#27180 closed Bug (fixed)
Check for sql_mode fails during migration with special database connections
| Reported by: | Markus Gerards | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.10 |
| Severity: | Release blocker | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I believe I found again a bug regarding some special database connections (like #26991):
Running migrate raises this error:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 342, in execute
self.check()
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 374, in check
include_deployment_checks=include_deployment_checks,
File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 61, in _run_checks
issues = run_checks(tags=[Tags.database])
File "/usr/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/usr/local/lib/python2.7/site-packages/django/core/checks/database.py", line 10, in check_database_backends
issues.extend(conn.validation.check(**kwargs))
File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py", line 9, in check
issues.extend(self._check_sql_mode(**kwargs))
File "/usr/local/lib/python2.7/site-packages/django/db/backends/mysql/validation.py", line 16, in _check_sql_mode
modes = set(sql_mode[0].split(','))
TypeError: 'NoneType' object has no attribute '__getitem__'
The reason is, that SELECT @@sql_mode returns no results in my special case.
Just a little side note: migrate runs database checks against all database connections, no matter if a database is selected via the --database parameter or if migrations are not allowed because of a database router. I'm not quite sure if this works as intended.
Attachments (1)
Change History (11)
comment:1 by , 9 years ago
| Component: | Migrations → Database layer (models, ORM) |
|---|---|
| Severity: | Normal → Release blocker |
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 9 years ago
comment:3 by , 9 years ago
From #26991, "I'm connecting via MySQL to an sphinxsearch database. It basically uses the MySQL query language but has some special features."
follow-up: 6 comment:4 by , 9 years ago
I'm wondering if we should continue this way with this special usage. Wouldn't the right solution to subclass the MySQL backend and adapt the checks?
comment:5 by , 9 years ago
I'm not sure how much ongoing work it would add to support this but if the backend has otherwise been usable since some old version of Django, then it seem reasonable to try to continue that as long as only minor changes are needed. We could also demote such issues from release blockers and require people using these special connections to submit patches themselves.
by , 9 years ago
| Attachment: | 27180.diff added |
|---|
comment:6 by , 9 years ago
Replying to claudep:
I'm wondering if we should continue this way with this special usage. Wouldn't the right solution to subclass the MySQL backend and adapt the checks?
This is for sure no problem for us if we run into another problems in future. But in this specific case I believe there can be other cases where this error could occur. I've attached a little patch, that works for us.
comment:7 by , 9 years ago
@gerricom: thanks for the patch, could you provide it as a pull request on Github?
Could we know a bit more about that
special database connection, please?