Skip to content

Customise column type parameters for reflection #6141

Answered by zzzeek
ghost asked this question in Usage Questions
Discussion options

You must be logged in to vote

Is your feature request related to a problem? Please describe.
Example: Reflection of a Postgres DB that uses UUID will result in Column with UUID(as_uuid=False) as the type, which causes SQLAlchemy to call .replace on my UUID objects when I insert.

Describe the solution you'd like
Some hook I can provide to automap_base? I'm not sure what would be the best.

The automap base documents this hook, which is not specific to automap, at https://docs.sqlalchemy.org/en/14/orm/extensions/automap.html#intercepting-column-definitions . Inspect the "type" member of the dictionary for the UUID type and set as_uuid=True.

Bonus question: Will anything break if I replace type of the column after the …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by CaselIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant
Converted from issue

This discussion was converted from issue #6140 on March 26, 2021 13:11.