]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
4 years agoPass all datetime values to pyodbc for timezone-naive column
Mike Bayer [Mon, 26 Apr 2021 23:17:06 +0000 (19:17 -0400)] 
Pass all datetime values to pyodbc for timezone-naive column

Fixed regression caused by :ticket:`6306` which added support for
``DateTime(timezone=True)``, where the previous behavior of the pyodbc
driver of implicitly dropping the tzinfo from a timezone-aware date when
INSERTing into a timezone-naive DATETIME column were lost, leading to a SQL
Server error when inserting timezone-aware datetime objects into
timezone-native database columns.

Fixes: #6366
Change-Id: Id7821de13d75ede27f2165b37277a7223468dfa4

4 years ago✏️ Fix small typos in SQLAlchemy 1.4 / 2.0 Tutorial (#6358)
Sebastián Ramírez [Mon, 26 Apr 2021 19:49:38 +0000 (21:49 +0200)] 
✏️ Fix small typos in SQLAlchemy 1.4 / 2.0 Tutorial (#6358)

* ✏️ Fix small typos in SQLAlchemy 1.4 / 2.0 Tutorial

* ⏪ Revert bikeshedding about "they", "we"

as I'm not sure changing to "they" actually helps disambiguate or not, so better to leave as it is.

4 years ago✏️ Fix small typo in Working with Transactions and the DBAPI (#6363)
Sebastián Ramírez [Mon, 26 Apr 2021 19:49:02 +0000 (21:49 +0200)] 
✏️ Fix small typo in Working with Transactions and the DBAPI (#6363)

4 years agoRemove py38 profiles
Federico Caselli [Mon, 26 Apr 2021 19:11:32 +0000 (21:11 +0200)] 
Remove py38 profiles

Change-Id: I726477b1c15fc6744ed16192ffca09df85bb01c8

4 years agoEnsure autobegin occurs for attribute changes; Document autobegin
Mike Bayer [Mon, 26 Apr 2021 13:50:50 +0000 (09:50 -0400)] 
Ensure autobegin occurs for attribute changes; Document autobegin

The Session autobegin feature was not anticipated as having
any behavioral changes other than the event hook being called
at a different time, however as autobegin impacts the behavior
of the commit() and rollback() methods in that they can now
be no-ops in non-autocommit mode, document the behavior fully.

Fixed issue where the new :ref:`session_autobegin` behavior failed to
"autobegin" in the case where an existing persistent object has an
attribute change, which would then impact the behavior of
:meth:`_orm.Session.rollback` in that no snapshot was created to be rolled
back. The "attribute modify" mechanics have been updated to ensure
"autobegin", which does not perform any database work, does occur when
persistent attributes change in the same manner as when
:meth:`_orm.Session.add` is called. This is a regression as in 1.3, the
rollback() method always had a transaction to roll back and would expire
every time.

Fixes: #6360
Fixes: #6359
Change-Id: I69f231a206f49e3231275d23bbe2cafd4e2bf3ba

4 years agoAdd order by to union example
Mike Bayer [Fri, 23 Apr 2021 23:15:48 +0000 (19:15 -0400)] 
Add order by to union example

the query in the second union example needs order by to
produce determinstic results on all plaforms including
OSX, arm

Change-Id: I88fcc391561db8567c389ed9e904e5de29c1c2ad

4 years agoMerge remote-tracking branch 'origin/pr/6341'
Mike Bayer [Fri, 23 Apr 2021 15:58:57 +0000 (11:58 -0400)] 
Merge remote-tracking branch 'origin/pr/6341'

Change-Id: I48e62f09d4f0f64ec409aa82272bb02a521cd53d

4 years agoMerge "dont assume ClauseElement in attributes, coercions"
mike bayer [Fri, 23 Apr 2021 15:52:40 +0000 (15:52 +0000)] 
Merge "dont assume ClauseElement in attributes, coercions"

4 years agoMerge "implement declared_attr superclass assignment check for dataclasses"
mike bayer [Fri, 23 Apr 2021 15:51:05 +0000 (15:51 +0000)] 
Merge "implement declared_attr superclass assignment check for dataclasses"

4 years agoAdd cross-linking for self-referential examples
Mike Bayer [Fri, 23 Apr 2021 15:29:58 +0000 (11:29 -0400)] 
Add cross-linking for self-referential examples

Change-Id: Ib2cb88210c680baafc26f714263309af11cda15a
References: #6351

4 years agoimplement declared_attr superclass assignment check for dataclasses
Mike Bayer [Fri, 23 Apr 2021 01:45:10 +0000 (21:45 -0400)] 
implement declared_attr superclass assignment check for dataclasses

Adjusted the declarative scan for dataclasses so that the inheritance
behavior of :func:`_orm.declared_attr` established on a mixin, when using
the new form of having it inside of a ``dataclasses.field()`` construct and
not actually a descriptor attribute on the class, correctly accommodates
the case when the target class to be mapped is a subclass of an existing
mapped class which has already mapped that :func:`_orm.declared_attr`, and
therefore should not be re-applied to this class.

Also, as changed in ed3f2c617239668d we now have an "is_dataclass"
boolean set as we iterate through attrs so we can remove this
from declared_attr.

Fixes: #6346
Change-Id: Iec75bdefd3bff7d8a9a157c8dd744ac14ff15ea8

4 years agodont assume ClauseElement in attributes, coercions
Mike Bayer [Fri, 23 Apr 2021 14:19:39 +0000 (10:19 -0400)] 
dont assume ClauseElement in attributes, coercions

Fixed two distinct issues, each of which would come into play under certain
circumstances, most likely however one which is a common mis-configuration
in :class:`_hybrid.hybrid_property`, where the "expression" implementation
would return a non :class:`_sql.ClauseElement` such as a boolean value.
For both issues, 1.3's behavior was to silently ignore the
mis-configuration and ultimately attempt to interpret the value as a
SQL expression, which would lead to an incorrect query.

* Fixed issue regarding interaction of the attribute system with
hybrid_property, where if the ``__clause_element__()`` method of the
attribute returned a non-:class:`_sql.ClauseElement` object, an internal
``AttributeError`` would lead the attribute to return the ``expression``
function on the hybrid_property itself, as the attribute error was
against the name ``.expression`` which would invoke the ``__getattr__()``
method as a fallback. This now raises explicitly. In 1.3 the
non-:class:`_sql.ClauseElement` was returned directly.

* Fixed issue in SQL argument coercions system where passing the wrong
kind of object to methods that expect column expressions would fail if
the object were altogether not a SQLAlchemy object, such as a Python
function, in cases where the object were not just coerced into a bound
value. Again 1.3 did not have a comprehensive argument coercion system
so this case would also pass silently.

Fixes: #6350
Change-Id: I5bba0a6b27f45e5f8ebadfd6d511fa773388ef7c

4 years agoMerge "omit text from selected_columns; clear memoizations"
mike bayer [Thu, 22 Apr 2021 22:59:53 +0000 (22:59 +0000)] 
Merge "omit text from selected_columns; clear memoizations"

4 years agoBreak up data.rst; add unions, literal_column
Mike Bayer [Thu, 22 Apr 2021 20:05:16 +0000 (16:05 -0400)] 
Break up data.rst; add unions, literal_column

This breaks data.rst into three separate sub-sections,
as SELECT is getting very long.  It then adds sections
on select() + text/literal_column as well as unions
and set operations, and also tries to improve the
ORDER BY section a bit.

Change-Id: Id90e6b4ff3699b2bbcb6e2eebbd23193e2ede00a

4 years agoomit text from selected_columns; clear memoizations
Mike Bayer [Thu, 22 Apr 2021 14:45:01 +0000 (10:45 -0400)] 
omit text from selected_columns; clear memoizations

Fixed regression where usage of the :func:`_sql.text` construct inside the
columns clause of a :class:`_sql.Select` construct, which is better handled
by using a :func:`_sql.literal_column` construct, would nonetheless prevent
constructs like :func:`_sql.union` from working correctly. Other use cases,
such as constructing subuqeries, continue to work the same as in prior
versions where the :func:`_sql.text` construct is silently omitted from the
collection of exported columns. Also repairs similar use within the
ORM.

This adds a new internal method _all_selected_columns.  The existing
"selected_columns" collection can't store a TextClause and this never
worked, so they are omitted.  The TextClause is also not "exported",
i.e. available for SELECT from a subquery, as was already the case
in 1.3, so the "exported_columns" and "exported_columns_iterator"
accessors are where we now omit TextClause.

Fixed regression involving legacy methods such as
:meth:`_sql.Select.append_column` where internal assertions would fail.

Fixes: #6343
Fixes: #6261
Change-Id: I7c2e5b9ae5d94131c77599a020f4310dcf812bcf

4 years agoEnsure sparse backend selection sorts on driver also
Mike Bayer [Thu, 22 Apr 2021 18:33:36 +0000 (14:33 -0400)] 
Ensure sparse backend selection sorts on driver also

Because we have --dbdriver now, we usually have
lots of db drivers queued up which affect the selection
of backend tests.   the sort in possible_configs_for_cls()
is used so that when we are only picking some backends
due to the sparse flag, we get the same answer each time
otherwise pytest-xdist raises an error if two workers
have different tests.

adding the sort for driver fixes an issue on jenkins
master build where the memusage test run frequently failed
due to mismatched test collection.

Change-Id: I8584c1a3a4e5b759c0e5a2602a93432d9cc8168d

4 years agoVersion 1.4.12 placeholder
Mike Bayer [Thu, 22 Apr 2021 03:15:51 +0000 (23:15 -0400)] 
Version 1.4.12 placeholder

4 years ago- 1.4.11 rel_1_4_11
Mike Bayer [Thu, 22 Apr 2021 03:10:02 +0000 (23:10 -0400)] 
- 1.4.11

4 years agofix typo
Mike Bayer [Thu, 22 Apr 2021 03:09:13 +0000 (23:09 -0400)] 
fix typo

Change-Id: I66e914680989ac86d836b3b1f87bbcbeda87a265

4 years agorepair test for mysql
Mike Bayer [Thu, 22 Apr 2021 03:03:51 +0000 (23:03 -0400)] 
repair test for mysql

mysql doesnt seem to be able to combine the metadata
fixture with multiprocessing here, do cleanup inside
the test for now.

Change-Id: I105ec1096bd162080a38e1a021d2520d1581bb04

4 years agoMerge "Add new "sync once" mode for pool.connect"
mike bayer [Thu, 22 Apr 2021 02:49:33 +0000 (02:49 +0000)] 
Merge "Add new "sync once" mode for pool.connect"

4 years agoAdd new "sync once" mode for pool.connect
Mike Bayer [Wed, 21 Apr 2021 18:44:45 +0000 (14:44 -0400)] 
Add new "sync once" mode for pool.connect

Fixed critical regression caused by the change in :ticket`5497` where the
connection pool "init" phase no longer occurred within mutexed isolation,
allowing other threads to proceed with the dialect uninitialized, which
could then impact the compilation of SQL statements.

This issue is essentially the same regression which was fixed many years
ago in :ticket:`2964` in dd32540dabbee0678530fb1b0868d1eb41572dca,
which was missed this time as the test suite fo
that issue only tested the pool in isolation, and assumed the
"first_connect" event would be used by the Engine.  However
:ticket:`5497` stopped using "first_connect" and no test detected
the lack of mutexing, that has been resolved here through
the addition of more tests.

This fix also identifies what is probably a bug in earlier versions
of SQLAlchemy where the "first_connect" handler would be cancelled
if the initializer failed; this is evidenced by
test_explode_in_initializer which was doing a reconnect due to
c.rollback() yet wasn't hanging.  We now solve this issue by
preventing the manufactured Connection from ever reconnecting
inside the first_connect handler.

Also remove the "_sqla_unwrap" test attribute; this is almost
not used anymore however we can use a more targeted
wrapper supplied by the testing.engines.proxying_engine
function.

See if we can also open up Oracle for "ad hoc engines" tests
now that we have better connection management logic.

Fixes: #6337
Change-Id: I4a3476625c4606f1a304dbc940d500325e8adc1a

4 years agoMerge "Mention how to turn warning to exceptions"
mike bayer [Wed, 21 Apr 2021 22:44:19 +0000 (22:44 +0000)] 
Merge "Mention how to turn warning to exceptions"

4 years agoFixed deprecated imports in orm/extensions docs 6341/head
NickKush [Wed, 21 Apr 2021 21:14:28 +0000 (00:14 +0300)] 
Fixed deprecated imports in orm/extensions docs

4 years agoLimit dc field logic to only fields that are definitely dc
Mike Bayer [Wed, 21 Apr 2021 14:39:09 +0000 (10:39 -0400)] 
Limit dc field logic to only fields that are definitely dc

Fixed regression where recent changes to support Python dataclasses had the
inadvertent effect that an ORM mapped class could not successfully override
the ``__new__()`` method.

In this case the "__new__" method comes out as staticmethod in
cls.__dict__ vs. a function in the metaclass dict_, so comparing
using identity fails.   I was hoping not to have too much
"dataclass" hardcoded, the logic here if it were generalized
to other attribute declaration systems there
would still have a flag that indicates an attribute is part of
the "special declaration system".

Fixes: #6331
Change-Id: Ia28a44fb57c668fa2fc5cd1ff38fd511f2c747e6

4 years agoVersion 1.4.11 placeholder
Mike Bayer [Wed, 21 Apr 2021 01:39:52 +0000 (21:39 -0400)] 
Version 1.4.11 placeholder

4 years ago- 1.4.10 rel_1_4_10
Mike Bayer [Wed, 21 Apr 2021 01:36:42 +0000 (21:36 -0400)] 
- 1.4.10

4 years agofix changelog entry
Mike Bayer [Wed, 21 Apr 2021 01:34:23 +0000 (21:34 -0400)] 
fix changelog entry

Change-Id: I2d4eb4b5d4fa351a476fc4afe944fb449d451b94

4 years agoMention how to turn warning to exceptions
Federico Caselli [Wed, 14 Apr 2021 20:44:28 +0000 (22:44 +0200)] 
Mention how to turn warning to exceptions

This helps locating the offending code, since the reported
warning location is not always correct.

References: #6241
Change-Id: I85d3a20e5b428a5003b541b36b9a77f1d7c1acb6

4 years agoPropagate compiler kw for visit_values to parameters
Mike Bayer [Tue, 20 Apr 2021 19:09:51 +0000 (15:09 -0400)] 
Propagate compiler kw for visit_values to parameters

Fixed issue in SQL compiler where the bound parameters set up for a
:class:`.Values` construct wouldn't be positionally tracked correctly if
inside of a :class:`_sql.CTE`, affecting database drivers that support
VALUES + ctes and use positional parameters such as SQL Server in
particular as well as asyncpg.   The fix also repairs support for
compiler flags such as ``literal_binds``.

Fixes: #6327
Change-Id: I2d549228691d0bfc10dadd0955b1549d7584db51

4 years agoMerge "Allow immediateload to use_get for recursive call"
mike bayer [Tue, 20 Apr 2021 18:58:34 +0000 (18:58 +0000)] 
Merge "Allow immediateload to use_get for recursive call"

4 years agoMerge "Add DateTime(timezone=True) support to mssql"
mike bayer [Tue, 20 Apr 2021 18:13:25 +0000 (18:13 +0000)] 
Merge "Add DateTime(timezone=True) support to mssql"

4 years agoMerge "Re-infer statements that got more specific on subsequent pass"
mike bayer [Tue, 20 Apr 2021 18:12:59 +0000 (18:12 +0000)] 
Merge "Re-infer statements that got more specific on subsequent pass"

4 years agoAllow immediateload to use_get for recursive call
Mike Bayer [Tue, 20 Apr 2021 18:09:51 +0000 (14:09 -0400)] 
Allow immediateload to use_get for recursive call

Altered some of the behavior repaired in :ticket:`6232` where the
``immediateload`` loader strategy no longer goes into recursive loops; the
modification is that an eager load (joinedload, selectinload, or
subqueryload) from A->bs->B which then states ``immediateload`` for a
simple manytoone B->a->A that's in the identity map will populate the B->A,
so that this attribute is back-populated when the collection of A/A.bs are
loaded. This allows the objects to be functional when detached.

Fixes: #6301
Change-Id: I8505d851802c38ad8ad4e2fab9030f7c17089e9d

4 years agoAdd DateTime(timezone=True) support to mssql
Gord Thompson [Sun, 18 Apr 2021 18:15:48 +0000 (12:15 -0600)] 
Add DateTime(timezone=True) support to mssql

The :paramref:`_types.DateTime.timezone` parameter when set to ``True``
will now make use of the ``DATETIMEOFFSET`` column type with SQL Server
when used to emit DDL, rather than ``DATETIME`` where the flag was silently
ignored.

Fixes: #6306
Change-Id: I4def8337046e8c190d424fa4a259ab24d5f9039e

4 years agoRe-infer statements that got more specific on subsequent pass
Mike Bayer [Mon, 19 Apr 2021 22:03:12 +0000 (18:03 -0400)] 
Re-infer statements that got more specific on subsequent pass

Fixed issue where mypy plugin would not correctly interpret an explicit
:class:`_orm.Mapped` annotation in conjunction with a
:func:`_orm.relationship` that refers to a class by string name; the
correct annotation would be downgraded to a less specific one leading to
typing errors.

The thing figured out here is that after we've already scanned
a class in the semanal stage and created DeclClassApplied,
when we are called again with that same DeclClassApplied, for this
specific kind of case we actually now have *better* types than
we did before, where the left side that looked like
List?[Address?] now seems to say
builtins.list[official.module.Address] - so let's take the
right side expression again, this time embedded in our
Mapped._empty_constructor() expression, and run the infer
all over again just like mypy would.   Just not setting the
"wrong" type here fixed the test cases but by re-applying the
whole infer we get the correct Mapped[] on the left side too.

Fixes: #6255
Change-Id: Iafe7254374f685a8458c7a1db82aafc2ed6d0232

4 years agoMerge "Derive `next_value.type` from `Sequence.data_type` if available"
mike bayer [Tue, 20 Apr 2021 17:04:57 +0000 (17:04 +0000)] 
Merge "Derive `next_value.type` from `Sequence.data_type` if available"

4 years agoNarrow refresh populate_existing to just refresh_state
Mike Bayer [Tue, 20 Apr 2021 15:33:02 +0000 (11:33 -0400)] 
Narrow refresh populate_existing to just refresh_state

Fixed additional regression caused by the "eagerloaders on refresh" feature
added in :ticket:`1763` where the refresh operation historically would set
``populate_existing``, which given the new feature now overwrites pending
changes on eagerly loaded objects when autoflush is false. The
populate_existing flag has been turned off for this case and a more
specific method used to ensure the correct attributes refreshed.

Fixes: #6326
Change-Id: I40315e4164eae28972c5839c04580d292bc6cb24

4 years agoadd some cross-linking for orderby/groupby docs + label examples
Mike Bayer [Mon, 19 Apr 2021 15:45:09 +0000 (11:45 -0400)] 
add some cross-linking for orderby/groupby docs + label examples

Change-Id: I34d4958ded8ec95e439ee47fdcb600f357cf7ae3
References: #6324

4 years agoMerge "Bypass declared_attr w/ a custom wrapper for lambda criteria"
mike bayer [Mon, 19 Apr 2021 01:33:43 +0000 (01:33 +0000)] 
Merge "Bypass declared_attr w/ a custom wrapper for lambda criteria"

4 years agoMerge "Fixed ``scalar_one`` usage after ``unique``."
mike bayer [Mon, 19 Apr 2021 00:47:29 +0000 (00:47 +0000)] 
Merge "Fixed ``scalar_one`` usage after ``unique``."

4 years agoBypass declared_attr w/ a custom wrapper for lambda criteria
Mike Bayer [Mon, 19 Apr 2021 00:30:14 +0000 (20:30 -0400)] 
Bypass declared_attr w/ a custom wrapper for lambda criteria

Fixed bug in new :func:`_orm.with_loader_criteria` feature where using a
mixin class with :func:`_orm.declared_attr` on an attribute that were
accessed inside the custom lambda would emit a warning regarding using an
unmapped declared attr, when the lambda callable were first initialized.
This warning is now prevented using special instrumentation for this
lambda initialization step.

Fixes: #6320
Change-Id: I18ce0c662131f2e683b84caa38c01b2182eb210b

4 years agoDerive `next_value.type` from `Sequence.data_type` if available
Bryan Forbes [Thu, 15 Apr 2021 17:35:52 +0000 (12:35 -0500)] 
Derive `next_value.type` from `Sequence.data_type` if available

Fixes #6287

Change-Id: I7d428ed86cd72cd910bfff9058a52c7fcb7c64ac

4 years agoImproved datetime documentation for sqlite
Federico Caselli [Sun, 18 Apr 2021 08:41:10 +0000 (10:41 +0200)] 
Improved datetime documentation for sqlite

closes #6313

Change-Id: Ib8e988915afc65c95ae6d4c22b7802a1226a2913

4 years agoMerge "Fixed ``instrument_declarative`` registry call."
mike bayer [Sat, 17 Apr 2021 17:31:29 +0000 (17:31 +0000)] 
Merge "Fixed ``instrument_declarative`` registry call."

4 years agoMerge "Don't stringify unnamed column elements when proxying"
mike bayer [Sat, 17 Apr 2021 17:25:00 +0000 (17:25 +0000)] 
Merge "Don't stringify unnamed column elements when proxying"

4 years agoFixed ``scalar_one`` usage after ``unique``.
Federico Caselli [Sat, 17 Apr 2021 09:56:51 +0000 (11:56 +0200)] 
Fixed ``scalar_one`` usage after ``unique``.

Fixed an issue that prevented using ``scalar_one`` or
``scalar_one_or_none()`` after a call to ``unique``.

Additionally includes some clarifications in result.py
and also removes pep-484 annotations for now as these
are duplicate on top of sqlalchemy2-stubs.

Fixes: #6299
Change-Id: Ia04f3d078c7a4f0d8488745e43d2fd63b60de9a0

4 years agoFixed ``instrument_declarative`` registry call.
Federico Caselli [Fri, 16 Apr 2021 20:25:56 +0000 (22:25 +0200)] 
Fixed ``instrument_declarative`` registry call.

Fixed :func:`_declarative.instrument_declarative` that called
a non existing registry method.

Fixes: #6291
Change-Id: I6fc8db84f72240cc82e7f6f3a784c424f5ccfc96

4 years agoVersion 1.4.10 placeholder
Mike Bayer [Sat, 17 Apr 2021 05:24:25 +0000 (01:24 -0400)] 
Version 1.4.10 placeholder

4 years ago- 1.4.9 rel_1_4_9
Mike Bayer [Sat, 17 Apr 2021 05:19:32 +0000 (01:19 -0400)] 
- 1.4.9

4 years agoMerge "pass asfrom correctly in compilers"
mike bayer [Sat, 17 Apr 2021 05:18:47 +0000 (05:18 +0000)] 
Merge "pass asfrom correctly in compilers"

4 years agoMerge "Uniquify FROMs when traversing through select"
mike bayer [Sat, 17 Apr 2021 04:45:28 +0000 (04:45 +0000)] 
Merge "Uniquify FROMs when traversing through select"

4 years agofix category
Mike Bayer [Sat, 17 Apr 2021 04:44:09 +0000 (00:44 -0400)] 
fix category

Change-Id: I6233ec667a4cca546e40e34224cc51998b5687d8

4 years agoDon't stringify unnamed column elements when proxying
Mike Bayer [Fri, 16 Apr 2021 15:06:56 +0000 (11:06 -0400)] 
Don't stringify unnamed column elements when proxying

Repaired and solidified issues regarding custom functions and other
arbitrary expression constructs which within SQLAlchemy's column labeling
mechanics would seek to use ``str(obj)`` to get a string representation to
use as an anonymous column name in the ``.c`` collection of a subquery.
This is a very legacy behavior that performs poorly and leads to lots of
issues, so has been revised to no longer perform any compilation by
establishing specific methods on :class:`.FunctionElement` to handle this
case, as SQL functions are the only use case that it came into play. An
effect of this behavior is that an unlabeled column expression with no
derivable name will be given an arbitrary label starting with the prefix
``"_no_label"`` in the ``.c`` collection of a subquery; these were
previously being represented either as the generic stringification of that
expression, or as an internal symbol.

This change seeks to make the concept of "anon name" more private
and renames anon_label and anon_key_label to _anon_name_label
and _anon_key_label.   There's no end-user utility to these accessors
and we need to be able to reorganize these as well.

Fixes: #6256
Change-Id: Ie63c86b20ca45873affea78500388da94cf8bf94

4 years agopass asfrom correctly in compilers
Mike Bayer [Sat, 17 Apr 2021 04:30:29 +0000 (00:30 -0400)] 
pass asfrom correctly in compilers

Fixed an argument error in the default and PostgreSQL compilers that
would interfere with an UPDATE..FROM or DELETE..FROM..USING statement
that was then SELECTed from as a CTE.

The incorrect pattern was also fixed in the mysql and sybase dialects.
MySQL supports CTEs but not "returning".

Fixes: #6303
Change-Id: Ic94805611a5ec443749fb6b1fd8a1326b0d83ef7

4 years agoUniquify FROMs when traversing through select
Mike Bayer [Sat, 17 Apr 2021 03:58:48 +0000 (23:58 -0400)] 
Uniquify FROMs when traversing through select

Fixed a critical performance issue where the traversal of a
:func:`_sql.select` construct would traverse a repetitive product of the
represented FROM clauses as they were each referred towards by columns in
the columns clause; for a series of nested subqueries with lots of columns
this could cause a large delay and significant memory growth. This
traversal is used by a wide variety of SQL and ORM functions, including by
the ORM :class:`_orm.Session` when it's configured to have
"table-per-bind", which while this is not a common use case, it seems to be
what Flask-SQLAlchemy is hardcoded as using, so the issue impacts
Flask-SQLAlchemy users. The traversal has been repaired to uniqify on FROM
clauses which was effectively what would happen implicitly with the pre-1.4
architecture.

Fixes: #6304
Change-Id: I43497e943db4065deab0bfc830fbb68c17b80a53

4 years agoFit literal compile of empty in on a tuple
Federico Caselli [Fri, 16 Apr 2021 20:07:34 +0000 (22:07 +0200)] 
Fit literal compile of empty in on a tuple

Fixed regression where an empty in statement on a tuple would result
in an error when compiled with the option ``literal_binds=True``.

Fixes: #6290
Change-Id: Ic0dff8f4a874cccdb201b6d9dcd3c2e7b7884cbb

4 years agosynonym fixes and enhancements
Mike Bayer [Fri, 16 Apr 2021 12:56:17 +0000 (08:56 -0400)] 
synonym fixes and enhancements

Fixed regression where an attribute that is mapped to a
:func:`_orm.synonym` could not be used in column loader options such as
:func:`_orm.load_only`.

Established support for :func:`_orm.synonym` in conjunction with hybrid
property, associationproxy, including that synonyms can be established
linking to these constructs which work fully. This is a behavior that was
semi-explicitly disallowed previously, however since it did not fail in
every scenario, explicit support for assoc proxy and hybrids has been
added.

Fixes: #6272
Fixes: #6267
Change-Id: Ie75bb3b535feeb6ccf3f6a391f21b69f241e625e

4 years agoVersion 1.4.9 placeholder
Mike Bayer [Thu, 15 Apr 2021 15:00:29 +0000 (11:00 -0400)] 
Version 1.4.9 placeholder

4 years ago- 1.4.8 rel_1_4_8
Mike Bayer [Thu, 15 Apr 2021 14:19:32 +0000 (10:19 -0400)] 
- 1.4.8

4 years agoMerge "test fixes from non-gerrit builds"
mike bayer [Thu, 15 Apr 2021 13:36:40 +0000 (13:36 +0000)] 
Merge "test fixes from non-gerrit builds"

4 years agoMerge "Fix with_expression() cache leak; don't adapt singletons"
mike bayer [Thu, 15 Apr 2021 12:35:07 +0000 (12:35 +0000)] 
Merge "Fix with_expression() cache leak; don't adapt singletons"

4 years agotest fixes from non-gerrit builds
Mike Bayer [Thu, 15 Apr 2021 12:28:34 +0000 (08:28 -0400)] 
test fixes from non-gerrit builds

- Fix savepoint test in test_memusage which hasn't been
running, jenkins now has this enabled for more backends

- fix SQL Server failure in test_assorted_eager

- don't mention "from_self()" in the error message for
Query

Fixes: #6277
Change-Id: I0b351032604bd19604143f86f5f055eefd4d0c23

4 years agoMerge "Fix as_declarative mypy test"
mike bayer [Thu, 15 Apr 2021 00:11:12 +0000 (00:11 +0000)] 
Merge "Fix as_declarative mypy test"

4 years agoFix with_expression() cache leak; don't adapt singletons
Mike Bayer [Wed, 14 Apr 2021 22:53:25 +0000 (18:53 -0400)] 
Fix with_expression() cache leak; don't adapt singletons

Fixed a cache leak involving the :func:`_orm.with_expression` loader
option, where the given SQL expression would not be correctly considered as
part of the cache key.

Additionally, fixed regression involving the corresponding
:func:`_orm.query_expression` feature. While the bug technically exists in
1.3 as well, it was not exposed until 1.4. The "default expr" value of
``null()`` would be rendered when not needed, and additionally was also not
adapted correctly when the ORM rewrites statements such as when using
joined eager loading. The fix ensures "singleton" expressions like ``NULL``
and ``true`` aren't "adapted" to refer to columns in ORM statements, and
additionally ensures that a :func:`_orm.query_expression` with no default
expression doesn't render in the statement if a
:func:`_orm.with_expression` isn't used.

Fixes: #6259
Change-Id: I5a70bc12dadad125bbc4324b64048c8d4a18916c

4 years agoFix as_declarative mypy test
Bryan Forbes [Wed, 14 Apr 2021 22:51:40 +0000 (17:51 -0500)] 
Fix as_declarative mypy test

Change-Id: I7f131c336cfe8987a1bcebf4a4068fd227f01226

4 years agodon't base compilation off the int value of offset/limit part II
Mike Bayer [Wed, 14 Apr 2021 20:14:36 +0000 (16:14 -0400)] 
don't base compilation off the int value of offset/limit part II

Fixed an additional regression in the same area as that of :ticket:`6184`,
where using a value of 0 for OFFSET in conjunction with LIMIT with SQL
Server would create a statement using "TOP", as was the behavior in 1.3,
however due to caching would then fail to respond accordingly to other
values of OFFSET. If the "0" wasn't first, then it would be fine. For the
fix, the "TOP" syntax is now only emitted if the OFFSET value is omitted
entirely, that is, :meth:`_sql.Select.offset` is not used. Note that this
change now requires that if the "with_ties" or "percent" modifiers are
used, the statement can't specify an OFFSET of zero, it now needs to be
omitted entirely.

Fixes: #6265
Change-Id: If30596b8dcd9f2ce4221cd87c5407fa81f5f9a90

4 years agoremove comment (post-production)
Mike Bayer [Wed, 14 Apr 2021 17:22:05 +0000 (13:22 -0400)] 
remove comment (post-production)

remove comment as stated in I47959bc826e3d9d2396ccfa290eb084841b02e77

Change-Id: Ic7978494314000cc4f57555802f22c1970bccc31

4 years agoMerge "Support DEFAULT VALUES and VALUES(DEFAULT) individually"
mike bayer [Wed, 14 Apr 2021 17:21:36 +0000 (17:21 +0000)] 
Merge "Support DEFAULT VALUES and VALUES(DEFAULT) individually"

4 years agoSupport DEFAULT VALUES and VALUES(DEFAULT) individually
Mike Bayer [Tue, 13 Apr 2021 14:52:00 +0000 (10:52 -0400)] 
Support DEFAULT VALUES and VALUES(DEFAULT) individually

Fixed regression where the introduction of the INSERT syntax "INSERT...
VALUES (DEFAULT)" was not supported on some backends that do however
support "INSERT..DEFAULT VALUES", including SQLite. The two syntaxes are
now each individually supported or non-supported for each dialect, for
example MySQL supports "VALUES (DEFAULT)" but not "DEFAULT VALUES".
Support for Oracle is still not enabled as there are unresolved issues
in using RETURNING at the same time.

Fixes: #6254
Change-Id: I47959bc826e3d9d2396ccfa290eb084841b02e77

4 years agoExplicitly test for Connection in dialect.has_table()
Mike Bayer [Wed, 14 Apr 2021 16:12:08 +0000 (12:12 -0400)] 
Explicitly test for Connection in dialect.has_table()

The :meth:`_engine.Dialect.has_table` method now raises an informative
exception if a non-Connection is passed to it, as this incorrect behavior
seems to be common.  This method is not intended for external use outside
of a dialect.  Please use the :meth:`.Inspector.has_table` method
or for cross-compatibility with older SQLAlchemy versions, the
:meth:`_engine.Engine.has_table` method.

Fixes: #5780
Fixes: #6062
Fixes: #6260
Change-Id: I9b2439675167019b68d682edee3dcdcfce836987

4 years agoFix OrderingList handling
Bryan Forbes [Mon, 12 Apr 2021 21:24:37 +0000 (16:24 -0500)] 
Fix OrderingList handling

Revised the fix for ``OrderingList`` from version 1.4.7 which was testing
against the incorrect API.

Fixes: #6205
Change-Id: I1d3f8b6534b70ae000294c2a67f08117cb77ee99

4 years agoMerge "Update mypy plugin to conform to strict mode"
mike bayer [Tue, 13 Apr 2021 19:38:32 +0000 (19:38 +0000)] 
Merge "Update mypy plugin to conform to strict mode"

4 years agoDisable raiseload in immediateload strategy
Mike Bayer [Tue, 13 Apr 2021 03:48:02 +0000 (23:48 -0400)] 
Disable raiseload in immediateload strategy

Fixed issue in the new feature of :meth:`_orm.Session.refresh` introduced
by :ticket:`1763` where eagerly loaded relationships are also refreshed,
where the ``lazy="raise"`` and ``lazy="raise_on_sql"`` loader strategies
would interfere with the :func:`_orm.immediateload` loader strategy, thus
breaking the feature for relationships that were loaded with
:func:`_orm.selectinload`, :func:`_orm.subqueryload` as well.

Also update some docs re: refresh, populate existing, etc.

Fixes: #6252
Change-Id: I5ac1430d33f1ce868426c22c7635f41f738580ce

4 years agoUpdate mypy plugin to conform to strict mode
Bryan Forbes [Mon, 12 Apr 2021 21:24:37 +0000 (16:24 -0500)] 
Update mypy plugin to conform to strict mode

Change-Id: I09a3df5af2f2d4ee34d8d72c3dedc4f236df8eb1

4 years agoMerge "Fix typo that prevented setting the ``bind`` attribute of an :class:`_asyncio...
mike bayer [Mon, 12 Apr 2021 19:38:50 +0000 (19:38 +0000)] 
Merge "Fix typo that prevented setting the ``bind`` attribute of an :class:`_asyncio.AsyncSession` to the correct value."

4 years agoMerge "Update mypy plugin to only use public plugin API"
mike bayer [Mon, 12 Apr 2021 19:38:13 +0000 (19:38 +0000)] 
Merge "Update mypy plugin to only use public plugin API"

4 years agoMerge "Ensure bindparam key escaping applied in all cases"
mike bayer [Mon, 12 Apr 2021 19:32:03 +0000 (19:32 +0000)] 
Merge "Ensure bindparam key escaping applied in all cases"

4 years agoMerge "Fix supports_schemas entry in changelog_14.rst"
mike bayer [Mon, 12 Apr 2021 19:31:20 +0000 (19:31 +0000)] 
Merge "Fix supports_schemas entry in changelog_14.rst"

4 years agoEnsure bindparam key escaping applied in all cases
Mike Bayer [Mon, 12 Apr 2021 18:33:50 +0000 (14:33 -0400)] 
Ensure bindparam key escaping applied in all cases

Fixed regression where the :class:`_sql.BindParameter` object would not
properly render for an IN expression (i.e. using the "post compile" feature
in 1.4) if the object were copied from either an internal cloning
operation, or from a pickle operation, and the parameter name contained
spaces or other special characters.

Fixes: #6249
Change-Id: Icd0d4096c8fa4eb1a1d4c20f8a96d8b1ae439f0a

4 years agoFixed typo in docstring 6246/head
Mark Bell [Mon, 12 Apr 2021 01:47:24 +0000 (02:47 +0100)] 
Fixed typo in docstring

4 years agoReturn Row for CursorResult.inserted_primary_key
Mike Bayer [Sun, 11 Apr 2021 21:15:55 +0000 (17:15 -0400)] 
Return Row for CursorResult.inserted_primary_key

The tuple returned by :attr:`.CursorResult.inserted_primary_key` is now a
:class:`_result.Row` object with a named tuple interface on top of the
existing tuple interface.

Fixes: #3314
Change-Id: I85677ef60d8329648f368bf497f634758f4e087b

4 years agoFix supports_schemas entry in changelog_14.rst
Gord Thompson [Sun, 11 Apr 2021 17:39:41 +0000 (11:39 -0600)] 
Fix supports_schemas entry in changelog_14.rst

The default for supports_schemas is ``True`` so
third-party dialects would set it to ``False``
if they want to *disable* the schema-level tests.

Change-Id: I63aea1ed14fc1f08ec7d5c8860097414ac607322

4 years agoDocument AsyncSession.refresh() w/ refresh-expire cascade quirk
Mike Bayer [Sun, 11 Apr 2021 15:30:01 +0000 (11:30 -0400)] 
Document AsyncSession.refresh() w/ refresh-expire cascade quirk

Change-Id: I90e884d12e5843609fa9078aaba4d471e80ba7cd
References: #6243

4 years agoClarify select_from(A).join(B.a)
Mike Bayer [Sun, 11 Apr 2021 15:10:20 +0000 (11:10 -0400)] 
Clarify select_from(A).join(B.a)

Fixes: #2722
Change-Id: I025715023fa74b1f9ade4ecc8ed8712f42de727a

4 years agoupdate .Unicode documentation
Mike Bayer [Sat, 10 Apr 2021 15:51:47 +0000 (11:51 -0400)] 
update .Unicode documentation

to reflect the modernization that was already done in
String.

Fixes: #6238
Change-Id: I92c667b45f040c6dad431c53d89d01fdcc2a2a2a

4 years agoFix typo that prevented setting the ``bind``
Federico Caselli [Sat, 10 Apr 2021 13:24:21 +0000 (15:24 +0200)] 
Fix typo that prevented setting the ``bind``
attribute of an :class:`_asyncio.AsyncSession` to the correct value.

Fixes: #6220
Change-Id: I91021351b8076e4aa4139af4b2cf359b3c0404af

4 years agoFix trivial typo in README.unittests 6237/head
Stephen Rosen [Fri, 9 Apr 2021 23:32:34 +0000 (23:32 +0000)] 
Fix trivial typo in README.unittests

4 years agoFix error in documentation of DDLElement
Federico Caselli [Fri, 9 Apr 2021 22:31:51 +0000 (00:31 +0200)] 
Fix error in documentation of DDLElement

Change-Id: I9d850458c274d245057ea676d6730d4bd93c261f

4 years agoUpdate mypy plugin to only use public plugin API
Bryan Forbes [Fri, 9 Apr 2021 19:27:16 +0000 (14:27 -0500)] 
Update mypy plugin to only use public plugin API

Change-Id: Id7f4e4a39e17c1b6ec3c754e2fc5c6ba4b437c38

4 years agoVersion 1.4.8 placeholder
Mike Bayer [Fri, 9 Apr 2021 17:09:46 +0000 (13:09 -0400)] 
Version 1.4.8 placeholder

4 years ago- 1.4.7 rel_1_4_7
Mike Bayer [Fri, 9 Apr 2021 17:07:59 +0000 (13:07 -0400)] 
- 1.4.7

4 years agoadd changelog for supports_schema
Mike Bayer [Fri, 9 Apr 2021 17:06:49 +0000 (13:06 -0400)] 
add changelog for supports_schema

Change-Id: I9fb9947c45e34369ebb8f55c3c52a2d6f4e879cf

4 years agoMerge "Dont return outer transaction for _subtrans flag"
mike bayer [Fri, 9 Apr 2021 16:35:53 +0000 (16:35 +0000)] 
Merge "Dont return outer transaction for _subtrans flag"

4 years agoclose session for loading test
Mike Bayer [Fri, 9 Apr 2021 16:25:20 +0000 (12:25 -0400)] 
close session for loading test

Fixes pypy

Change-Id: Iadfb8bc74d47a23e50ab69e9d784652355f5e622

4 years agoMerge "Apply recursive check to immediateloader and generalize"
mike bayer [Fri, 9 Apr 2021 16:03:43 +0000 (16:03 +0000)] 
Merge "Apply recursive check to immediateloader and generalize"

4 years agoDont return outer transaction for _subtrans flag
Mike Bayer [Fri, 9 Apr 2021 15:09:16 +0000 (11:09 -0400)] 
Dont return outer transaction for _subtrans flag

Fixed critical regression where the :class:`_orm.Session` could fail to
"autobegin" a new transaction when a flush occurred without an existing
transaction in place, implicitly placing the :class:`_orm.Session` into
legacy autocommit mode which commit the transaction. The
:class:`_orm.Session` now has a check that will prevent this condition from
occurring, in addition to repairing the flush issue.

Additionally, scaled back part of the change made as part of :ticket:`5226`
which can run autoflush during an unexpire operation, to not actually
do this in the case of a :class:`_orm.Session` using legacy
:paramref:`_orm.Session.autocommit` mode, as this incurs a commit within
a refresh operation.

Fixes: #6233
Change-Id: Ia980e62a090e39e3e2a7fb77c95832ae784cc9a5

4 years agoApply recursive check to immediateloader and generalize
Mike Bayer [Fri, 9 Apr 2021 14:46:21 +0000 (10:46 -0400)] 
Apply recursive check to immediateloader and generalize

Fixed critical regression caused by the new feature added as part of
:ticket:`1763`, eager loaders are invoked on unexpire operations. The new
feature makes use of the "immediateload" eager loader strategy as a
substitute for a collection loading strategy, which unlike the other
"post-load" strategies was not accommodating for recursive invocations
between mutually-dependent relationships, leading to recursion overflow
errors.

Fixes: #6232
Change-Id: Ifb2286281f40d1a04c24741261d4438659b6e3dd

4 years agoMake schema support explicit
Gord Thompson [Thu, 8 Apr 2021 23:22:34 +0000 (17:22 -0600)] 
Make schema support explicit

Add ``supports_schema = True`` to DefaultDialect and modify
requirements.py to use that attribute so third-party dialects
can explicitly indicate that they do *not* support schemas by
specifying ``supports_schema = False`` in their Dialect class.

Change-Id: Idffee82f6668a15ac7148f2a407a17de785d1fb7

4 years agodocument scalar_subquery() with column_property()
Mike Bayer [Fri, 9 Apr 2021 13:25:04 +0000 (09:25 -0400)] 
document scalar_subquery() with column_property()

Other doc cleanups and fixes as well, including more
explicitness that declarative attribute assignment only
works when a declarative base is involved; other forms
need to call add_property() directly.

Fixes: #6225
Change-Id: I123c3fb35cfa788b96bac7ab640f6de857d003d6