]> 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 19:25:53 +0000 (15:25 -0400)
commitf862a4534affcac0522832583e89c209ac58290f
tree90e5d13cf2d6a5cdc7639ca9afe76e03cc35d3c5
parent5594b60d4a76e86970e95f6121e8e1d35acc417b
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
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