summaryrefslogtreecommitdiff
path: root/test/engine/test_reflection.py
diff options
context:
space:
mode:
authorErich Blume <blume.erich@gmail.com>2014-02-03 16:55:00 -0800
committerErich Blume <blume.erich@gmail.com>2014-02-03 16:55:00 -0800
commite47f99450378a7b1ea29a8493c0692bcf8669da3 (patch)
tree8add39d04bfb28e187bf6dc8cd90d7e4524c8aeb /test/engine/test_reflection.py
parentc188526a74486596bfaef2dadbaeff915ec34812 (diff)
downloadsqlalchemy-pr/65.tar.gz
SQLite dialect - support relection from affinitypr/65
SQLite allows column types that aren't technically understood in sqlite by using 'data affinity', which is an algorithm for converting column types in to some sort of useful type that can be stored and retrieved from the db. Unfortunatly, this breaks reflection since we (previously) expected a sqlite db to reflect column types that we permit in the `ischema_names` for that dialect. This patch changes the logic for 'unknown' column types during reflection to instead run through SQLite's data affinity algorithm, and assigns appropriate types from that. It also expands the matching for column type to include column types with spaces (strongly discouraged but allowed by sqlite) and also completely empty column types (in which case the NullType is assigned, which sqlite will treat as a Blob - or rather, Blob is treated as NullType). These changes mean that SQLite will never raise an error for an unknown type during reflection - there will always be some 'useful' type returned, which follows the spirit of SQLite (accomodation before sanity!).
Diffstat (limited to 'test/engine/test_reflection.py')
-rw-r--r--test/engine/test_reflection.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/test/engine/test_reflection.py b/test/engine/test_reflection.py
index 2f311f7e7..5ba3cac1b 100644
--- a/test/engine/test_reflection.py
+++ b/test/engine/test_reflection.py
@@ -4,8 +4,8 @@ import unicodedata
import sqlalchemy as sa
from sqlalchemy import schema, events, event, inspect
from sqlalchemy import MetaData, Integer, String
-from sqlalchemy.testing import ComparesTables, \
- engines, AssertsCompiledSQL, fixtures
+from sqlalchemy.testing import (ComparesTables, engines, AssertsCompiledSQL,
+ fixtures, skip)
from sqlalchemy.testing.schema import Table, Column
from sqlalchemy.testing import eq_, assert_raises, assert_raises_message
from sqlalchemy import testing
@@ -317,8 +317,14 @@ class ReflectionTest(fixtures.TestBase, ComparesTables):
t2a = Table('test2', m2, autoload=True)
assert t2a._autoincrement_column is t2a.c.id2
+ @skip('sqlite')
@testing.provide_metadata
def test_unknown_types(self):
+ """Test the handling of unknown types for the given dialect.
+
+ sqlite is skipped because it has special rules for unknown types using
+ 'affinity types' - this feature is tested in that dialect's test spec.
+ """
meta = self.metadata
t = Table("test", meta,
Column('foo', sa.DateTime))