diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-03-14 12:00:56 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-03-14 17:01:07 -0400 |
commit | f3b6f4f8da5223fae0a1dd948d4266b2e49e317c (patch) | |
tree | 9cae69a0b1680161a5e6604371a17b5766c3dc34 /test/sql/test_compiler.py | |
parent | 596e322543df6ff380243c9cb0cf9997252329f6 (diff) | |
download | sqlalchemy-f3b6f4f8da5223fae0a1dd948d4266b2e49e317c.tar.gz |
Add "empty in" strategies; default to "static"
The longstanding behavior of the :meth:`.Operators.in_` and
:meth:`.Operators.not_in_` operators emitting a warning when
the right-hand condition is an empty sequence has been revised;
a new flag :paramref:`.create_engine.empty_in_strategy` allows an
empty "IN" expression to generate a simple boolean expression, or
to invoke the previous behavior of dis-equating the expression to
itself, with or without a warning. The default behavior is now
to emit the simple boolean expression, allowing an empty IN to
be evaulated without any performance penalty.
Change-Id: I65cc37f2d7cf65a59bf217136c42fee446929352
Fixes: #3907
Diffstat (limited to 'test/sql/test_compiler.py')
-rw-r--r-- | test/sql/test_compiler.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/test/sql/test_compiler.py b/test/sql/test_compiler.py index e65db2a36..8b19b8931 100644 --- a/test/sql/test_compiler.py +++ b/test/sql/test_compiler.py @@ -1386,7 +1386,6 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): dialect=mysql.dialect() ) - @testing.emits_warning('.*empty sequence.*') def test_render_binds_as_literal(self): """test a compiler that renders binds inline into SQL in the columns clause.""" @@ -1423,7 +1422,7 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile( select([literal("foo").in_([])]), - "SELECT 'foo' != 'foo' AS anon_1", + "SELECT 1 != 1 AS anon_1", dialect=dialect ) @@ -1440,13 +1439,16 @@ class SelectTest(fixtures.TestBase, AssertsCompiledSQL): dialect=dialect ) + empty_in_dialect = default.DefaultDialect(empty_in_strategy='dynamic') + empty_in_dialect.statement_compiler = Compiler + assert_raises_message( exc.CompileError, "Bind parameter 'foo' without a " "renderable value not allowed here.", bindparam("foo").in_( []).compile, - dialect=dialect) + dialect=empty_in_dialect) def test_literal(self): |