]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
use os.urandom() for CTE, aliased anon id
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 9 Dec 2025 14:07:20 +0000 (09:07 -0500)
committerMichael Bayer <mike_mp@zzzcomputing.com>
Tue, 9 Dec 2025 15:23:29 +0000 (15:23 +0000)
commit6785a09670cfc90ef0f6977baa3d7dc26c8d1751
treef7cd9056255d608d8a57f3de6843a8739de7c798
parentf58ea194d5190859baef66c183fa0228f629830c
use os.urandom() for CTE, aliased anon id

Fixed issue where anonymous label generation for :class:`.CTE` constructs
could produce name collisions when Python's garbage collector reused memory
addresses during complex query compilation. The anonymous name generation
for :class:`.CTE` and other aliased constructs like :class:`.Alias`,
:class:`.Subquery` and others now use :func:`os.urandom` to generate unique
identifiers instead of relying on object ``id()``, ensuring uniqueness even
in cases of aggressive garbage collection and memory reuse.

Fixes: #12990
Change-Id: If56a53840684bc7d2b7637f1e154dfed1cac5f32
doc/build/changelog/unreleased_21/12990.rst [new file with mode: 0644]
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/selectable.py
test/orm/test_query.py