]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Use non-subquery form for empty IN
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 28 Apr 2021 22:31:51 +0000 (18:31 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 29 Apr 2021 18:43:09 +0000 (14:43 -0400)
commitaba308868544b21bafa0b3435701ddc908654b0a
tree9160bdeacf66b4227e73203f7bb81a074d463927
parent5b12393e81f6b8953e9ebd46801e6943007b7a56
Use non-subquery form for empty IN

Revised the "EMPTY IN" expression to no longer rely upon using a subquery,
as this was causing some compatibility and performance problems. The new
approach for selected databases takes advantage of using a NULL-returning
IN expression combined with the usual "1 != 1" or "1 = 1" expression
appended by AND or OR. The expression is now the default for all backends
other than SQLite, which still had some compatibility issues regarding
tuple "IN" for older SQLite versions.

Third party dialects can still override how the "empty set" expression
renders by implementing a new compiler method
``def visit_empty_set_op_expr(self, type_, expand_op)``, which takes
precedence over the existing
``def visit_empty_set_expr(self, element_types)`` which remains in place.

Fixes: #6258
Fixes: #6397
Change-Id: I2df09eb00d2ad3b57039ae48128fdf94641b5e59
doc/build/changelog/unreleased_14/6258.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/sqlite/base.py
lib/sqlalchemy/sql/coercions.py
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/testing/suite/test_select.py
test/sql/test_lambdas.py