]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Query linter option
authorAlessio Bogon <youtux@gmail.com>
Sun, 15 Sep 2019 15:12:24 +0000 (11:12 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 22 Jan 2020 16:31:23 +0000 (11:31 -0500)
commit3809a5ecfe785cecbc9d91a8e4e4558e3839c694
treedbde348bd6673de8acc685f82884f78f6b9f8f67
parentd3ad35838ede0713d073bbbf78d1bca511806059
Query linter option

Added "from linting" as a built-in feature to the SQL compiler.  This
allows the compiler to maintain graph of all the FROM clauses in a
particular SELECT statement, linked by criteria in either the WHERE
or in JOIN clauses that link these FROM clauses together.  If any two
FROM clauses have no path between them, a warning is emitted that the
query may be producing a cartesian product.   As the Core expression
language as well as the ORM are built on an "implicit FROMs" model where
a particular FROM clause is automatically added if any part of the query
refers to it, it is easy for this to happen inadvertently and it is
hoped that the new feature helps with this issue.

The original recipe is from:
https://github.com/sqlalchemy/sqlalchemy/wiki/FromLinter

The linter is now enabled for all tests in the test suite as well.
This has necessitated that a lot of the queries be adjusted to
not include cartesian products.  Part of the rationale for the
linter to not be enabled for statement compilation only was to reduce
the need for adjustment for the many test case statements throughout
the test suite that are not real-world statements.

This gerrit is adapted from Ib5946e57c9dba6da428c4d1dee6760b3e978dda0.

Fixes: #4737
Change-Id: Ic91fd9774379f895d021c3ad564db6062299211c
Closes: #4830
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4830
Pull-request-sha: f8a21aa6262d1bcc9ff0d11a2616e41fba97a47a
25 files changed:
doc/build/changelog/migration_14.rst
doc/build/changelog/unreleased_14/4737.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mysql/base.py
lib/sqlalchemy/dialects/oracle/base.py
lib/sqlalchemy/engine/base.py
lib/sqlalchemy/engine/create.py
lib/sqlalchemy/engine/default.py
lib/sqlalchemy/sql/__init__.py
lib/sqlalchemy/sql/compiler.py
test/base/test_tutorials.py
test/orm/inheritance/test_abc_inheritance.py
test/orm/inheritance/test_assorted_poly.py
test/orm/inheritance/test_poly_persistence.py
test/orm/inheritance/test_polymorphic_rel.py
test/orm/inheritance/test_relationship.py
test/orm/inheritance/test_single.py
test/orm/test_deprecations.py
test/orm/test_eager_relations.py
test/orm/test_froms.py
test/orm/test_pickled.py
test/orm/test_query.py
test/profiles.txt
test/sql/test_defaults.py
test/sql/test_from_linter.py [new file with mode: 0644]
test/sql/test_resultset.py