diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/sql/test_metadata.py | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index 87d8ae516..ea18229de 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -979,6 +979,84 @@ class ColumnDefinitionTest(AssertsCompiledSQL, fixtures.TestBase): getattr, select([t1.select().alias()]), 'c' ) +class ColumnDefaultsTest(fixtures.TestBase): + """test assignment of default fixures to columns""" + + def _fixture(self, *arg, **kw): + return Column('x', Integer, *arg, **kw) + + def test_server_default_positional(self): + target = schema.DefaultClause('y') + c = self._fixture(target) + assert c.server_default is target + assert target.column is c + + def test_server_default_keyword_as_schemaitem(self): + target = schema.DefaultClause('y') + c = self._fixture(server_default=target) + assert c.server_default is target + assert target.column is c + + def test_server_default_keyword_as_clause(self): + target = 'y' + c = self._fixture(server_default=target) + assert c.server_default.arg == target + assert c.server_default.column is c + + def test_server_default_onupdate_positional(self): + target = schema.DefaultClause('y', for_update=True) + c = self._fixture(target) + assert c.server_onupdate is target + assert target.column is c + + def test_server_default_onupdate_keyword_as_schemaitem(self): + target = schema.DefaultClause('y', for_update=True) + c = self._fixture(server_onupdate=target) + assert c.server_onupdate is target + assert target.column is c + + def test_server_default_onupdate_keyword_as_clause(self): + target = 'y' + c = self._fixture(server_onupdate=target) + assert c.server_onupdate.arg == target + assert c.server_onupdate.column is c + + def test_column_default_positional(self): + target = schema.ColumnDefault('y') + c = self._fixture(target) + assert c.default is target + assert target.column is c + + def test_column_default_keyword_as_schemaitem(self): + target = schema.ColumnDefault('y') + c = self._fixture(default=target) + assert c.default is target + assert target.column is c + + def test_column_default_keyword_as_clause(self): + target = 'y' + c = self._fixture(default=target) + assert c.default.arg == target + assert c.default.column is c + + def test_column_default_onupdate_positional(self): + target = schema.ColumnDefault('y', for_update=True) + c = self._fixture(target) + assert c.onupdate is target + assert target.column is c + + def test_column_default_onupdate_keyword_as_schemaitem(self): + target = schema.ColumnDefault('y', for_update=True) + c = self._fixture(onupdate=target) + assert c.onupdate is target + assert target.column is c + + def test_column_default_onupdate_keyword_as_clause(self): + target = 'y' + c = self._fixture(onupdate=target) + assert c.onupdate.arg == target + assert c.onupdate.column is c + class ColumnOptionsTest(fixtures.TestBase): def test_default_generators(self): |