]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Fix floordiv (//) for float/numeric by int with div_is_floordiv dialects
authorOSS Contributor <contributor@example.com>
Mon, 23 Mar 2026 14:44:40 +0000 (10:44 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 20 May 2026 18:48:27 +0000 (14:48 -0400)
commit757a53fbbf5b19dfb5e42215d2aadf2a7071c960
tree0c9ad076809dd78823dfacf59d97287a8438dfa5
parente50452cea3c2fae7bb9aed29d6533448155ea4d3
Fix floordiv (//) for float/numeric by int with div_is_floordiv dialects

Fixed issue where floor division (``//``) between a :class:`.Float` or
:class:`.Numeric` numerator and an :class:`.Integer` denominator would omit
the ``FLOOR()`` SQL wrapper on dialects where
:attr:`.Dialect.div_is_floordiv` is ``True`` (the default, including
PostgreSQL and SQLite).  ``FLOOR()`` is now applied if either the
denominator or the numerator is a non-integer, so that expressions such as
``float_col // int_col`` render as ``FLOOR(float_col / int_col)`` instead
of the incorrect ``float_col / int_col``.  Pull request courtesy r266-tech.

Fixes: #10528
Closes: #13191
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13191
Pull-request-sha: c9cbc47c877e19c91f912556b4ead6cd26e3cfe6

Change-Id: I5f9f02d966aa6ccee214a2c5cc27a73a4292da03
(cherry picked from commit a4c7dbc49e820e4eaf111b618b20d80e6b5ddc43)
doc/build/changelog/unreleased_20/10528.rst [new file with mode: 0644]
doc/build/core/operators.rst
lib/sqlalchemy/sql/compiler.py
test/sql/test_cte.py
test/sql/test_operators.py
test/sql/test_selectable.py