summaryrefslogtreecommitdiff
path: root/test/dialect/sqlite.py
diff options
context:
space:
mode:
authorJason Kirtland <jek@discorporate.us>2008-02-01 08:11:12 +0000
committerJason Kirtland <jek@discorporate.us>2008-02-01 08:11:12 +0000
commitb79f23d3d02e785221d93544f476247097fdea0e (patch)
tree1f2b585ffafe8c47752e2ba205541db98ca33862 /test/dialect/sqlite.py
parenta0ffeb546468e14fa9d99b30571f7b8f9b32f421 (diff)
downloadsqlalchemy-b79f23d3d02e785221d93544f476247097fdea0e.tar.gz
- fixed reflection of Time columns on sqlite
Diffstat (limited to 'test/dialect/sqlite.py')
-rw-r--r--test/dialect/sqlite.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/test/dialect/sqlite.py b/test/dialect/sqlite.py
index f04093b89..5041cca89 100644
--- a/test/dialect/sqlite.py
+++ b/test/dialect/sqlite.py
@@ -31,6 +31,74 @@ class TestTypes(AssertMixin):
finally:
meta.drop_all()
+ @testing.uses_deprecated('Using String type with no length')
+ def test_type_reflection(self):
+ # (ask_for, roundtripped_as_if_different)
+ specs = [( String(), sqlite.SLText(), ),
+ ( String(1), sqlite.SLString(1), ),
+ ( String(3), sqlite.SLString(3), ),
+ ( Text(), sqlite.SLText(), ),
+ ( Unicode(), sqlite.SLText(), ),
+ ( Unicode(1), sqlite.SLString(1), ),
+ ( Unicode(3), sqlite.SLString(3), ),
+ ( UnicodeText(), sqlite.SLText(), ),
+ ( CLOB, sqlite.SLText(), ),
+ ( sqlite.SLChar(1), ),
+ ( CHAR(3), sqlite.SLChar(3), ),
+ ( NCHAR(2), sqlite.SLChar(2), ),
+ ( SmallInteger(), sqlite.SLSmallInteger(), ),
+ ( sqlite.SLSmallInteger(), ),
+ ( Binary(3), sqlite.SLBinary(), ),
+ ( Binary(), sqlite.SLBinary() ),
+ ( sqlite.SLBinary(3), sqlite.SLBinary(), ),
+ ( NUMERIC, sqlite.SLNumeric(), ),
+ ( NUMERIC(10,2), sqlite.SLNumeric(10,2), ),
+ ( Numeric, sqlite.SLNumeric(), ),
+ ( Numeric(10, 2), sqlite.SLNumeric(10, 2), ),
+ ( DECIMAL, sqlite.SLNumeric(), ),
+ ( DECIMAL(10, 2), sqlite.SLNumeric(10, 2), ),
+ ( Float, sqlite.SLNumeric(), ),
+ ( sqlite.SLNumeric(), ),
+ ( INT, sqlite.SLInteger(), ),
+ ( Integer, sqlite.SLInteger(), ),
+ ( sqlite.SLInteger(), ),
+ ( TIMESTAMP, sqlite.SLDateTime(), ),
+ ( DATETIME, sqlite.SLDateTime(), ),
+ ( DateTime, sqlite.SLDateTime(), ),
+ ( sqlite.SLDateTime(), ),
+ ( DATE, sqlite.SLDate(), ),
+ ( Date, sqlite.SLDate(), ),
+ ( sqlite.SLDate(), ),
+ ( TIME, sqlite.SLTime(), ),
+ ( Time, sqlite.SLTime(), ),
+ ( sqlite.SLTime(), ),
+ ( BOOLEAN, sqlite.SLBoolean(), ),
+ ( Boolean, sqlite.SLBoolean(), ),
+ ( sqlite.SLBoolean(), ),
+ ]
+ columns = [Column('c%i' % (i + 1), t[0]) for i, t in enumerate(specs)]
+
+ db = testing.db
+ m = MetaData(db)
+ t_table = Table('types', m, *columns)
+ try:
+ m.create_all()
+
+ m2 = MetaData(db)
+ rt = Table('types', m2, autoload=True)
+ try:
+ db.execute('CREATE VIEW types_v AS SELECT * from types')
+ rv = Table('types_v', m2, autoload=True)
+
+ expected = [len(c) > 1 and c[1] or c[0] for c in specs]
+ for table in rt, rv:
+ for i, reflected in enumerate(table.c):
+ print reflected.type, type(expected[i])
+ assert isinstance(reflected.type, type(expected[i]))
+ finally:
+ db.execute('DROP VIEW types_v')
+ finally:
+ m.drop_all()
class DialectTest(AssertMixin):
__only_on__ = 'sqlite'