-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Fixed #11964 -- Added support for check constraints in model Meta. #7615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
django/db/models/constraints.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work because I don't have access to a suitable compiler
. I will also need to add support for as_sql
to Q
objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From #8056, it looks like I can do:
compiler = connection.ops.compiler('SQLCompiler')(None, connection, 'default')
f7f256c
to
89b2092
Compare
django/db/models/constraints.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gets me further. Unfortunately, I appear to need a more complete query
instead of None
, so Col.as_sql
can be evaluated.
tests/migrations/test_operations.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long term, I want to be able to use Q(pink__gt=2)
here, but for now using this avoids the need to implement Q.as_sql
.
tests/migrations/test_state.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't really thought whether this is the best way to fix these tests, but it is sufficient for now.
fc2f707
to
835f04e
Compare
I'm not sure where is best to put MySQL error handling. It supports the syntax, but |
https://code.djangoproject.com/ticket/11964