Opened 13 months ago
Closed 9 months ago
#35839 closed Bug (fixed)
GeneratedField with db_comment causes syntax error
| Reported by: | Jason Christa | Owned by: | JaeHyuckSa |
|---|---|---|---|
| Component: | Migrations | Version: | 5.0 |
| Severity: | Normal | Keywords: | |
| Cc: | Jason Christa, Mariusz Felisiak | Triage Stage: | Ready for checkin |
| Has patch: | yes | 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 (10)
comment:1 by , 13 months ago
| Component: | Database layer (models, ORM) → Migrations |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 13 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 , 13 months ago
| Cc: | added |
|---|
follow-up: 5 comment:4 by , 13 months ago
| Owner: | set to |
|---|---|
| Status: | new → assigned |
I'd like to try resolving this ticket!
follow-up: 6 comment:5 by , 13 months 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 , 13 months 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!
comment:7 by , 9 months ago
| Owner: | changed from to |
|---|
comment:8 by , 9 months ago
| Has patch: | set |
|---|
comment:9 by , 9 months ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
Reproduced with the following test
tests/schema/tests.py
It appears that the problem is due to the order the the
COMMENTandGENERATEDclause in the generated SQL.MySQL expects
COMMENTto come afterGENERATEDwhile we do the oppositeCrashes while
passes.