Opened 2 months ago
Last modified 7 weeks ago
#35839 assigned Bug
GeneratedField with db_comment causes syntax error
Reported by: | Jason Christa | Owned by: | JasonCalm |
---|---|---|---|
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 (6)
comment:1 by , 2 months ago
Component: | Database layer (models, ORM) → Migrations |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 2 months 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 , 2 months ago
Cc: | added |
---|
follow-up: 5 comment:4 by , 2 months ago
Owner: | set to |
---|---|
Status: | new → assigned |
I'd like to try resolving this ticket!
follow-up: 6 comment:5 by , 7 weeks ago
Replying to JasonCalm:
I'd like to try resolving this ticket!
Jason, are you working on this? If not, I'd be happy to pass this to my Djangonauts.
comment:6 by , 7 weeks ago
Replying to Mariusz Felisiak:
Replying to JasonCalm:
I'd like to try resolving this ticket!
Jason, are you working on this? If not, I'd be happy to pass this to my Djangonauts.
Yes, I'm currently working on this part!
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.