summaryrefslogtreecommitdiff
path: root/test/dialect/test_sqlite.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-09-19 00:34:30 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-09-19 00:34:30 -0400
commit9e3458c4793e863737df371774b39c4c05858abd (patch)
tree66f0e323bc04d35fc7794b7a33cb75068be9a0b3 /test/dialect/test_sqlite.py
parentb76995600a633ed769530a00b6489560456e7b0c (diff)
downloadsqlalchemy-9e3458c4793e863737df371774b39c4c05858abd.tar.gz
- [bug] Adjusted a very old bugfix which attempted
to work around a SQLite issue that itself was "fixed" as of sqlite 3.6.14, regarding quotes surrounding a table name when using the "foreign_key_list" pragma. The fix has been adjusted to not interfere with quotes that are *actually in the name* of a column or table, to as much a degree as possible; sqlite still doesn't return the correct result for foreign_key_list() if the target table actually has quotes surrounding its name, as *part* of its name (i.e. """mytable"""). [ticket:2568]
Diffstat (limited to 'test/dialect/test_sqlite.py')
-rw-r--r--test/dialect/test_sqlite.py57
1 files changed, 44 insertions, 13 deletions
diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py
index 4ce3d8fb6..cfc49af12 100644
--- a/test/dialect/test_sqlite.py
+++ b/test/dialect/test_sqlite.py
@@ -385,11 +385,11 @@ class DialectTest(fixtures.TestBase, AssertsExecutionResults):
finally:
meta.drop_all()
- def test_quoted_identifiers(self):
+ @testing.provide_metadata
+ def test_quoted_identifiers_one(self):
"""Tests autoload of tables created with quoted column names."""
- # This is quirky in sqlite.
-
+ metadata = self.metadata
testing.db.execute("""CREATE TABLE "django_content_type" (
"id" integer NOT NULL PRIMARY KEY,
"django_stuff" text NULL
@@ -405,16 +405,47 @@ class DialectTest(fixtures.TestBase, AssertsExecutionResults):
"change_message" text NOT NULL
)
""")
- try:
- meta = MetaData(testing.db)
- table1 = Table('django_admin_log', meta, autoload=True)
- table2 = Table('django_content_type', meta, autoload=True)
- j = table1.join(table2)
- assert j.onclause.compare(table1.c.content_type_id
- == table2.c.id)
- finally:
- testing.db.execute('drop table django_admin_log')
- testing.db.execute('drop table django_content_type')
+ table1 = Table('django_admin_log', metadata, autoload=True)
+ table2 = Table('django_content_type', metadata, autoload=True)
+ j = table1.join(table2)
+ assert j.onclause.compare(table1.c.content_type_id
+ == table2.c.id)
+
+ @testing.provide_metadata
+ def test_quoted_identifiers_two(self):
+ """"test the edgiest of edge cases, quoted table/col names
+ that start and end with quotes.
+
+ SQLite claims to have fixed this in
+ http://www.sqlite.org/src/info/600482d161, however
+ it still fails if the FK points to a table name that actually
+ has quotes as part of its name.
+
+ """
+
+ metadata = self.metadata
+ testing.db.execute(r'''CREATE TABLE """a""" (
+ """id""" integer NOT NULL PRIMARY KEY
+ )
+ ''')
+
+ # unfortunately, still can't do this; sqlite quadruples
+ # up the quotes on the table name here for pragma foreign_key_list
+ #testing.db.execute(r'''
+ #CREATE TABLE """b""" (
+ # """id""" integer NOT NULL PRIMARY KEY,
+ # """aid""" integer NULL
+ # REFERENCES """a""" ("""id""")
+ #)
+ #''')
+
+ table1 = Table(r'"a"', metadata, autoload=True)
+ assert '"id"' in table1.c
+
+ #table2 = Table(r'"b"', metadata, autoload=True)
+ #j = table1.join(table2)
+ #assert j.onclause.compare(table1.c['"id"']
+ # == table2.c['"aid"'])
def test_attached_as_schema(self):
cx = testing.db.connect()