agronholm / sqlacodegen

Automatic model code generator for SQLAlchemy
Other
1.78k stars 236 forks source link

UUID for postgreSQL #331

Open chris-han opened 1 month ago

chris-han commented 1 month ago

Things to check first

Feature description

3.0.0RC5 generated model for pgsql using generic uuid type uuid.UUID, which need to be manually converted to the UUID type from sqlalchemy.dialects.postgresql: from sqlalchemy.dialects.postgresql import UUID

from: uuid: Mapped[uuid.UUID] = mapped_column(Uuid, primary_key=True) to: uuid: Mapped[UUID] = mapped_column(Uuid, primary_key=True)

Use case

You'll need this every time you generate the models from pgsql which contains uuid type.

dominusmi commented 1 month ago

Pushed a possible fix. A bit hacky but give it a look. Tested locally on my database and works, wanted to run the repo tests and potentially add a test for this case, but they seem to be failing on master