Skip to content

Commit

Permalink
[1.1.X] Fixed #13396 -- Modified the SQLite introspection code to avo…
Browse files Browse the repository at this point in the history
…id a problem with unconsumed cursors on PyPy. Thanks to Alex Gaynor for the report and fix.

Backport of r13016 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@13017 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
freakboy3742 committed Apr 21, 2010
1 parent 0e99698 commit af48cad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion django/db/backends/sqlite3/introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,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(')')]

Expand Down
11 changes: 4 additions & 7 deletions tests/regressiontests/introspection/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'])
self.assertEqual(
[datatype(r[1], r) for r in desc],
['IntegerField', 'CharField', 'CharField', 'CharField']
)

# Regression test for #9991 - 'real' types in postgres
if settings.DATABASE_ENGINE.startswith('postgresql'):
Expand Down

0 comments on commit af48cad

Please sign in to comment.