diff options
| author | Robin Thomas <robin.thomas@livestream.com> | 2016-04-14 03:48:42 -0400 |
|---|---|---|
| committer | Robin Thomas <robin.thomas@livestream.com> | 2016-04-14 03:48:42 -0400 |
| commit | a39cea9ed443c8e11bc612af89b2716b6060868a (patch) | |
| tree | 2999d51233f4534b62d48f2a708d6ddba4f03a6f /test/dialect/postgresql/test_compiler.py | |
| parent | f43788c296206de489ecd1464af431ff7037d1d9 (diff) | |
| download | sqlalchemy-a39cea9ed443c8e11bc612af89b2716b6060868a.tar.gz | |
avoid commit cycle of .ext.ExcludeConstraint with lazy import hack.
Diffstat (limited to 'test/dialect/postgresql/test_compiler.py')
| -rw-r--r-- | test/dialect/postgresql/test_compiler.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index 0b43f0a9e..f3e21b699 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -118,6 +118,8 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): ) unique_constr = schema.UniqueConstraint(table1.c.name, name='uq_name') + excl_constr = ExcludeConstraint((table1.c.name, '='), (table1.c.description, '&&'), name='excl_thing') + excl_constr_anon = ExcludeConstraint((table1.c.name, '='), (table1.c.description, '&&')) goofy_index = Index('goofy_index', table1.c.name, postgresql_where=table1.c.name > 'm') i = insert( table1, @@ -168,6 +170,24 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): "(%(myid)s, %(name)s) ON CONFLICT (name) WHERE name > 'm' " 'DO UPDATE SET name = excluded.name', dialect=dialect) + i = insert( + table1, values=dict(name='foo'), + postgresql_on_conflict=DoUpdate(excl_constr).set_with_excluded('name') + ) + self.assert_compile(i, + 'INSERT INTO mytable (myid, name) VALUES ' + "(%(myid)s, %(name)s) ON CONFLICT ON CONSTRAINT excl_thing " + 'DO UPDATE SET name = excluded.name', + dialect=dialect) + i = insert( + table1, values=dict(name='foo'), + postgresql_on_conflict=DoUpdate(excl_constr_anon).set_with_excluded('name') + ) + self.assert_compile(i, + 'INSERT INTO mytable (myid, name) VALUES ' + "(%(myid)s, %(name)s) ON CONFLICT (name, description) " + 'DO UPDATE SET name = excluded.name', + dialect=dialect) def test_insert_returning(self): dialect = postgresql.dialect() |
