]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
use a new ClauseElement for Over.range_ / Over.rows
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 23 Jun 2024 19:40:31 +0000 (15:40 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 24 Jun 2024 19:21:18 +0000 (15:21 -0400)
commitf522e43cc7c31d3aaffb4e126d2d06a719e0d157
tree945b3f2b18a8d5dd8cd45d4885aba2af0f0f0e40
parentda9c87306dee45e8e25fe651c0c8d3623b210fdc
use a new ClauseElement for Over.range_ / Over.rows

Enhanced the caching structure of the :paramref:`.over.rows` and
:paramref:`.over.range` so that different numerical values for the rows /
range fields are cached on the same cache key, to the extent that the
underlying SQL does not actually change (i.e. "unbounded", "current row",
negative/positive status will still change the cache key).  This prevents
the use of many different numerical range/rows value for a query that is
otherwise identical from filling up the SQL cache.

Note that the semi-private compiler method ``_format_frame_clause()``
is removed by this fix, replaced with a new method
``visit_frame_clause()``.  Third party dialects which may have referred
to this method will need to change the name and revise the approach to
rendering the correct SQL for that dialect.

This patch introduces a new ClauseElement called _FrameClause which
stores the integer range values separately and within cache-compatible
BindParameter objects from the "type" which
can be unbounded, current, preceding, or following, represented by
a _FrameClauseType enum.    The negative
sign is also stripped from the integer and represented within the
_FrameClauseType.  Tests from #11514 are adapted to include
a test for SQL Server's "literal_execute" flag taking effect so
that literal numeric values aren't stored in the cache.

Fixes: #11515
Change-Id: I8aad368ffef9f06cb5c3f8c4e971fadef029ffd5
doc/build/changelog/unreleased_21/11515.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mssql/base.py
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/testing/suite/test_select.py
test/sql/test_compare.py