diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-10-03 11:12:19 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-10-03 11:12:19 -0400 |
commit | 5bb97a4b094bd6aac0a47f2c7ad268b57cd4b32d (patch) | |
tree | 4bca0fc6672cbfcf06d6a35ed3c81d24a8a7b1f0 /tests/test_op.py | |
parent | 49b41feef2ab5180a3e500c78731fade3e43b86a (diff) | |
download | alembic-5bb97a4b094bd6aac0a47f2c7ad268b57cd4b32d.tar.gz |
- Added support for use of the :class:`~sqlalchemy.sql.elements.quoted_name`
construct when using the ``schema`` argument within operations. This
allows a name containing a dot to be fully quoted, as well as to
provide configurable quoting on a per-name basis.
fixes #230
Diffstat (limited to 'tests/test_op.py')
-rw-r--r-- | tests/test_op.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/test_op.py b/tests/test_op.py index 13e58bd..5434900 100644 --- a/tests/test_op.py +++ b/tests/test_op.py @@ -49,6 +49,45 @@ class OpTest(TestBase): op.create_index, 'name', 'tname', [func.foo(column('x'))] ) + @config.requirements.sqlalchemy_09 + def test_add_column_schema_hard_quoting(self): + from sqlalchemy.sql.schema import quoted_name + context = op_fixture("postgresql") + op.add_column( + "somename", Column("colname", String), + schema=quoted_name("some.schema", quote=True)) + + context.assert_( + 'ALTER TABLE "some.schema".somename ADD COLUMN colname VARCHAR' + ) + + @config.requirements.sqlalchemy_09 + def test_rename_table_schema_hard_quoting(self): + from sqlalchemy.sql.schema import quoted_name + context = op_fixture("postgresql") + op.rename_table( + 't1', 't2', + schema=quoted_name("some.schema", quote=True)) + + context.assert_( + 'ALTER TABLE "some.schema".t1 RENAME TO t2' + ) + + @config.requirements.sqlalchemy_09 + def test_add_constraint_schema_hard_quoting(self): + from sqlalchemy.sql.schema import quoted_name + context = op_fixture("postgresql") + op.create_check_constraint( + "ck_user_name_len", + "user_table", + func.len(column('name')) > 5, + schema=quoted_name("some.schema", quote=True) + ) + context.assert_( + 'ALTER TABLE "some.schema".user_table ADD ' + 'CONSTRAINT ck_user_name_len CHECK (len(name) > 5)' + ) + def test_create_index_quoting(self): context = op_fixture("postgresql") op.create_index( |