diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-01-21 20:10:23 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-01-21 20:10:23 -0500 |
commit | 07fb90c6cc14de6d02cf4be592c57d56831f59f7 (patch) | |
tree | 050ef65db988559c60f7aa40f2d0bfe24947e548 /test/sql/test_constraints.py | |
parent | 560fd1d5ed643a1b0f95296f3b840c1963bbe67f (diff) | |
parent | ee1f4d21037690ad996c5eacf7e1200e92f2fbaa (diff) | |
download | sqlalchemy-ticket_2501.tar.gz |
Merge branch 'master' into ticket_2501ticket_2501
Conflicts:
lib/sqlalchemy/orm/mapper.py
Diffstat (limited to 'test/sql/test_constraints.py')
-rw-r--r-- | test/sql/test_constraints.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/sql/test_constraints.py b/test/sql/test_constraints.py index b44a65190..cb4b73ec8 100644 --- a/test/sql/test_constraints.py +++ b/test/sql/test_constraints.py @@ -544,6 +544,28 @@ class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL): "FOREIGN KEY(foo_bar) REFERENCES foo (bar))" ) + def test_empty_pkc(self): + # test that an empty primary key is ignored + metadata = MetaData() + tbl = Table('test', metadata, + Column('x', Integer, autoincrement=False), + Column('y', Integer, autoincrement=False), + PrimaryKeyConstraint()) + self.assert_compile(schema.CreateTable(tbl), + "CREATE TABLE test (x INTEGER, y INTEGER)" + ) + + def test_empty_uc(self): + # test that an empty constraint is ignored + metadata = MetaData() + tbl = Table('test', metadata, + Column('x', Integer, autoincrement=False), + Column('y', Integer, autoincrement=False), + UniqueConstraint()) + self.assert_compile(schema.CreateTable(tbl), + "CREATE TABLE test (x INTEGER, y INTEGER)" + ) + def test_deferrable_column_check(self): t = Table('tbl', MetaData(), Column('a', Integer), @@ -726,6 +748,27 @@ class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL): "ALTER TABLE tbl ADD PRIMARY KEY (a)" ) + def test_render_check_constraint_sql_literal(self): + t, t2 = self._constraint_create_fixture() + + constraint = CheckConstraint(t.c.a > 5) + + self.assert_compile( + schema.AddConstraint(constraint), + "ALTER TABLE tbl ADD CHECK (a > 5)" + ) + + def test_render_index_sql_literal(self): + t, t2 = self._constraint_create_fixture() + + constraint = Index('name', t.c.a + 5) + + self.assert_compile( + schema.CreateIndex(constraint), + "CREATE INDEX name ON tbl (a + 5)" + ) + + class ConstraintAPITest(fixtures.TestBase): def test_double_fk_usage_raises(self): f = ForeignKey('b.id') |