diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-01-10 16:20:57 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-01-10 16:20:57 -0500 |
commit | b3bc2d877e9e23b35c2ec92645d5cd055468dbd1 (patch) | |
tree | 0e29325f8efc492957f56530394186c901bc2eed /tests/test_sqlite.py | |
parent | 094fb87017517ac5e60ad0df030ec574314611f7 (diff) | |
download | alembic-b3bc2d877e9e23b35c2ec92645d5cd055468dbd1.tar.gz |
The "implicit" constraint generated by a
type such as Boolean or Enum will not generate an
ALTER statement when run on SQlite, which does not
support ALTER for the purpose of adding/removing
constraints separate from the column def itself.
While SQLite supports adding a CHECK constraint
at the column level, SQLAlchemy would need modification
to support this.
A warning is emitted indicating this
constraint cannot be added in this scenario.
#98
Diffstat (limited to 'tests/test_sqlite.py')
-rw-r--r-- | tests/test_sqlite.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/test_sqlite.py b/tests/test_sqlite.py new file mode 100644 index 0000000..8d514ee --- /dev/null +++ b/tests/test_sqlite.py @@ -0,0 +1,42 @@ +from tests import op_fixture, assert_raises_message +from alembic import op, util +from sqlalchemy import Integer, Column, ForeignKey, \ + UniqueConstraint, Table, MetaData, String,\ + func, Boolean +from sqlalchemy.sql import table, column + +def test_add_column(): + context = op_fixture('sqlite') + op.add_column('t1', Column('c1', Integer)) + context.assert_( + 'ALTER TABLE t1 ADD COLUMN c1 INTEGER' + ) + +def test_add_column_implicit_constraint(): + context = op_fixture('sqlite') + op.add_column('t1', Column('c1', Boolean)) + context.assert_( + 'ALTER TABLE t1 ADD COLUMN c1 BOOLEAN' + ) + +def test_add_explicit_constraint(): + context = op_fixture('sqlite') + assert_raises_message( + NotImplementedError, + "No support for ALTER of constraints in SQLite dialect", + op.create_check_constraint, + "foo", + "sometable", + column('name') > 5 + ) + +def test_drop_explicit_constraint(): + context = op_fixture('sqlite') + assert_raises_message( + NotImplementedError, + "No support for ALTER of constraints in SQLite dialect", + op.drop_constraint, + "foo", + "sometable", + ) + |