summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-04-23 12:34:17 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2011-04-23 12:34:17 -0400
commit3452a2ba03bcf75eeec60141f040d661e15eaa2f (patch)
tree66681f60cef20504e4f53bf0b6cc5cf27de5e83c /test
parent7ab1eb81d67a2d26f473c68b1782bf729d8d2a06 (diff)
downloadsqlalchemy-3452a2ba03bcf75eeec60141f040d661e15eaa2f.tar.gz
- Fixed bug whereby if FetchedValue was passed
to column server_onupdate, it would not have its parent "column" assigned, added test coverage for all column default assignment patterns. [ticket:2147] also in 0.6.8
Diffstat (limited to 'test')
-rw-r--r--test/sql/test_metadata.py78
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):