Opened 3 hours ago
Last modified 18 minutes ago
#35839 new Bug
GeneratedField with db_comment causes syntax error
Reported by: | Jason Christa | Owned by: | |
---|---|---|---|
Component: | Migrations | Version: | 5.0 |
Severity: | Normal | Keywords: | |
Cc: | Jason Christa, Mariusz Felisiak | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Adding a new GeneratedField with the db_comment argument cause invalid SQL to be generated for MySQL (maybe others but that is all I tested). Altering a GeneratedField with a db_comment seems to work fine.
Change History (3)
comment:1 by , 2 hours ago
Component: | Database layer (models, ORM) → Migrations |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 2 hours ago
Jason, If you're interested in submitting a patch it seems that the solution lies in changing the order of the generated SQL in _iter_column_sql
.
comment:3 by , 18 minutes ago
Cc: | added |
---|
Note:
See TracTickets
for help on using tickets.
Reproduced with the following test
tests/schema/tests.py
It appears that the problem is due to the order the the
COMMENT
andGENERATED
clause in the generated SQL.MySQL expects
COMMENT
to come afterGENERATED
while we do the oppositeCrashes while
passes.