Open np-kyokyo opened 1 month ago
~I'm dealing with this issue...~ I've been too busy to handle it.
Did you install the project with the pgvector
extra?
@agronholm yes. this is minimal requirements.lock to reproduce the issue.
# generated by rye
# use `rye lock` or `rye sync` to update this lockfile
#
# last locked with the following flags:
# pre: false
# features: []
# all-features: false
# with-sources: false
# generate-hashes: false
inflect==7.3.1
# via sqlacodegen
more-itertools==10.3.0
# via inflect
numpy==2.0.0
# via pgvector
pgvector==0.3.1
psycopg2==2.9.9
sqlacodegen==3.0.0rc5
sqlalchemy==2.0.31
# via sqlacodegen
typeguard==4.3.0
# via inflect
typing-extensions==4.12.2
# via sqlalchemy
# via typeguard
Others have successfully tested the pgvector integration. Any idea why it's not working for you?
I downgraded pgvector to 0.2.5 and it worked fine, was having the same issue before!
Pinpointing the specific commit where it starts to fail would probably help.
Things to check first
[X] I have searched the existing issues and didn't find my bug already reported there
[X] I have checked that my bug is still present in the latest release
Sqlacodegen version
3.0.0rc5
SQLAlchemy version
2.0.31
RDBMS vendor
PostgreSQL
What happened?
Issue:
When attempting to add a new column to the
recommend_model."Image"
table using the following SQL command:then, we encountered an issue where the
pgvector.sqlalchemy.vector.VECTOR
type is not being properly recognized in the context of theget_adapted_type
method. This results in the column type falling back tosqlalchemy.sql.type_api.UserDefinedType
instead.Analysis
The VECTOR type is recognized, but since it is an uppercase type, the loop continues to check for any camel case types. As a result, UserDefinedType is found, but since it does not have the get_col_spec method, an error occurs.
Potential Fixes
Avoid to use UserDefinedType when get adapted type:
UserDefinedTypeが発見された場合、すでにnew_coltypeがあった場合はそちらを優先する方針がよさそう。 It seems a good approach to prioritize an existing detected new_coltype if UserDefinedType is found.
It seem to be below:
Add Special Handling for
VECTOR
: Include a specific check for theVECTOR
type:VECTORの時点で現状、キャメルケースがくることはない。→しかし、今後来るようになる可能性はある? Currently, there are no camel case types coming after VECTOR. However, it is possible that they might come in the future.
Remove the Uppercase Check: Replace the existing check with a break statement, allowing
VECTOR
to be recognized:→ Due to the impact on other areas, this approach is rejected.
Output on success
References
Commit where if supercls.name != supercls.name.upper() was introduced
ralated issue
https://github.com/agronholm/sqlacodegen/issues/300
What is the difference between
Text
andTEXT
types in SQLAlchemy?ref. https://docs.sqlalchemy.org/en/20/core/type_basics.html#generic-camelcase-types
Removing
if supercls.__name__ != supercls.__name__.upper(): break
results in differences, such as parts previously outputting asText
now appearing asTEXT
.Database schema for reproducing the bug
(WIP)