Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/sqlacodegen/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ def group_imports(self) -> list[list[str]]:
collection.append(f"from {package} import {imports}")

for module in sorted(self.module_imports):
thirdparty_imports.append(f"import {module}")
# all third-party module references must include a `_module` prefix to avoid collision with field names
thirdparty_imports.append(f"import {module} as {module}_module")

return [
group
Expand Down Expand Up @@ -1204,7 +1205,7 @@ def render_column_attribute(self, column_attr: ColumnAttribute) -> str:
column_python_type = python_type_name
else:
python_type_module = python_type.__module__
column_python_type = f"{python_type_module}.{python_type_name}"
column_python_type = f"{python_type_module}_module.{python_type_name}"
self.add_module_import(python_type_module)
except NotImplementedError:
self.add_literal_import("typing", "Any")
Expand Down
Loading