Skip to content

Conversation

@makhalin
Copy link

  • Introduced types.Optional wrapper for nullable fields in StructType.
  • Added StructType.from_table(table) helper method to generate StructType from sa.Table.
  • Updated compiler to handle optional fields and type instances in StructType binding.
  • Added integration tests for upsert/insert with AS_TABLE and reflection usage in test/test_core.py.


def visit_optional(self, type_: types.Optional, **kw):
el = type_.element_type
if isinstance(el, type):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Let's use the helper function from the sqlaclhemy:

from sqlalchemy.sql.type_api import to_instance

The same below

Comment on lines +164 to +168
for field, field_type in type_.fields_types.items():
type_str = self.process(field_type, **kw)
text += f"{field}:{type_str},"
if text.endswith(","):
text = text[:-1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): Let's use join here, like

return f"Struct<{','.join(...)}>"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants