]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
3 years agoMerge "reject methods as lambda SQL callables" into rel_1_4
mike bayer [Wed, 19 Jan 2022 02:41:20 +0000 (02:41 +0000)] 
Merge "reject methods as lambda SQL callables" into rel_1_4

3 years agoMerge "enhance double-aliased table logic to handle more cases" into rel_1_4
mike bayer [Wed, 19 Jan 2022 02:39:58 +0000 (02:39 +0000)] 
Merge "enhance double-aliased table logic to handle more cases" into rel_1_4

3 years agoreject methods as lambda SQL callables
Mike Bayer [Tue, 18 Jan 2022 22:19:24 +0000 (17:19 -0500)] 
reject methods as lambda SQL callables

Added an informative error message when a method object is passed to a SQL
construct. Previously, when such a callable were passed, as is a common
typographical error when dealing with method-chained SQL constructs, they
were interpreted as "lambda SQL" targets to be invoked at compilation time,
which would lead to silent failures. As this feature was not intended to be
used with methods, method objects are now rejected.

Fixes: #7032
Change-Id: If714715bd8c11557ab769ee3b1a24264b0b06acc
(cherry picked from commit e28ec27b599558b3e26ced106a972e8b4aa9e668)

3 years agoenhance double-aliased table logic to handle more cases
Mike Bayer [Sun, 16 Jan 2022 15:21:45 +0000 (10:21 -0500)] 
enhance double-aliased table logic to handle more cases

Fixed ORM regression where calling the :func:`_orm.aliased` function
against an existing :func:`_orm.aliased` construct would fail to produce
correct SQL if the existing construct were against a fixed table. The fix
allows that the original :func:`_orm.aliased` construct is disregarded if
it were only against a table that's now being replaced. It also allows for
correct behavior when constructing a :func:`_orm.aliased` without a
selectable argument against a :func:`_orm.aliased` that's against a
subuquery, to create an alias of that subquery (i.e. to change its name).

The nesting behavior of :func:`_orm.aliased` remains in place for the case
where the outer :func:`_orm.aliased` object is against a subquery which in
turn refers to the inner :func:`_orm.aliased` object. This is a relatively
new 1.4 feature that helps to suit use cases that were previously served by
the deprecated ``Query.from_self()`` method.

Fixes: #7576
Change-Id: Ia9ca606f6300e38b6040eb6fc7facfe97c8cf057
(cherry picked from commit bb11d5b7c2256861fdfe64f5cded94ce15266132)

3 years agodetect map_imperatively() called twice
Mike Bayer [Tue, 18 Jan 2022 16:02:57 +0000 (11:02 -0500)] 
detect map_imperatively() called twice

Fixed issue where calling upon :meth:`_orm.regsitry.map_imperatively` more
than once for the same class would produce an unexpected error, rather than
an informative error that the target class is already mapped. This behavior
differed from that of the :func:`_orm.mapper` function which does report an
informative message already.

For 2.0, this change also cleans up the logic that detects against
`Mapper()` or `_mapper()` being invoked directly.  1.4's backport will
take on a different format as `mapper()` is still public API in that
release.

Fixes: #7579
Change-Id: Ie74a1a2e97f8b6a81ac1942040edd8cae82f4bd8
(cherry picked from commit e6ded82eef63235d7cbfe3ab3382a48f32913640)

3 years agoMerge "fix(mypy): Placeholder vars should have fullname set." into rel_1_4
mike bayer [Sat, 15 Jan 2022 14:09:13 +0000 (14:09 +0000)] 
Merge "fix(mypy): Placeholder vars should have fullname set." into rel_1_4

3 years agofix(mypy): Placeholder vars should have fullname set.
Jaen Saul [Fri, 19 Nov 2021 20:12:44 +0000 (22:12 +0200)] 
fix(mypy): Placeholder vars should have fullname set.

Otherwise the dmypy daemon will crash on an incremental re-run.

Fixes: #7347
Closes: #7348
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7348
Pull-request-sha: 79eefa3417e09a8f9defaeafdb9f76d323385238

Change-Id: Id2133e837ee5dcf43461af51458e296353bdad6c
(cherry picked from commit 7c170ade108b907c4ea6c7a73cc606afd1838885)

3 years agoFixes(#7561) Add support for postgres.UUID literal_binds compilation
José Duarte [Thu, 13 Jan 2022 22:20:06 +0000 (17:20 -0500)] 
Fixes(#7561) Add support for postgres.UUID literal_binds compilation

Added string rendering to the :class:`.postgresql.UUID` datatype, so that
stringifying a statement with "literal_binds" that uses this type will
render an appropriate string value for the PostgreSQL backend. Pull request
courtesy José Duarte.

Fixes: #7561
Closes: #7563
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7563
Pull-request-sha: cf6fe73265342d7884a940c4b3a34c9552113ec3

Change-Id: I4b162bdcdce2293a90683e36da54e4a891a3c684
(cherry picked from commit 17d228f6268515bbf37fdd70a6ee3a62cb9a0b0c)

3 years agoRemove pymysql in asyncmy
long2ice [Fri, 14 Jan 2022 08:50:26 +0000 (03:50 -0500)] 
Remove pymysql in asyncmy

Removed unnecessary dependency on PyMySQL from the asyncmy dialect. Pull
request courtesy long2ice.

Fixes: #7567
Closes: #7568
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7568
Pull-request-sha: 48cbb3e3c249e431dfd91e88fcb3284af83671e5

Change-Id: Iad5048eaa5de6ad6666b2120df6608fd1bf50e02
(cherry picked from commit b4fe2b83ab3ce8cee1e2f4353dfcbea515b4f8d1)

3 years agoMerge "implement second-level type resolution for literals" into rel_1_4
mike bayer [Tue, 11 Jan 2022 18:11:43 +0000 (18:11 +0000)] 
Merge "implement second-level type resolution for literals" into rel_1_4

3 years agoimplement second-level type resolution for literals
Mike Bayer [Wed, 5 Jan 2022 17:20:46 +0000 (12:20 -0500)] 
implement second-level type resolution for literals

Added additional rule to the system that determines ``TypeEngine``
implementations from Python literals to apply a second level of adjustment
to the type, so that a Python datetime with or without tzinfo can set the
``timezone=True`` parameter on the returned :class:`.DateTime` object, as
well as :class:`.Time`. This helps with some round-trip scenarios on
type-sensitive PostgreSQL dialects such as asyncpg, psycopg3 (2.0 only).

Improved support for asyncpg handling of TIME WITH TIMEZONE, which
was not fully implemented.

Fixes: #7537
Change-Id: Icdb07db85af5f7f39f1c1ef855fe27609770094b
(cherry picked from commit 3b2e28bcb5ba32446a92b62b6862b7c11dabb592)

3 years agoensure with_options not switched to a list
Mike Bayer [Mon, 10 Jan 2022 19:59:59 +0000 (14:59 -0500)] 
ensure with_options not switched to a list

Fixed regression which appeared in 1.4.23 which could cause loader options
to be mis-handled in some cases, in particular when using joined table
inheritance in combination with the ``polymorphic_load="selectin"`` option
as well as relationship lazy loading, leading to a ``TypeError``.

Fixes: #7557
Change-Id: Id38619692f94308fd5f567a02337efef7a3a7544
(cherry picked from commit 4e9fe6e3b7a72fc3b116403ea9b27e847b5bf186)

3 years agohappy new year 2022
Mike Bayer [Thu, 6 Jan 2022 20:59:47 +0000 (15:59 -0500)] 
happy new year 2022

Change-Id: Ic38dbc640aa0fe8a784a5b5e57c45a41eb0ea01b

3 years agofix incorrect with_parent() example
Mike Bayer [Thu, 6 Jan 2022 14:24:08 +0000 (09:24 -0500)] 
fix incorrect with_parent() example

The lead example for the with_parent() function
docstring was backwards, based on the standard User/Address
mapping used in the documentation.

Fixes: #7540
Change-Id: Iaff7dc6fdd0c323509231ae5f3122ed76a420915
(cherry picked from commit 21ee595ba9ef3e7abc8982fac7bf488c904cf9c9)

3 years agoupdate stale documentation on Mapper class
Mike Bayer [Tue, 4 Jan 2022 20:38:15 +0000 (15:38 -0500)] 
update stale documentation on Mapper class

don't get into details here that have changed,
point to the main narrative documentation instead.

Change-Id: I5bc0829f6ff282ca104f18deb9ec9857b6e1c8ac
(cherry picked from commit 9298ce03e1181d5bc00c1891663433606ead1223)

3 years agoMerge "Imrpove MySQL/MariaDB dialect initialization." into rel_1_4
Federico Caselli [Tue, 4 Jan 2022 20:30:11 +0000 (20:30 +0000)] 
Merge "Imrpove MySQL/MariaDB dialect initialization." into rel_1_4

3 years agoMerge "Improve array of enum handling." into rel_1_4
Federico Caselli [Tue, 4 Jan 2022 20:28:50 +0000 (20:28 +0000)] 
Merge "Improve array of enum handling." into rel_1_4

3 years agoMerge "ensure correlate_except is checked for empty tuple" into rel_1_4
mike bayer [Tue, 4 Jan 2022 19:36:39 +0000 (19:36 +0000)] 
Merge "ensure correlate_except is checked for empty tuple" into rel_1_4

3 years agoImprove array of enum handling.
Federico Caselli [Fri, 10 Dec 2021 13:18:34 +0000 (14:18 +0100)] 
Improve array of enum handling.

Fixed handling of array of enum values which require escape characters.

Fixes: #7418
Change-Id: I50525846f6029dfea9a8ad1cb913424d168d5f62
(cherry picked from commit 94afc4f5fc842160468cf7175552125eebf7a510)

3 years agoimprove custom operator for SQL types docs
Mike Bayer [Tue, 4 Jan 2022 19:08:10 +0000 (14:08 -0500)] 
improve custom operator for SQL types docs

introduce here that "custom ops" first come from
the .op() method in the usual case.  then only if one wants
such an op to be pre-assocaited with particular types,
then the comparator may be used.  Also clarify the individual
points regarding the comparator.

Change-Id: Id6046448eb2c17fa6e3f2ef6d9343b156ddec96f
(cherry picked from commit 680264970a4c9199c6e1dc91f855bdb08a90b4cc)

3 years agoensure correlate_except is checked for empty tuple
Mike Bayer [Mon, 3 Jan 2022 22:28:52 +0000 (17:28 -0500)] 
ensure correlate_except is checked for empty tuple

Fixed issue where :meth:`_sql.Select.correlate_except` method, when passed
either the ``None`` value or no arguments, would not correlate any elements
when used in an ORM context (that is, passing ORM entities as FROM
clauses), rather than causing all FROM elements to be considered as
"correlated" in the same way which occurs when using Core-only constructs.

Fixes: #7514
Change-Id: Ic4a5252c8f3c1140aba6c308264948f3a91f33f5
(cherry picked from commit 709239f4a61e88c2051dce87eb4058efd653697e)

3 years agoImrpove MySQL/MariaDB dialect initialization.
Federico Caselli [Thu, 30 Dec 2021 22:29:55 +0000 (23:29 +0100)] 
Imrpove MySQL/MariaDB dialect initialization.

Replace ``SHOW VARIABLES LIKE`` statement with equivalent
``SELECT @@variable`` in MySQL and MariaDB dialect initialization.
This should avoid mutex contention caused by ``SHOW VARIABLES``,
improving initialization performance.

Change-Id: Id836ef534fcc1473c7aaf9270d08a4da9b8f62cf
closes: #7518
(cherry picked from commit 5e06f0f579df45116696fed78d65abcccc1dc3e3)

3 years agoReflect included columns as dialect_options
Gord Thompson [Mon, 20 Dec 2021 21:37:13 +0000 (14:37 -0700)] 
Reflect included columns as dialect_options

Fixed reflection of covering indexes to report ``include_columns`` as part
of the ``dialect_options`` entry in the reflected index dictionary, thereby
enabling round trips from reflection->create to be complete. Included
columns continue to also be present under the ``include_columns`` key for
backwards compatibility.

Fixes: #7382
Change-Id: I4f16b65caed3a36d405481690a3a92432b5efd62
(cherry picked from commit 52e352a190af750c3c28a5390b2ad55b20d1b752)

3 years agoMerge "include empty intermediary tables in optimized get" into rel_1_4
mike bayer [Mon, 27 Dec 2021 16:49:59 +0000 (16:49 +0000)] 
Merge "include empty intermediary tables in optimized get" into rel_1_4

3 years agoinclude empty intermediary tables in optimized get
Mike Bayer [Sun, 26 Dec 2021 17:13:19 +0000 (12:13 -0500)] 
include empty intermediary tables in optimized get

Fixed issue in joined-inheritance load of additional attributes
functionality in deep multi-level inheritance where an intermediary table
that contained no columns would not be included in the tables joined,
instead linking those tables to their primary key identifiers. While this
works fine, it nonetheless in 1.4 began producing the cartesian product
compiler warning. The logic has been changed so that these intermediary
tables are included regardless. While this does include additional tables
in the query that are not technically necessary, this only occurs for the
highly unusual case of deep 3+ level inheritance with intermediary tables
that have no non primary key columns, potential performance impact is
therefore expected to be negligible.

Fixes: #7507
Change-Id: Id2073773e97a0853b744b51feeb2bc4437032e51
(cherry picked from commit c1d2fbac4c399b47f4715f7ea2a1147374d2aa43)

3 years agorestore graceful degrade of subqueryload w from_statement
Mike Bayer [Sun, 26 Dec 2021 16:25:00 +0000 (11:25 -0500)] 
restore graceful degrade of subqueryload w from_statement

Fixed regression from 1.3 where the "subqueryload" loader strategy would
fail with a stack trace if used against a query that made use of
:meth:`_orm.Query.from_statement` or :meth:`_sql.Select.from_statement`. As
subqueryload requires modifying the original statement, it's not compatible
with the "from_statement" use case, especially for statements made against
the :func:`_sql.text` construct. The behavior now is equivalent to that of
1.3 and previously, which is that the loader strategy silently degrades to
not be used for such statements, typically falling back to using the
lazyload strategy.

Fixes: #7505
Change-Id: I950800dc86a77f8320a5e696edce1ff2c84b1eb9
(cherry picked from commit 818d62be00530549aa52dd5d981819010e4ae484)

3 years agoVersion 1.4.30 placeholder
Mike Bayer [Thu, 23 Dec 2021 02:19:30 +0000 (21:19 -0500)] 
Version 1.4.30 placeholder

3 years ago- 1.4.29 rel_1_4_29
Mike Bayer [Thu, 23 Dec 2021 02:08:12 +0000 (21:08 -0500)] 
- 1.4.29

3 years agoadd mariadb conf section
Mike Bayer [Thu, 23 Dec 2021 02:07:33 +0000 (21:07 -0500)] 
add mariadb conf section

Change-Id: I7686ab7a877895de33e9ca19217ae38cb5729238
(cherry picked from commit f37931d50c21c412418fbd19d4676042fb5292a9)

3 years agoMerge "add recursion check for with_loader_criteria() option" into rel_1_4
mike bayer [Thu, 23 Dec 2021 00:38:55 +0000 (00:38 +0000)] 
Merge "add recursion check for with_loader_criteria() option" into rel_1_4

3 years agoMerge "Fix missing class attributes when using __class_getitem__" into rel_1_4
mike bayer [Thu, 23 Dec 2021 00:36:56 +0000 (00:36 +0000)] 
Merge "Fix missing class attributes when using __class_getitem__" into rel_1_4

3 years agoFix missing class attributes when using __class_getitem__
Kai Mueller [Tue, 21 Dec 2021 20:00:30 +0000 (15:00 -0500)] 
Fix missing class attributes when using __class_getitem__

Fixed issue where the ``__class_getitem__()`` method of the generated
declarative base class by :func:`_orm.as_declarative` would lead to
inaccessible class attributes such as ``__table__``, for cases where a
``Generic[T]`` style typing declaration were used in the class hierarchy.
This is in continuation from the basic addition of ``__class_getitem__()``
in :ticket:`7368`. Pull request courtesy Kai Mueller.

Fixes: #7462
Closes: #7470
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7470
Pull-request-sha: d5e5765e0e5542149f116ed9ccff1b3e2e32dee5

Change-Id: I6418af6d34532ff181343884bd419d9c2684e617
(cherry picked from commit 3088df9820bd62b3edff15d39a7635e86d265300)

3 years agoadd recursion check for with_loader_criteria() option
Mike Bayer [Wed, 22 Dec 2021 20:33:11 +0000 (15:33 -0500)] 
add recursion check for with_loader_criteria() option

Fixed recursion overflow which could occur within ORM statement compilation
when using either the :func:`_orm.with_loader_criteria` feature or the the
:meth:`_orm.PropComparator.and_` method within a loader strategy in
conjunction with a subquery which referred to the same entity being altered
by the criteria option, or loaded by the loader strategy.  A check for
coming across the same loader criteria option in a recursive fashion has
been added to accommodate for this scenario.

Fixes: #7491
Change-Id: I8701332717c45a21948ea4788a3058c0fbbf03a7
(cherry picked from commit c66c6d1aeff92f838740b7745a9c2a47852949d6)

3 years agouse fully qualified, locatable names for all use of api.named_type()
Mike Bayer [Wed, 22 Dec 2021 21:21:33 +0000 (16:21 -0500)] 
use fully qualified, locatable names for all use of api.named_type()

Fixed mypy regression where the release of mypy 0.930 added additional
internal checks to the format of "named types", requiring that they be
fully qualified and locatable. This broke the mypy plugin for SQLAlchemy,
raising an assertion error, as there was use of symbols such as
``__builtins__`` and other un-locatable or unqualified names that
previously had not raised any assertions.

Fixes: #7496
Change-Id: I037680606a1d51158ef6503508ec76c5d5adc946
(cherry picked from commit aded8b11d9eccbd1f2b645a94338e34a3d234bc9)

3 years agoaccommodate for "clone" of ColumnClause
Mike Bayer [Tue, 21 Dec 2021 23:08:33 +0000 (18:08 -0500)] 
accommodate for "clone" of ColumnClause

for use with the ClauseElement.params() method,
altered ColumnClause._clone() so that while the element
stays immutable, if the column is associated with a subquery,
it returns a new version of itself as corresponding to a
clone of the subquery.  this allows processing functions
to access the parameters in the subquery and produce a
copy of it.  The use case here is the expanded use of
.params() within loader strategies that use
HasCacheKey._apply_params_to_element().

Fixed issue in new "loader criteria" method
:meth:`_orm.PropComparator.and_` where usage with a loader strategy like
:func:`_orm.selectinload` against a column that was a member of the ``.c.``
collection of a subquery object, where the subquery would be dynamically
added to the FROM clause of the statement, would be subject to stale
parameter values within the subquery in the SQL statement cache, as the
process used by the loader strategy to replace the parameters at execution
time would fail to accommodate the subquery when received in this form.

Fixes: #7489
Change-Id: Ibb3b6af140b8a62a2c8d05b2ac92e86ca3013c46
(cherry picked from commit 267e9cbf6e3c165a4e953b49d979d7f4ddc533f9)

3 years agoinclude InterfaceError for mariadb disconnect check
Mike Bayer [Tue, 14 Dec 2021 21:46:50 +0000 (16:46 -0500)] 
include InterfaceError for mariadb disconnect check

Corrected the error classes inspected for the "is_disconnect" check for the
``mariadbconnector`` dialect, which was failing for disconnects that
occurred due to common MySQL/MariaDB error codes such as 2006; the DBAPI
appears to currently use the ``mariadb.InterfaceError`` exception class for
disconnect errors such as error code 2006, which has been added to the list
of classes checked.

For the current "real reconnect test", shutting down the mariadb
connection from the client side produces
ProgrammingError("Connection isn't valid anymore") which we also
continue to intercept.

Fixes: #7457
Change-Id: I0b37cd7a73359a23ad756ff2af0a9333c841221b
(cherry picked from commit 3a33fa8b0acd9220ef4428ac6a56ebd8d40c3762)

3 years agoIgnore ephemeral classes in test_all_present()
Nils Philippsen [Sun, 12 Dec 2021 23:35:03 +0000 (18:35 -0500)] 
Ignore ephemeral classes in test_all_present()

Fixed a regression in the test suite where the test called
``CompareAndCopyTest::test_all_present`` would fail on some platforms due
to additional testing artifacts being detected. Pull request courtesy Nils
Philippsen.

In some circumstances, ephemeral class objects that are created within
the scope of a test method don't seem to be garbage collected directly
on exit. Filter out classes created in test modules.

Fixes: #7450
Closes: #7451
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7451
Pull-request-sha: 135a8aaba2c6941460c7f45aa1a55c8f6b9eb43d

Change-Id: I621967bd916089dc1e3f98625fd2a852cd9fd712
(cherry picked from commit 4291e3c235569031948ebaacec4dde8776255e0e)

3 years agoMerge "implement correct errors for Row immutability" into rel_1_4
mike bayer [Sun, 12 Dec 2021 23:29:27 +0000 (23:29 +0000)] 
Merge "implement correct errors for Row immutability" into rel_1_4

3 years agoMerge "check for string_types, not str, for py2 support" into rel_1_4
mike bayer [Sun, 12 Dec 2021 20:18:38 +0000 (20:18 +0000)] 
Merge "check for string_types, not str, for py2 support" into rel_1_4

3 years agouse the options from the cached statement for propagate_options
Mike Bayer [Sun, 12 Dec 2021 18:37:21 +0000 (13:37 -0500)] 
use the options from the cached statement for propagate_options

Fixed caching-related issue where the use of a loader option of the form
``lazyload(aliased(A).bs).joinedload(B.cs)`` would fail to result in the
joinedload being invoked for runs subsequent to the query being cached, due
to a mismatch for the options / object path applied to the objects loaded
for a query with a lead entity that used ``aliased()``.

Fixes: #7447
Change-Id: I4e9c34654b7d3668cd8878decbd688afe2af5f81
(cherry picked from commit 04421c8bed9e93a625b7164e99eb1ee0395bebfe)

3 years agocheck for string_types, not str, for py2 support
Mike Bayer [Sun, 12 Dec 2021 16:23:07 +0000 (11:23 -0500)] 
check for string_types, not str, for py2 support

Fixed regression in the :func:`_engine.make_url` function used to parse URL
strings where the query string parsing would go into a recursion overflow
if a Python 2 ``u''`` string were used.

Fixes: #7446
Change-Id: I081275673e6240a52f71da7dfaaf04e6fe32cf48

3 years agoFix referenced ticket number (#7439)
Nils Philippsen [Sat, 11 Dec 2021 16:24:22 +0000 (17:24 +0100)] 
Fix referenced ticket number (#7439)

Signed-off-by: Nils Philippsen <nils@tiptoe.de>
3 years agoMerge "Add execution options to ``Session.get``" into rel_1_4
Federico Caselli [Sat, 11 Dec 2021 08:09:32 +0000 (08:09 +0000)] 
Merge "Add execution options to ``Session.get``" into rel_1_4

3 years agoMerge "Add async_engine_from_config()" into rel_1_4
Federico Caselli [Sat, 11 Dec 2021 08:07:28 +0000 (08:07 +0000)] 
Merge "Add async_engine_from_config()" into rel_1_4

3 years agoAdd ``scalars`` to Migration - ORM Usage table.
Federico Caselli [Thu, 9 Dec 2021 21:41:47 +0000 (22:41 +0100)] 
Add ``scalars`` to Migration - ORM Usage table.

Fixes #7407

Change-Id: I0ec7c0dd44dce3b907296824ee4e6103bc72a6dd
(cherry picked from commit d692b11608f540e4d4df8f4127ee52a476e0e5e4)

3 years agoAdd async_engine_from_config()
Nils Philippsen [Sat, 13 Nov 2021 16:11:32 +0000 (11:11 -0500)] 
Add async_engine_from_config()

Added :func:`_asyncio.async_engine_config` function to create
an async engine from a configuration dict.  This otherwise
behaves the same as :func:`_sa.engine_from_config`.

Fixes: #7301
Closes: #7302
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7302
Pull-request-sha: c7c758833b6c37b7509b8c5bed4f26ac0ccc0395

Change-Id: I64feadf95b5015c24fe0fa0dbae6755b72d1713e
(cherry picked from commit 98b1650efce79ae6d304eb08047890ef8ae89df1)

3 years agoAdd execution options to ``Session.get``
Federico Caselli [Thu, 9 Dec 2021 21:11:37 +0000 (22:11 +0100)] 
Add execution options to ``Session.get``

Fixes: #7410
Change-Id: Iab6427b8b4c2ada8c31ef69f92d27c1185dbb6b1
(cherry picked from commit ec1fee363e7d538a2239818cfb1e341eddddcf36)

3 years agoMerge branch 'postgresql-docs-update-table-numbers_1_4' into rel_1_4
Federico Caselli [Fri, 10 Dec 2021 13:28:36 +0000 (14:28 +0100)] 
Merge branch 'postgresql-docs-update-table-numbers_1_4' into rel_1_4

Change-Id: I0856b0dfff3116b4e9685bc8f7dec60c4ac31b42

3 years agoUpdate references to tables in PostgreSQL documentation
Leo Singer [Fri, 8 Oct 2021 02:07:08 +0000 (22:07 -0400)] 
Update references to tables in PostgreSQL documentation

Since the table numbers change from one version of PostgreSQL to
the next, refer to the tables by name rather than by number.

(cherry picked from commit 786bc099743285ca4af3786d8f54cd59ce7a7c81)

3 years agoInclude import error message when greenlet is not installed
Federico Caselli [Thu, 9 Dec 2021 20:47:22 +0000 (21:47 +0100)] 
Include import error message when greenlet is not installed

Fixes: #7419
Change-Id: I0c604875a80287acff3bab732f67601a5e2db98c
(cherry picked from commit 533f5718904b620be8d63f2474229945d6f8ba5d)

3 years agoVersion 1.4.29 placeholder
Mike Bayer [Thu, 9 Dec 2021 19:50:36 +0000 (14:50 -0500)] 
Version 1.4.29 placeholder

3 years ago- 1.4.28 rel_1_4_28
Mike Bayer [Thu, 9 Dec 2021 19:35:43 +0000 (14:35 -0500)] 
- 1.4.28

3 years agoMerge branch 'typos-fixes_1_4' into rel_1_4
Federico Caselli [Thu, 9 Dec 2021 19:27:19 +0000 (20:27 +0100)] 
Merge branch 'typos-fixes_1_4' into rel_1_4

Change-Id: I6d53b7e7b9538cc8bea9ab5af4b0fa383f52d7cf

3 years agoFix typo in changelog
Lele Gaifax [Thu, 9 Dec 2021 07:13:42 +0000 (08:13 +0100)] 
Fix typo in changelog

3 years agoFix typo in docstring
Lele Gaifax [Thu, 9 Dec 2021 07:14:06 +0000 (08:14 +0100)] 
Fix typo in docstring

(cherry picked from commit 9fd1bb4e8bf8a21f8c20b4390a9e7d579556ffc0)

3 years agoimplement correct errors for Row immutability
Mike Bayer [Thu, 9 Dec 2021 19:23:42 +0000 (14:23 -0500)] 
implement correct errors for Row immutability

Corrected the error message for the ``AttributeError`` that's raised when
attempting to write to an attribute on the :class:`_result.Row` class,
which is immutable. The previous message claimed the column didn't exist
which is misleading.

Fixes: #7432
Change-Id: If0e2cbd3f763dca6c99a18aa42252c69f1207d59
(cherry picked from commit f113e979219e20a22044c4b262e4531ba9993b8a)

3 years agoimplement attributes.Proxy._clone()
Mike Bayer [Thu, 9 Dec 2021 17:51:43 +0000 (12:51 -0500)] 
implement attributes.Proxy._clone()

Fixed issue where the internal cloning used by the
:meth:`_orm.PropComparator.any` method on a :func:`_orm.relationship` in
the case where the related class also makes use of ORM polymorphic loading,
would fail if a hybrid property on the related, polymorphic class were used
within the criteria for the ``any()`` operation.

Fixes: #7425
Change-Id: I5f4f4ec5fab17df228bc6e3de412d24114b20600
(cherry picked from commit 546391e5a80f647e7ad78ef93f832f10278a8867)

3 years agochangelog updates
Mike Bayer [Thu, 9 Dec 2021 17:36:25 +0000 (12:36 -0500)] 
changelog updates

Change-Id: Ie136cfb7375e68b2badba1099b5b041f99da85fa
(cherry picked from commit af50c8064d668ba33ef2399a288fd1594b1b5602)

3 years agoMerge "Warn when caching is disabled / document" into rel_1_4
mike bayer [Tue, 7 Dec 2021 15:47:12 +0000 (15:47 +0000)] 
Merge "Warn when caching is disabled / document" into rel_1_4

3 years agoMerge "contextmanager skips rollback if trans says to skip it" into rel_1_4
mike bayer [Tue, 7 Dec 2021 14:53:38 +0000 (14:53 +0000)] 
Merge "contextmanager skips rollback if trans says to skip it" into rel_1_4

3 years agoWarn when caching is disabled / document
Mike Bayer [Fri, 3 Dec 2021 19:04:05 +0000 (14:04 -0500)] 
Warn when caching is disabled / document

This patch adds new warnings for all elements that
don't indicate their caching behavior, including user-defined
ClauseElement subclasses and third party dialects.
it additionally adds new documentation to discuss an apparent
performance degradation in 1.4 when caching is disabled as a
result in the significant expense incurred by ORM
lazy loaders, which in 1.3 used BakedQuery so were actually
cached.

As a result of adding the warnings, a fair degree of
lesser used SQL expression objects identified that they did not
define caching behavior so would have been producing
``[no key]``, including PostgreSQL constructs ``hstore``
and ``array``.  These have been amended to use inherit
cache where appropriate.  "on conflict" constructs in
PostgreSQL, MySQL, SQLite still explicitly don't generate
a cache key at this time.

The change also adds a test for all constructs via
assert_compile() to assert they will not generate cache
warnings.

Fixes: #7394
Change-Id: I85958affbb99bfad0f5efa21bc8f2a95e7e46981
(cherry picked from commit 22deafe15289d2be55682e1632016004b02b62c0)

3 years agoAdd __copy__, __deepcopy__ to URL. Fixes: #7400
Tom Ritchford [Sun, 5 Dec 2021 18:27:45 +0000 (13:27 -0500)] 
Add __copy__, __deepcopy__ to URL. Fixes: #7400

Added support for ``copy()`` and ``deepcopy()`` to the :class:`_url.URL`
class. Pull request courtesy Tom Ritchford.

Fixes: #7400
Closes: #7401
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7401
Pull-request-sha: a2c1b8992f5d153c6210178cda47b8ae96b91fb5

Change-Id: I55977338b2655a7d4f733ae786d31e589185e9ca
(cherry picked from commit 924cc31975f8874d369db6599575e361bdb34be9)

3 years agocontextmanager skips rollback if trans says to skip it
Mike Bayer [Thu, 2 Dec 2021 00:27:25 +0000 (19:27 -0500)] 
contextmanager skips rollback if trans says to skip it

Fixed issue where if an exception occurred when the :class:`_orm.Session`
were to close the connection within the :meth:`_orm.Session.commit` method,
when using a context manager for :meth:`_orm.Session.begin` , it would
attempt a rollback which would not be possible as the :class:`_orm.Session`
was in between where the transaction is committed and the connection is
then to be returned to the pool, raising the exception "this
sessiontransaction is in the committed state". This exception can occur
mostly in an asyncio context where CancelledError can be raised.

Fixes: #7388
Change-Id: I1a85a3a7eae79f3553ddf1e3d245a0d90b0a2f40
(cherry picked from commit a845da8b0fc5bb172e278c399a1de9a2e49d62af)

3 years agoqualify the stringification warning
Mike Bayer [Mon, 6 Dec 2021 17:41:36 +0000 (12:41 -0500)] 
qualify the stringification warning

the recipe which uses render_postcompile itself is
not insecure as it still renders bound parameters
and does not stringify any literal values.

Change-Id: Ib5ac2f7ce37dc1415a67b117a9c31c0ee37270b3
(cherry picked from commit 973b6ccbf1f81d2357d310ed44717fe37df96ac6)

3 years agofix typo in exists documentation
Federico Caselli [Sun, 5 Dec 2021 21:14:51 +0000 (22:14 +0100)] 
fix typo in exists documentation

Change-Id: I71773e32ae69bad10642f2f3c7b73a80045e7b8b

3 years agoThe where method of exists now accepts multiple cluase.
Federico Caselli [Sat, 4 Dec 2021 22:08:05 +0000 (23:08 +0100)] 
The where method of exists now accepts multiple cluase.

Support multiple clause elements in the :meth:`_sql.Exists.where` method,
unifying the api with the on presented by a normal :func:`_sql.select`
construct.

Fixes: #7386
Change-Id: I5df20478008cd5167053d357cbfad8a641c62b44
(cherry picked from commit b2bc0c8e4138ccef4834a415f7be9012e1c6286e)

3 years agoMerge "copy list for __iadd__" into rel_1_4
mike bayer [Fri, 3 Dec 2021 15:34:31 +0000 (15:34 +0000)] 
Merge "copy list for __iadd__" into rel_1_4

3 years agoblock class_getitem test for python 3.6
Mike Bayer [Thu, 2 Dec 2021 21:07:51 +0000 (16:07 -0500)] 
block class_getitem test for python 3.6

This commit in 3d4e64b8ef6 wont work on python 3.6.

Change-Id: I8e39268914ee972247e6cf54f6c07366e0033133

3 years agocopy list for __iadd__
Mike Bayer [Thu, 2 Dec 2021 02:39:59 +0000 (21:39 -0500)] 
copy list for __iadd__

Fixed issue where a list mapped with :func:`_orm.relationship` would go
into an endless loop if in-place added to itself, i.e. the ``+=`` operator
were used, as well as if ``.extend()`` were given the same list.

Fixes: #7389
Change-Id: Idd5118420f8bc684d1ee36b2b6d4c5812f36cc4c
(cherry picked from commit 9fc17513fe69a1fd26fc522f9862af3e0ebfd2c4)

3 years agoAdd __class_getitem__ to the declarative Base class
Kai Mueller [Wed, 1 Dec 2021 15:58:40 +0000 (10:58 -0500)] 
Add __class_getitem__ to the declarative Base class

Fixed issue where the :func:`_orm.as_declarative` decorator and similar
functions used to generate the declarative base class would not copy the
``__class_getitem__()`` method from a given superclass, which prevented the
use of pep-484 generics in conjunction with the ``Base`` class. Pull
request courtesy Kai Mueller.

Fixes: #7368
Closes: #7381
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7381
Pull-request-sha: 7db7fd869a6bb617f767fad5b71ddf7cb5f14ff5

Change-Id: I495718c3082ad6dd2c83fdbf6feba7c529e351cb
(cherry picked from commit 20fe2a3dc2597b04338e8907883c6f4ea72518c8)

3 years agoMerge "Fixes: #4390" into rel_1_4
mike bayer [Tue, 30 Nov 2021 15:54:57 +0000 (15:54 +0000)] 
Merge "Fixes: #4390" into rel_1_4

3 years agoMerge "document get_bind() overrides for async session" into rel_1_4
mike bayer [Tue, 30 Nov 2021 15:49:06 +0000 (15:49 +0000)] 
Merge "document get_bind() overrides for async session" into rel_1_4

3 years agoscoped_session adjustments
Mike Bayer [Tue, 30 Nov 2021 14:06:29 +0000 (09:06 -0500)] 
scoped_session adjustments

* fix typo, change to a note the async scoped session note
* more dragons re: threading.local()

Change-Id: I76266507510e4014456d992656f4aadf6d03ba4a
(cherry picked from commit 912bdcc8075c640a4f3d9e0194f57b5bdcfc6f2b)

3 years agodocument get_bind() overrides for async session
Mike Bayer [Mon, 29 Nov 2021 22:00:21 +0000 (17:00 -0500)] 
document get_bind() overrides for async session

Change-Id: Ifcc936a5861d49857d1f365416190cfbd0981aac
References: #7383
(cherry picked from commit 250725ab7bbeafbed650f8ecb286ffad01078801)

3 years agoadapt pytest plugin to support pytest v7
Federico Caselli [Sat, 27 Nov 2021 08:53:29 +0000 (09:53 +0100)] 
adapt pytest plugin to support pytest v7

Implemented support for the test suite to run correctly under Pytest 7.
Previously, only Pytest 6.x was supported for Python 3, however the version
was not pinned on the upper bound in tox.ini. Pytest is not pinned in
tox.ini to be lower than version 8 so that SQLAlchemy versions released
with the current codebase will be able to be tested under tox without
changes to the environment.   Much thanks to the Pytest developers for
their help with this issue.

Change-Id: I3b12166199be2b913ee16e78b3ebbff415654396
(cherry picked from commit 7f84297c9947ff8d52b091aedb2a46035791763c)

3 years agoupdate migration strategy for dynamic loaders
Mike Bayer [Sat, 27 Nov 2021 19:29:00 +0000 (14:29 -0500)] 
update migration strategy for dynamic loaders

discuss the two current ways for this use case that
use 2.0 style querying and introduce that a newer API
is likely on the way.

Also repair autofunctions for with_parent for 2.0 only.

References: #7123
References: #7372

Change-Id: I2ff6cfd780540ee4ee887b61137af7afa1327a9f
(cherry picked from commit 29c5fba9ad89e53180f0bd2a026742321093105f)

3 years agofix execution options docs local to 1.4
Mike Bayer [Thu, 25 Nov 2021 00:47:57 +0000 (19:47 -0500)] 
fix execution options docs local to 1.4

the cherry-pick in c37ef701638e27863a7af768ba8
went in cleanly but failed to accommodate that
the spacing here was still wrong in a different way.

Change-Id: Ife87fb01aec3eae2ae9635e6951330279f29471b

3 years agoImprove ``ORMExecuteState`` documentation
Federico Caselli [Wed, 24 Nov 2021 14:11:04 +0000 (15:11 +0100)] 
Improve ``ORMExecuteState`` documentation

(cherry picked from commit 7c3d3670c68298e88d03bc8f02e01c6a3f7fe42f)

3 years agofix year
Mike Bayer [Sun, 21 Nov 2021 16:50:27 +0000 (11:50 -0500)] 
fix year

Change-Id: I56a325fde167501a53b588cc1b69255238ac1dbb
(cherry picked from commit 3085f28be58bf4e4a0318b932f1422c49e1af2f1)

3 years agoMerge "favor setuptools imports over distutils" into rel_1_4
mike bayer [Fri, 19 Nov 2021 14:30:16 +0000 (14:30 +0000)] 
Merge "favor setuptools imports over distutils" into rel_1_4

3 years agoMerge "generalize cache_ok to UserDefinedType" into rel_1_4
mike bayer [Fri, 19 Nov 2021 14:30:03 +0000 (14:30 +0000)] 
Merge "generalize cache_ok to UserDefinedType" into rel_1_4

3 years agoMerge "disable raiseerr for refresh state loader options" into rel_1_4
mike bayer [Thu, 18 Nov 2021 20:51:01 +0000 (20:51 +0000)] 
Merge "disable raiseerr for refresh state loader options" into rel_1_4

3 years agouse typing.Dict
Mike Bayer [Thu, 18 Nov 2021 18:39:54 +0000 (13:39 -0500)] 
use typing.Dict

newer Pythons seem to accept ``dict[Any, Any]`` which is why
this wasn't noticed.  Revise fix for #7321 made in
I55656e867876677c5c55143449db371344be8600.

Fixes: #7321
Change-Id: Idc22e15d098543e07853f4532cfd1aaae4dd6404
(cherry picked from commit 2fe72b977506562811d3b4dce1c138f0a69f7ad4)

3 years agodisable raiseerr for refresh state loader options
Mike Bayer [Thu, 18 Nov 2021 17:46:25 +0000 (12:46 -0500)] 
disable raiseerr for refresh state loader options

Fixed ORM regression where the new behavior of "eager loaders run on
unexpire" added in :ticket:`1763` would lead to loader option errors being
raised inappropriately for the case where a single :class:`_orm.Query` or
:class:`_sql.Select` were used to load multiple kinds of entities, along
with loader options that apply to just one of those kinds of entity like a
:func:`_orm.joinedload`, and later the objects would be refreshed from
expiration, where the loader options would attempt to be applied to the
mismatched object type and then raise an exception. The check for this
mismatch now bypasses raising an error for this case.

Fixes: #7318
Change-Id: I111e0f3e0fb0447355574cbdcde002f734833490
(cherry picked from commit d4c170238dc95eeb2dc7e6c5e03270fbc8b36f8f)

3 years agofavor setuptools imports over distutils
Mike Bayer [Mon, 15 Nov 2021 20:06:06 +0000 (15:06 -0500)] 
favor setuptools imports over distutils

Python 3.10 has deprecated "distutils" in favor of explicit use of
"setuptools" in :pep:`632`; SQLAlchemy's setup.py has replaced imports
accordingly. However, since setuptools itself only recently added the
replacement symbols mentioned in pep-632 as of November of 2022 in version
59.0.1, ``setup.py`` still has fallback imports to distutils, as SQLAlchemy
1.4 does not have a hard setuptools versioning requirement at this time.
SQLAlchemy 2.0 is expected to use a full :pep:`517` installation layout
which will indicate appropriate setuptools versioning up front.

Fixes: #7311
Change-Id: I215ef3c3b226a38266f59d181214aea462c4664d
(cherry picked from commit e6c02c33728a581e0df910caa8d96b6e114c114d)

3 years agoMerge "Add new sections regarding schemas and reflection" into rel_1_4
mike bayer [Thu, 18 Nov 2021 16:14:44 +0000 (16:14 +0000)] 
Merge "Add new sections regarding schemas and reflection" into rel_1_4

3 years agohandle dunder names in @declared_attr separately
Mike Bayer [Mon, 15 Nov 2021 01:02:10 +0000 (20:02 -0500)] 
handle dunder names in @declared_attr separately

Fixed Mypy crash which would occur when using Mypy plugin against code
which made use of :class:`_orm.declared_attr` methods for non-mapped names
like ``__mapper_args__``, ``__table_args__``, or other dunder names, as the
plugin would try to interpret these as mapped attributes which would then
be later mis-handled. As part of this change, the decorated function is
still converted by the plugin into a generic assignment statement (e.g.
``__mapper_args__: Any``) so that the argument signature can continue to be
annotated in the same way one would for any other ``@classmethod`` without
Mypy complaining about the wrong argument type for a method that isn't
explicitly ``@classmethod``.

Fixes: #7321
Change-Id: I55656e867876677c5c55143449db371344be8600
(cherry picked from commit 836902bc8438a800d2c9cf1452da31d3ca967f3b)

3 years agoAdd new sections regarding schemas and reflection
jonathan vanasco [Mon, 27 Sep 2021 16:41:24 +0000 (12:41 -0400)] 
Add new sections regarding schemas and reflection

* add a new section to reflection.rst `Schemas and Reflection`.
  * this contains some text from the ticket
* migrate some text from `Specifying the Schema Name` to new section
* migrate some text from PostgreSQL dialect to new section
  * target text is made more generic
  * cross-reference the postgres and new sections to one another, to avoid duplication of docs
* update some docs 'meta' to 'metadata_obj'

Fixes: #4387
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: I2b08672753fb2575d30ada07ead77587468fdade
(cherry picked from commit 0fa0beacb465c61e792c97d530a0e8fdd7139256)

3 years agogeneralize cache_ok to UserDefinedType
Mike Bayer [Wed, 17 Nov 2021 20:08:29 +0000 (15:08 -0500)] 
generalize cache_ok to UserDefinedType

Extended the ``cache_ok`` flag and corresponding warning message if this
flag is not defined, a behavior first established for
:class:`.TypeDecorator` as part of :ticket:`6436`, to also take place for
:class:`.UserDefinedType`, by generalizing the flag and associated caching
logic to a new common base for these two types, :class:`.ExternalType`.

The change means any current :class:`.UserDefinedType` will now cause SQL
statement caching to no longer take place for statements which make use of
the datatype, along with a warning being emitted, unless the class defines
the :attr:`.UserDefinedType.cache_ok` flag as True. If the datatype cannot
form a deterministic, hashable cache key derived from its arguments, it may return
False which will continue to keep caching disabled but will suppress the
warning. In particular, custom datatypes currently used in packages such as
SQLAlchemy-utils will need to implement this flag. The issue was observed
as a result of a SQLAlchemy-utils datatype that is not currently cacheable.

Fixes: #7319
Change-Id: Ie0b5d4587df87bfe66d2fe7cd4585c3882584575
(cherry picked from commit 4761e6878b127f7d5fb09addaae15426edbb0b73)

3 years agoAdd Non linear CTE support
Eric Masseran [Tue, 2 Nov 2021 20:40:04 +0000 (16:40 -0400)] 
Add Non linear CTE support

"Compound select" methods like :meth:`_sql.Select.union`,
:meth:`_sql.Select.intersect_all` etc. now accept ``*other`` as an argument
rather than ``other`` to allow for multiple additional SELECTs to be
compounded with the parent statement at once. In particular, the change as
applied to :meth:`_sql.CTE.union` and :meth:`_sql.CTE.union_all` now allow
for a so-called "non-linear CTE" to be created with the :class:`_sql.CTE`
construct, whereas previously there was no way to have more than two CTE
sub-elements in a UNION together while still correctly calling upon the CTE
in recursive fashion. Pull request courtesy Eric Masseran.

Allow:

```sql
WITH RECURSIVE nodes(x) AS (
   SELECT 59
   UNION
   SELECT aa FROM edge JOIN nodes ON bb=x
   UNION
   SELECT bb FROM edge JOIN nodes ON aa=x
)
SELECT x FROM nodes;
```

Based on @zzzeek suggestion: https://github.com/sqlalchemy/sqlalchemy/pull/7133#issuecomment-933882348

Fixes: #7259
Closes: #7260
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/7260
Pull-request-sha: 2565a5fd4b1940e92125e53aeaa731cc682f49bb

Change-Id: I685c8379762b5fb6ab4107ff8f4d8a4de70c0ca6
(cherry picked from commit 958f902b1fc528fed0be550bc573545de47ed854)

3 years agoVersion 1.4.28 placeholder
Mike Bayer [Thu, 11 Nov 2021 15:48:50 +0000 (10:48 -0500)] 
Version 1.4.28 placeholder

3 years ago- 1.4.27 rel_1_4_27
Mike Bayer [Thu, 11 Nov 2021 15:42:08 +0000 (10:42 -0500)] 
- 1.4.27

3 years agoqualify asyncpg API tests for python 3.8
Mike Bayer [Wed, 10 Nov 2021 14:52:18 +0000 (09:52 -0500)] 
qualify asyncpg API tests for python 3.8

Getting
TypeError: object MagicMock can't be used in 'await' expression
for Python 3.7 and earlier.  this test is not needed
on all platforms it's confirming that two methods
are present.

Change-Id: If918add023c98c062ea0c1cd132a999647a2d35f
(cherry picked from commit 2c41cd99d8a4d8bb27c975f5e2511ab2bf261110)

3 years agoMerge "set within_columns_clause=False for all sub-elements of select()" into rel_1_4
mike bayer [Tue, 9 Nov 2021 23:56:20 +0000 (23:56 +0000)] 
Merge "set within_columns_clause=False for all sub-elements of select()" into rel_1_4

3 years agoMerge "upgrade deferred loader to regular loader if refresh_state" into rel_1_4
mike bayer [Tue, 9 Nov 2021 23:55:19 +0000 (23:55 +0000)] 
Merge "upgrade deferred loader to regular loader if refresh_state" into rel_1_4

3 years agoMerge "change the POSTCOMPILE/ SCHEMA symbols to not conflict w mssql quoting" into...
mike bayer [Tue, 9 Nov 2021 23:52:38 +0000 (23:52 +0000)] 
Merge "change the POSTCOMPILE/ SCHEMA symbols to not conflict w mssql quoting" into rel_1_4

3 years agochange the POSTCOMPILE/ SCHEMA symbols to not conflict w mssql quoting
Mike Bayer [Mon, 8 Nov 2021 23:29:16 +0000 (18:29 -0500)] 
change the POSTCOMPILE/ SCHEMA symbols to not conflict w mssql quoting

Adjusted the compiler's generation of "post compile" symbols including
those used for "expanding IN" as well as for the "schema translate map" to
not be based directly on plain bracketed strings with underscores, as this
conflicts directly with SQL Server's quoting format of also using brackets,
which produces false matches when the compiler replaces "post compile" and
"schema translate" symbols. The issue created easy to reproduce examples
both with the :meth:`.Inspector.get_schema_names` method when used in
conjunction with the
:paramref:`_engine.Connection.execution_options.schema_translate_map`
feature, as well in the unlikely case that a symbol overlapping with the
internal name "POSTCOMPILE" would be used with a feature like "expanding
in".

Fixes: #7300
Change-Id: I6255c850b140522a4aba95085216d0bca18ce230
(cherry picked from commit b919a0a85afd5066f9188b20ef06ee1b4af884a9)

3 years agoset within_columns_clause=False for all sub-elements of select()
Mike Bayer [Tue, 9 Nov 2021 20:02:44 +0000 (15:02 -0500)] 
set within_columns_clause=False for all sub-elements of select()

Fixed issue where using the feature of using a string label for ordering or
grouping described at :ref:`tutorial_order_by_label` would fail to function
correctly if used on a :class:`.CTE` construct, when the CTE were embedded
inside of an enclosing :class:`_sql.Select` statement that itself was set
up as a scalar subquery.

Fixes: #7269
Change-Id: Ied6048a1c9a622374a418230c8cfedafa8d3f87e
(cherry picked from commit 89661c1a218b7117c1835698dbb81836e72015ae)

3 years agoupgrade deferred loader to regular loader if refresh_state
Mike Bayer [Tue, 9 Nov 2021 16:31:23 +0000 (11:31 -0500)] 
upgrade deferred loader to regular loader if refresh_state

Fixed issue where deferred polymorphic loading of attributes from a
joined-table inheritance subclass would fail to populate the attribute
correctly if the :func:`_orm.load_only` option were used to originally
exclude that attribute, in the case where the load_only were descending
from a relationship loader option.  The fix allows that other valid options
such as ``defer(..., raiseload=True)`` etc. still function as expected.

Fixes: #7304
Change-Id: I58b7ce7c450bcc52d2f0c9bfbcb4d747463ee9b2
(cherry picked from commit 52b3d6649525929ee1ec14487a2f007194ed741d)

3 years agoFixes: #4390
jonathan vanasco [Mon, 27 Sep 2021 16:51:32 +0000 (12:51 -0400)] 
Fixes: #4390
Deprecated an undocumented loader option syntax ``".*"``, which appears to
be no different than passing a single asterisk, and will emit a deprecation
warning if used. This syntax may have been intended for something but there
is currently no need for it.

The original ticket was to document the `.{WILDCARD}` (e.g. `.*`) format,
however this format does not appear to be used or needed by SQLAlchemy
and is likely not used by any projects or developers.

This PR invokes `util.warn_deprecated` to notify users this functionality
is deprecated, and directs them to the #4390 issue if they actually use it.

Assuming there are no complaints over this warning in the coming months,
this code can be removed in a future major release.

Change-Id: I665e3ac26be0a7819246a2ee56fb5a5f32980c91
(cherry picked from commit 2432d2ed0b28480c0e1004a47aa74238865105b5)