diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-02-16 17:20:18 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-02-16 17:20:18 -0500 |
commit | 5e100a70c51362b522c8d4a05c0149c7d77672fb (patch) | |
tree | ef92cedadf4a0277c247e39497f28ef7efa08cff /test/dialect/test_sqlite.py | |
parent | 79f801eae889ee6ee098ce3cd3b0ca98b852d2f5 (diff) | |
download | sqlalchemy-5e100a70c51362b522c8d4a05c0149c7d77672fb.tar.gz |
- The SQLite dialect will now skip unsupported arguments when reflecting
types; such as if it encounters a string like ``INTEGER(5)``, the
:class:`.INTEGER` type will be instantiated without the "5" being included,
based on detecting a ``TypeError`` on the first attempt.
Diffstat (limited to 'test/dialect/test_sqlite.py')
-rw-r--r-- | test/dialect/test_sqlite.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py index 319b708e7..38bb78304 100644 --- a/test/dialect/test_sqlite.py +++ b/test/dialect/test_sqlite.py @@ -11,7 +11,9 @@ from sqlalchemy import Table, String, select, Text, CHAR, bindparam, Column,\ Unicode, Date, MetaData, UnicodeText, Time, Integer, TIMESTAMP, \ Boolean, func, NUMERIC, DateTime, extract, ForeignKey, text, Numeric,\ DefaultClause, and_, DECIMAL, TypeDecorator, create_engine, Float, \ - INTEGER, UniqueConstraint, DATETIME, DATE, TIME, BOOLEAN, BIGINT + INTEGER, UniqueConstraint, DATETIME, DATE, TIME, BOOLEAN, BIGINT, \ + VARCHAR +from sqlalchemy.types import UserDefinedType from sqlalchemy.util import u, ue from sqlalchemy import exc, sql, schema, pool, types as sqltypes, util from sqlalchemy.dialects.sqlite import base as sqlite, \ @@ -30,7 +32,7 @@ class TestTypes(fixtures.TestBase, AssertsExecutionResults): """Test that the boolean only treats 1 as True """ - + meta = MetaData(testing.db) t = Table('bool_table', meta, Column('id', Integer, primary_key=True), Column('boo', @@ -161,12 +163,20 @@ class TestTypes(fixtures.TestBase, AssertsExecutionResults): assert not bindproc or \ isinstance(bindproc(util.u('some string')), util.text_type) + @testing.emits_warning("Could not instantiate") @testing.provide_metadata def test_type_reflection(self): metadata = self.metadata # (ask_for, roundtripped_as_if_different) + class AnyType(UserDefinedType): + def __init__(self, spec): + self.spec = spec + + def get_col_spec(self): + return self.spec + specs = [ (String(), String()), (String(1), String(1)), @@ -198,11 +208,14 @@ class TestTypes(fixtures.TestBase, AssertsExecutionResults): (Time, Time()), (BOOLEAN, BOOLEAN()), (Boolean, Boolean()), + # types with unsupported arguments + (AnyType("INTEGER(5)"), INTEGER()), + (AnyType("DATETIME(6, 12)"), DATETIME()), ] columns = [Column('c%i' % (i + 1), t[0]) for (i, t) in enumerate(specs)] db = testing.db - t_table = Table('types', metadata, *columns) + Table('types', metadata, *columns) metadata.create_all() m2 = MetaData(db) rt = Table('types', m2, autoload=True) @@ -218,7 +231,6 @@ class TestTypes(fixtures.TestBase, AssertsExecutionResults): finally: db.execute('DROP VIEW types_v') - @testing.emits_warning('Did not recognize') @testing.provide_metadata def test_unknown_reflection(self): metadata = self.metadata |