#21134: Documentation for transaction.atomic needs more explicit warning about catching DatabaseErrors -------------------------------------+------------------------------------- Reporter: RichardOfWard | Owner: aaugustin Type: | Status: assigned Cleanup/optimization | Version: Component: Documentation | 1.6-beta-1 Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 1 Easy pickings: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by Harm Geerts <hgeerts@…>): I receive the same failure on master with postgres-9.3.0 The test fails because the constraint columns from introspection are returned in reversed order so it doesn't match the existing constraint in _constraint_names() https://github.com/django/django/blob/master/django/db/backends/schema.py#L720 e.g. [year, slug] == [slug, year] fails. Even when using a new connection on the test database the order remains reversed. However, when using an explicit collate it will return in the expected order. The database was created with encoding/collation nl_NL.UTF-8 First query is equal to what introspection.get_constraints() uses. The second uses COLLATE "C" and the last uses COLLATE "nk_NL". So somewhere in the test suite postgres gets confused and switches collation to something odd? {{{ test_django_default=# SELECT kc.constraint_name, kc.column_name, c.constraint_type, array(SELECT table_name::text || '.' || column_name::text FROM information_schema.constraint_column_usage WHERE constraint_name = kc.constraint_name) FROM information_schema.key_column_usage AS kc JOIN information_schema.table_constraints AS c ON kc.table_schema = c.table_schema AND kc.table_name = c.table_name AND kc.constraint_name = c.constraint_name WHERE kc.table_schema = 'public' AND kc.table_name = 'schema_uniquetest'; constraint_name | column_name | constraint_type | array ---------------------------------+-------------+-----------------+------------------------------------------------- schema_uniquetest_year_slug_key | slug | UNIQUE | {schema_uniquetest.year,schema_uniquetest.slug} schema_uniquetest_year_slug_key | year | UNIQUE | {schema_uniquetest.year,schema_uniquetest.slug} schema_uniquetest_pkey | id | PRIMARY KEY | {schema_uniquetest.id} (3 rows) test_django_default=# SELECT kc.constraint_name, kc.column_name, c.constraint_type, array(SELECT table_name::text || '.' || column_name::text FROM information_schema.constraint_column_usage WHERE constraint_name = kc.constraint_name) FROM information_schema.key_column_usage AS kc JOIN information_schema.table_constraints AS c ON kc.table_schema = c.table_schema AND kc.table_name = c.table_name AND kc.constraint_name = c.constraint_name WHERE kc.table_schema = 'public' AND kc.table_name = 'schema_uniquetest' COLLATE "C"; constraint_name | column_name | constraint_type | array ---------------------------------+-------------+-----------------+------------------------------------------------- schema_uniquetest_pkey | id | PRIMARY KEY | {schema_uniquetest.id} schema_uniquetest_year_slug_key | year | UNIQUE | {schema_uniquetest.year,schema_uniquetest.slug} schema_uniquetest_year_slug_key | slug | UNIQUE | {schema_uniquetest.year,schema_uniquetest.slug} (3 rows) test_django_default=# SELECT kc.constraint_name, kc.column_name, c.constraint_type, array(SELECT table_name::text || '.' || column_name::text FROM information_schema.constraint_column_usage WHERE constraint_name = kc.constraint_name) FROM information_schema.key_column_usage AS kc JOIN information_schema.table_constraints AS c ON kc.table_schema = c.table_schema AND kc.table_name = c.table_name AND kc.constraint_name = c.constraint_name WHERE kc.table_schema = 'public' AND kc.table_name = 'schema_uniquetest' COLLATE "nl_NL"; constraint_name | column_name | constraint_type | array ---------------------------------+-------------+-----------------+------------------------------------------------- schema_uniquetest_pkey | id | PRIMARY KEY | {schema_uniquetest.id} schema_uniquetest_year_slug_key | year | UNIQUE | {schema_uniquetest.year,schema_uniquetest.slug} schema_uniquetest_year_slug_key | slug | UNIQUE | {schema_uniquetest.year,schema_uniquetest.slug} (3 rows) }}} -- Ticket URL: <https://code.djangoproject.com/ticket/21134#comment:12> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/071.82a34ab30b8944020a93996ae1d13146%40djangoproject.com. For more options, visit https://groups.google.com/groups/opt_out.