Why are association tables generated as Table and not as Declarative Model? #174
Unanswered
dirkdevries96
asked this question in
Q&A
Replies: 1 comment
-
The reason is that SQLAlchemy cannot keep such "association objects", in sync with the relationship attributes, causing some very puzzling bugs. If your intent is to not have a direct many-to-many relationship between Project and ProfileType, that's fine then, but sqlacodegen does not have a way for the user to communicate such intent at the moment, so you'll have to edit the generated code a bit. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm interested in generating association table using Declarative Base. This way this table can be referenced elsewhere in a declarative way.
But the readme states the following:
Model class generators
The code generators that generate classes try to generate model classes whenever possible. There are two circumstances in which a Table is generated instead:
Is there a specific reason why it's done this way? Is perhaps my use case of referencing an association table not good practice?
Below is an expample of the current code generated.
Beta Was this translation helpful? Give feedback.
All reactions