diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-02-12 17:47:36 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-02-12 17:47:36 -0500 |
| commit | d50ea3eabf49a8f881a4a21dbafd471bd6510ba8 (patch) | |
| tree | ba97a570a39fc81d162ec44bc0584d0cf30722b5 /test/sql/test_constraints.py | |
| parent | fdc92f0226779d608a5082e2f9009a332c142eb1 (diff) | |
| download | sqlalchemy-d50ea3eabf49a8f881a4a21dbafd471bd6510ba8.tar.gz | |
- [bug] Index will raise when arguments passed
cannot be interpreted as columns or expressions.
Will warn when Index is created
with no columns at all. [ticket:2380]
Diffstat (limited to 'test/sql/test_constraints.py')
| -rw-r--r-- | test/sql/test_constraints.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/sql/test_constraints.py b/test/sql/test_constraints.py index 79a32d44b..246878624 100644 --- a/test/sql/test_constraints.py +++ b/test/sql/test_constraints.py @@ -256,6 +256,39 @@ class ConstraintTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled Index('bar', t1.c.x) ) + def test_raise_index_nonexistent_name(self): + m = MetaData() + # the KeyError isn't ideal here, a nicer message + # perhaps + assert_raises( + KeyError, + Table, 't', m, Column('x', Integer), Index("foo", "q") + ) + + def test_raise_not_a_column(self): + assert_raises( + exc.ArgumentError, + Index, "foo", 5 + ) + + def test_warn_no_columns(self): + assert_raises_message( + exc.SAWarning, + "No column names or expressions given for Index.", + Index, "foo" + ) + + def test_raise_clauseelement_not_a_column(self): + m = MetaData() + t2 = Table('t2', m, Column('x', Integer)) + class SomeClass(object): + def __clause_element__(self): + return t2 + assert_raises( + exc.ArgumentError, + Index, "foo", SomeClass() + ) + class ConstraintCompilationTest(fixtures.TestBase, AssertsCompiledSQL): __dialect__ = 'default' |
