Skip to content
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

Fixed omission of 'collation' keyword in existing CHAR type #286

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
10 changes: 8 additions & 2 deletions src/sqlacodegen/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,15 @@ def group_imports(self) -> list[list[str]]:
future_imports: list[str] = []
stdlib_imports: list[str] = []
thirdparty_imports: list[str] = []
duplicate_imports = set()

for package in sorted(self.imports):
imports = ", ".join(sorted(self.imports[package]))
imports = sorted(self.imports[package])
unique_imports = [
import_ for import_ in imports if import_ not in duplicate_imports
]
duplicate_imports.update(imports)
imports_str = ", ".join(unique_imports)
collection = thirdparty_imports
if package == "__future__":
collection = future_imports
Expand All @@ -304,7 +310,7 @@ def group_imports(self) -> list[list[str]]:
if "site-packages" not in (sys.modules[package].__file__ or ""):
collection = stdlib_imports

collection.append(f"from {package} import {imports}")
collection.append(f"from {package} import {imports_str}")

for module in sorted(self.module_imports):
thirdparty_imports.append(f"import {module}")
Expand Down