Fixed #22744 -- Fixed sqlite3 get_relations introspection with views

Thanks Tim Graham for the report and Simon Charette for the review.
This commit is contained in:
Claude Paroz 2014-06-01 22:03:33 +02:00
parent d04e730224
commit 5a504a5311
1 changed files with 5 additions and 1 deletions

View File

@ -79,7 +79,11 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
# Schema for this table # Schema for this table
cursor.execute("SELECT sql FROM sqlite_master WHERE tbl_name = %s AND type = %s", [table_name, "table"]) cursor.execute("SELECT sql FROM sqlite_master WHERE tbl_name = %s AND type = %s", [table_name, "table"])
try:
results = cursor.fetchone()[0].strip() results = cursor.fetchone()[0].strip()
except TypeError:
# It might be a view, then no results will be returned
return relations
results = results[results.index('(') + 1:results.rindex(')')] results = results[results.index('(') + 1:results.rindex(')')]
# Walk through and look for references to other tables. SQLite doesn't # Walk through and look for references to other tables. SQLite doesn't