-
Notifications
You must be signed in to change notification settings - Fork 279
handle SQLAlchemy types with unimplemented python_type as typing.Any & use SQLModel.metadata as metadataref #425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1243,9 +1243,18 @@ def render_python_type(column_type: TypeEngine[Any]) -> str: | |
| if isinstance(column_type, DOMAIN): | ||
| python_type = column_type.data_type.python_type | ||
| else: | ||
| python_type = column_type.python_type | ||
| try: | ||
| python_type = column_type.python_type | ||
| except NotImplementedError: | ||
| self.add_literal_import("typing", "Any") | ||
| python_type = Any | ||
|
|
||
| python_type_name = ( | ||
| python_type.__name__ | ||
| if hasattr(python_type, "__name__") | ||
| else python_type._name | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the deal with this fallback? we can we expect for
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this just to accommodate
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, unfortunately and only in 3.9 as Any is a |
||
| ) | ||
|
|
||
| python_type_name = python_type.__name__ | ||
| python_type_module = python_type.__module__ | ||
| if python_type_module == "builtins": | ||
| return python_type_name | ||
|
|
@@ -1435,7 +1444,7 @@ def generate_base(self) -> None: | |
| self.base = Base( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a test to cover this behavior for SQLModels? |
||
| literal_imports=[], | ||
| declarations=[], | ||
| metadata_ref="", | ||
| metadata_ref="SQLModel.metadata", | ||
| ) | ||
|
|
||
| def collect_imports(self, models: Iterable[Model]) -> None: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.