#16809 closed Bug (fixed)
MySQL is not SQL standards compliant regarding IS NULL criteria on newly-inserted auto-incremented fields
Reported by: | jamesp | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.3 |
Severity: | Normal | Keywords: | mysql, sql standards, auto_increment, count |
Cc: | 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
MySQL has a setting which allows an auto-increment column to be returned on a newly-inserted row when tested for NULL. This is enabled by default prior to MySQL 5.6.
This is an edge case in Django, which caused the following tests for #15316 to fail:
- test_ticket15316_exclude_false
- test_ticket15316_one2one_exclude_false
To correct this behavior, the following statement must be issued, once per connection:
SET SQL_AUTO_IS_NULL = 0;
Re: http://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_sql_auto_is_null
Caveats:
This setting was introduced in MySQL 4.1 and is disabled in MySQL 5.6. This patch does not check the version of the database, and the documentation currently indicates that MySQL 3.23 may be used with Django. Please advise if version checking ought to be rolled into the provided patch.
Attachments (1)
Change History (5)
by , 13 years ago
Attachment: | mysql-set-sql_auto_is_null.patch added |
---|
comment:1 by , 13 years ago
comment:2 by , 13 years ago
Ignore what I said about the versions caveat as this setting is available in 3.23, 4.0, 4.1, and following.
comment:3 by , 13 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|
Clarification on status of setting in MySQL 5.6. The setting is available but it is disabled by default. Execution will not cause an error.
Test suite executed in MySQL 5.1.41, 116 tests passed successfully with 1 expected failure.