[Django] #24113: django.db.backends.sqlite3.introspection.get_constraints does not return constraint names.

8 views
Skip to first unread message

Django

unread,
Jan 10, 2015, 2:10:58 AM1/10/15
to django-...@googlegroups.com
#24113: django.db.backends.sqlite3.introspection.get_constraints does not return
constraint names.
-------------------------------+--------------------
Reporter: dnozay | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
`django.db.backends.sqlite3.introspection.get_constraints` does not return
constraint names.

I was trying to add a regression test for
https://github.com/django/django/pull/3862 .

However the introspection does not get the constraint names properly.

Here is how you would get the equivalent of `show create table` in
`sqlite3`.

{{{#!python
cursor.execute("SELECT sql FROM sqlite_master WHERE tbl_name =
%s", [table])
result = cursor.fetchall()[0]
}}}

e.g. this is the output for `tests.schema.models.UniqueTest`

{{{
[(u'CREATE TABLE "schema_uniquetest" ("id" integer NOT NULL PRIMARY KEY
AUTOINCREMENT, "year" integer NOT NULL, "slug" varchar(50) NOT NULL,
CONSTRAINT "schema_uniquetest_year_4b36f60cc3fa9c74_uniq" UNIQUE ("year",
"slug"))',),
}}}

vs. the output of `connection.introspection.get_constraints`

{{{
{'__primary__': {'check': False,
'columns': [u'id'],
'foreign_key': False,
'index': False,
'primary_key': True,
'unique': False},
u'schema_uniquetest_2dbcba41': {'check': False,
'columns': [u'slug'],
'foreign_key': False,
'index': True,
'primary_key': False,
'unique': False},
u'sqlite_autoindex_schema_uniquetest_1': {'check': False,
'columns': [u'year', u'slug'],
'foreign_key': False,
'index': True,
'primary_key': False,
'unique': True}}

}}}


side note: would be helpful to refactor `django.db.backends.schema` so
that `create_model` uses a helper function that generates the sql
statements; which whould make it possible to inspect the sql more easily
in tests.

--
Ticket URL: <https://code.djangoproject.com/ticket/24113>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 16, 2015, 10:04:09 AM1/16/15
to django-...@googlegroups.com
#24113: django.db.backends.sqlite3.introspection.get_constraints does not return
constraint names.
-------------------------------------+-------------------------------------
Reporter: dnozay | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* component: Uncategorized => Database layer (models, ORM)
* needs_tests: => 0
* version: 1.7 => master
* needs_docs: => 0
* type: Uncategorized => New feature
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/24113#comment:1>

Django

unread,
Aug 20, 2016, 5:08:09 PM8/20/16
to django-...@googlegroups.com
#24113: django.db.backends.sqlite3.introspection.get_constraints does not return
constraint names.
-------------------------------------+-------------------------------------
Reporter: dnozay | Owner: nobody
Type: New feature | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):

* status: new => closed
* resolution: => needsinfo


Comment:

I have tried a bit but was unable to reproduce that index name mismatch.
Could you please provide some test case where this difference would show
up?

--
Ticket URL: <https://code.djangoproject.com/ticket/24113#comment:2>

Reply all
Reply to author
Forward
0 new messages