diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2017-03-17 14:16:27 -0400 |
---|---|---|
committer | Gerrit Code Review <gerrit@awstats.zzzcomputing.com> | 2017-03-17 14:16:27 -0400 |
commit | d96fc5d02a921820aa5973daf66445c880ca6cd4 (patch) | |
tree | a7b3a47cca6e9a5af48dda6b3d92e3ba3f0b2418 /test | |
parent | 9974e9a46bdf6c570c650aa911b76c2dcfd9327b (diff) | |
parent | fadb8d61babb76ef7bdbc98279096a8900c7328d (diff) | |
download | sqlalchemy-d96fc5d02a921820aa5973daf66445c880ca6cd4.tar.gz |
Merge "Implement comments for tables, columns"
Diffstat (limited to 'test')
-rw-r--r-- | test/dialect/postgresql/test_reflection.py | 2 | ||||
-rw-r--r-- | test/engine/test_reflection.py | 14 | ||||
-rw-r--r-- | test/requirements.py | 4 | ||||
-rw-r--r-- | test/sql/test_ddlemit.py | 29 |
4 files changed, 47 insertions, 2 deletions
diff --git a/test/dialect/postgresql/test_reflection.py b/test/dialect/postgresql/test_reflection.py index 1d5648e57..e02c8915d 100644 --- a/test/dialect/postgresql/test_reflection.py +++ b/test/dialect/postgresql/test_reflection.py @@ -1054,7 +1054,7 @@ class CustomTypeReflectionTest(fixtures.TestBase): ]: column_info = dialect._get_column_info( 'colname', sch, None, False, - {}, {}, 'public') + {}, {}, 'public', None) assert isinstance(column_info['type'], self.CustomType) eq_(column_info['type'].arg1, args[0]) eq_(column_info['type'].arg2, args[1]) diff --git a/test/engine/test_reflection.py b/test/engine/test_reflection.py index e2a204e7b..9616c300d 100644 --- a/test/engine/test_reflection.py +++ b/test/engine/test_reflection.py @@ -1010,6 +1010,20 @@ class ReflectionTest(fixtures.TestBase, ComparesTables): assert set([t2.c.name, t2.c.id]) == set(r2.columns) assert set([t2.c.name]) == set(r3.columns) + @testing.requires.comment_reflection + @testing.provide_metadata + def test_comment_reflection(self): + m1 = self.metadata + Table('sometable', m1, + Column('id', sa.Integer, comment='c1 comment'), + comment='t1 comment') + m1.create_all() + m2 = MetaData(testing.db) + t2 = Table('sometable', m2, autoload=True) + + eq_(t2.comment, 't1 comment') + eq_(t2.c.id.comment, 'c1 comment') + @testing.requires.check_constraint_reflection @testing.provide_metadata def test_check_constraint_reflection(self): diff --git a/test/requirements.py b/test/requirements.py index 16b1305bf..ea940d168 100644 --- a/test/requirements.py +++ b/test/requirements.py @@ -106,6 +106,10 @@ class DefaultRequirements(SuiteRequirements): return only_on(['postgresql', 'mysql', 'sqlite']) @property + def comment_reflection(self): + return only_on(['postgresql', 'mysql', 'oracle']) + + @property def unbounded_varchar(self): """Target database must support VARCHAR with no length""" diff --git a/test/sql/test_ddlemit.py b/test/sql/test_ddlemit.py index e191beed3..25f9c595f 100644 --- a/test/sql/test_ddlemit.py +++ b/test/sql/test_ddlemit.py @@ -14,7 +14,9 @@ class EmitDDLTest(fixtures.TestBase): return Mock(dialect=Mock( supports_sequences=True, has_table=Mock(side_effect=has_item), - has_sequence=Mock(side_effect=has_item) + has_sequence=Mock(side_effect=has_item), + supports_comments=True, + inline_comments=False, ) ) @@ -77,6 +79,26 @@ class EmitDDLTest(fixtures.TestBase): return m, t1, t2, s1, s2 + def _table_comment_fixture(self): + m = MetaData() + + c1 = Column('id', Integer, comment='c1') + + t1 = Table( + 't1', m, c1, + comment='t1' + ) + + return m, t1, c1 + + def test_comment(self): + m, t1, c1 = self._table_comment_fixture() + + generator = self._mock_create_fixture( + False, [t1], item_exists=lambda t: t not in ("t1",)) + + self._assert_create_comment([t1, t1, c1], generator, m) + def test_create_seq_checkfirst(self): m, t1, t2, s1, s2 = self._table_seq_fixture() generator = self._mock_create_fixture( @@ -249,6 +271,11 @@ class EmitDDLTest(fixtures.TestBase): (schema.DropTable, schema.DropSequence, schema.DropConstraint), elements, generator, argument) + def _assert_create_comment(self, elements, generator, argument): + self._assert_ddl( + (schema.CreateTable, schema.SetTableComment, schema.SetColumnComment), + elements, generator, argument) + def _assert_ddl(self, ddl_cls, elements, generator, argument): generator.traverse_single(argument) for call_ in generator.connection.execute.mock_calls: |