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

Fix issue340 pgvector genarating #341

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
12 changes: 10 additions & 2 deletions src/sqlacodegen/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,17 @@ def fix_column_types(self, table: Table) -> None:

def get_adapted_type(self, coltype: Any) -> Any:
compiled_type = coltype.compile(self.bind.engine.dialect)
adapted_type: Any = None
for supercls in coltype.__class__.__mro__:
if not supercls.__name__.startswith("_") and hasattr(
supercls, "__visit_name__"
):
if (
supercls.__visit_name__ == "user_defined"
and adapted_type is not None
):
continue

# Hack to fix adaptation of the Enum class which is broken since
# SQLAlchemy 1.2
kw = {}
Expand Down Expand Up @@ -700,12 +707,13 @@ def get_adapted_type(self, coltype: Any) -> Any:
# If the adapted column type can't be compiled, don't substitute it
break

adapted_type = new_coltype

# Stop on the first valid non-uppercase column type class
coltype = new_coltype
if supercls.__name__ != supercls.__name__.upper():
break

return coltype
return adapted_type


class DeclarativeGenerator(TablesGenerator):
Expand Down
Loading