Fixed up the introspection code and tests added for #9779 to run under Python 2.3, which has neither set nor rsplit.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10392 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
bb31cf37ff
commit
48e01d2b3d
|
@ -67,8 +67,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
||||||
# Schema for this table
|
# 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", [table_name])
|
||||||
results = cursor.fetchone()[0].strip()
|
results = cursor.fetchone()[0].strip()
|
||||||
results = results.split('(', 1)[1]
|
results = results[results.index('(')+1:results.rindex(')')]
|
||||||
results = results.rsplit(')', 1)[0]
|
|
||||||
|
|
||||||
# Walk through and look for references to other tables. SQLite doesn't
|
# Walk through and look for references to other tables. SQLite doesn't
|
||||||
# really have enforced references, but since it echoes out the SQL used
|
# really have enforced references, but since it echoes out the SQL used
|
||||||
|
@ -89,8 +88,9 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
|
||||||
if not result:
|
if not result:
|
||||||
continue
|
continue
|
||||||
other_table_results = result[0].strip()
|
other_table_results = result[0].strip()
|
||||||
other_table_results = other_table_results.split('(', 1)[1]
|
li, ri = other_table_results.index('('), other_table_results.rindex(')')
|
||||||
other_table_results = other_table_results.rsplit(')', 1)[0]
|
other_table_results = other_table_results[li+1:ri]
|
||||||
|
|
||||||
|
|
||||||
for other_index, other_desc in enumerate(other_table_results.split(',')):
|
for other_index, other_desc in enumerate(other_table_results.split(',')):
|
||||||
other_desc = other_desc.strip()
|
other_desc = other_desc.strip()
|
||||||
|
|
|
@ -5,6 +5,11 @@ from django.utils import functional
|
||||||
|
|
||||||
from models import Reporter, Article
|
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
|
# The introspection module is optional, so methods tested here might raise
|
||||||
# NotImplementedError. This is perfectly acceptable behavior for the backend
|
# NotImplementedError. This is perfectly acceptable behavior for the backend
|
||||||
|
|
Loading…
Reference in New Issue