Opened 4 months ago
Last modified 4 months 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 |
Pull Requests: | How to create a pull request | ||
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.
According to the ticket's flags, the next step(s) to move this issue forward are:
- To provide a patch by sending a pull request. Claim the ticket when you start working so that someone else doesn't duplicate effort. Before sending a pull request, review your work against the patch review checklist. Check the "Has patch" flag on the ticket after sending a pull request and include a link to the pull request in the ticket comment when making that update. The usual format is:
[https://github.com/django/django/pull/#### PR]
.
Change History (6)
comment:1 by , 4 months ago
Component: | Database layer (models, ORM) → Migrations |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 4 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 , 4 months ago
Cc: | added |
---|
follow-up: 5 comment:4 by , 4 months ago
Owner: | set to |
---|---|
Status: | new → assigned |
I'd like to try resolving this ticket!
follow-up: 6 comment:5 by , 4 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 , 4 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!
Reproduced with the following test
TabularUnified 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.