Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #13396 -- Modified the SQLite introspection code to avoid a pro…

…blem with unconsumed cursors on PyPy. Thanks to Alex Gaynor for the report and fix.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13016 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 5866875547515bd8a1f7082404414602cf112355 1 parent b5dc794
@freakboy3742 freakboy3742 authored
View
2  django/db/backends/sqlite3/introspection.py
@@ -66,7 +66,7 @@ def get_relations(self, cursor, table_name):
relations = {}
# Schema for this table
- cursor.execute("SELECT sql FROM sqlite_master WHERE tbl_name = %s", [table_name])
+ cursor.execute("SELECT sql FROM sqlite_master WHERE tbl_name = %s AND type = %s", [table_name, "table"])
results = cursor.fetchone()[0].strip()
results = results[results.index('(')+1:results.rindex(')')]
View
11 tests/regressiontests/introspection/tests.py
@@ -5,11 +5,6 @@
from models import Reporter, Article
-try:
- set
-except NameError:
- from sets import Set as set # Python 2.3 fallback
-
#
# The introspection module is optional, so methods tested here might raise
# NotImplementedError. This is perfectly acceptable behavior for the backend
@@ -76,8 +71,10 @@ def test_get_table_description_names(self):
def test_get_table_description_types(self):
cursor = connection.cursor()
desc = connection.introspection.get_table_description(cursor, Reporter._meta.db_table)
- self.assertEqual([datatype(r[1], r) for r in desc],
- ['IntegerField', 'CharField', 'CharField', 'CharField', 'BigIntegerField'])
+ self.assertEqual(
+ [datatype(r[1], r) for r in desc],
+ ['IntegerField', 'CharField', 'CharField', 'CharField', 'BigIntegerField']
+ )
# Regression test for #9991 - 'real' types in postgres
if settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].startswith('django.db.backends.postgresql'):
Please sign in to comment.
Something went wrong with that request. Please try again.