#24362 closed Bug (fixed)
Migration test failure on Oracle
Reported by: | Shai Berger | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 1.8alpha1 |
Severity: | Release blocker | Keywords: | oracle |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
On CI, reporoduces also on my laptop:
====================================================================== ERROR [0.000s]: test_run_python_related_assignment (migrations.test_operations.OperationTests) ---------------------------------------------------------------------- Traceback (most recent call last): File ".../tests/migrations/test_operations.py", line 1714, in test_run_python_related_assignment create_old_man.database_forwards("test_books", editor, project_state, new_state) File ".../django/db/migrations/operations/special.py", line 179, in database_forwards self.code(from_state.apps, schema_editor) File ".../tests/migrations/test_operations.py", line 1671, in inner_method author = Author.objects.create(name="Hemingway") File ".../django/db/models/manager.py", line 127, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File ".../django/db/models/query.py", line 401, in create obj.save(force_insert=True, using=self.db) File ".../django/db/models/base.py", line 676, in save force_update=force_update, update_fields=update_fields) File ".../django/db/models/base.py", line 704, in save_base updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File ".../django/db/models/base.py", line 788, in _save_table result = self._do_insert(cls._base_manager, using, fields, update_pk, raw) File ".../django/db/models/base.py", line 827, in _do_insert using=using, raw=raw) File ".../django/db/models/manager.py", line 127, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File ".../django/db/models/query.py", line 1026, in _insert return query.get_compiler(using=using).execute_sql(return_id) File ".../django/db/models/sql/compiler.py", line 963, in execute_sql cursor.execute(sql, params) File ".../django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File ".../django/db/utils.py", line 92, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File ".../django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File ".../django/db/backends/oracle/base.py", line 478, in execute return self.cursor.execute(query, self._param_generator(params)) IntegrityError: ORA-01400: cannot insert NULL into ("D_DJANGOORACLE_27"."TEST_AUTHORS_AUTHOR"."ID")
Bisecting leads to the commit that added the test; it was added (failing) for #24282, and the failure was later fixed.
The failure on Oracle is unrelated to the problem reported on the ticket, but since the solution (b29f3b51204d53c1c8745966476543d068c173a2) involved a rewrite of model reloading, it may be related.
Change History (5)
comment:1 by , 10 years ago
Has patch: | set |
---|---|
Version: | 1.7 → 1.8alpha1 |
comment:2 by , 10 years ago
The only thing how I'd be to explain this problem is by some statement cache on oracle, but not sure if this applies here or anymore in general. It's definitely unrelated to the state rewrite.
comment:3 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:5 by , 10 years ago
The explanation is that on Oracle, the auto-field is implemented using a trigger; the code that creates the trigger is added in the CreateModel
migration operation as deferred sql. Deferred sql is only executed in the schema editor's __exit__
. In most tests around this one in the file you can see migration operations performed each in its own schema editor. I did the same here.
PR -- Hopefully you can explain it.