]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
add postgresql_where test
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 24 Apr 2013 14:39:25 +0000 (10:39 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 24 Apr 2013 14:39:25 +0000 (10:39 -0400)
tests/test_op.py

index e7845ee48977def62652d7db91c4951fac15dfe8..f1ab2570b727cf44c771895e81aa073b477e9e48 100644 (file)
@@ -2,7 +2,7 @@
 
 from sqlalchemy import Integer, Column, ForeignKey, \
             Table, String, Boolean
-from sqlalchemy.sql import column, func
+from sqlalchemy.sql import column, func, text
 from sqlalchemy import event
 
 from alembic import op
@@ -34,6 +34,17 @@ def test_rename_table_schema_postgresql():
     op.rename_table('t1', 't2', schema="foo")
     context.assert_("ALTER TABLE foo.t1 RENAME TO t2")
 
+def test_create_index_postgresql_where():
+    context = op_fixture("postgresql")
+    op.create_index(
+        'geocoded',
+        'locations',
+        ['coordinates'],
+        postgresql_where=text("locations.coordinates != Null"))
+    context.assert_(
+            "CREATE INDEX geocoded ON locations (coordinates) "
+            "WHERE locations.coordinates != Null")
+
 def test_add_column():
     context = op_fixture()
     op.add_column('t1', Column('c1', Integer, nullable=False))