]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
4 years agoMerge "Support stream_results in the pg8000 dialect"
mike bayer [Sun, 2 May 2021 13:17:00 +0000 (13:17 +0000)] 
Merge "Support stream_results in the pg8000 dialect"

4 years agoMerge "Support filter_by() from columns, functions, Core SQL"
mike bayer [Sun, 2 May 2021 13:13:42 +0000 (13:13 +0000)] 
Merge "Support filter_by() from columns, functions, Core SQL"

4 years agospecify tuple_in for composite selectinload test / mssql
Mike Bayer [Sat, 1 May 2021 18:59:39 +0000 (14:59 -0400)] 
specify tuple_in for composite selectinload test / mssql

Change-Id: Ie527c4aa02d48bf1fcce3e192cd6299c15569fb0

4 years agoAvoid creating asyncio.Lock on the wrong loop.
Federico Caselli [Fri, 30 Apr 2021 20:36:59 +0000 (22:36 +0200)] 
Avoid creating asyncio.Lock on the wrong loop.

Fixed a regression introduced by :ticket:`6337` that would create an
``asyncio.Lock`` which could be attached to the wrong loop when
instantiating the async engine before any asyncio loop was started, leading
to an asyncio error message when attempting to use the engine under certain
circumstances.

Fixes: #6409
Change-Id: I8119c56b44a7bd70a650c0ea676892d4d7814a8b

4 years agoSupport filter_by() from columns, functions, Core SQL
Mike Bayer [Sat, 1 May 2021 12:41:09 +0000 (08:41 -0400)] 
Support filter_by() from columns, functions, Core SQL

Fixed regression where :meth:`_orm.Query.filter_by` would not work if the
lead entity were a SQL function or other expression derived from the
primary entity in question, rather than a simple entity or column of that
entity. Additionally, improved the behavior of
:meth:`_sql.Select.filter_by` overall to work with column expressions even
in a non-ORM context.

Fixes: #6414
Change-Id: I316b5bf98293bec1ede08787f6181dd14be85419

4 years agotrack_on needs to be a fixed size, support sub-tuples
Mike Bayer [Fri, 30 Apr 2021 15:54:52 +0000 (11:54 -0400)] 
track_on needs to be a fixed size, support sub-tuples

Fixed regression in ``selectinload`` loader strategy that would cause it to
cache its internal state incorrectly when handling relationships that join
across more than one column, such as when using a composite foreign key.
The invalid caching would then cause other loader operations to fail.

Fixes: #6410
Change-Id: I9f95ccca3553e7fd5794c619be4cf85c02b04626

4 years agoVersion 1.4.13 placeholder
Mike Bayer [Thu, 29 Apr 2021 21:56:51 +0000 (17:56 -0400)] 
Version 1.4.13 placeholder

4 years ago- 1.4.12 rel_1_4_12
Mike Bayer [Thu, 29 Apr 2021 21:46:15 +0000 (17:46 -0400)] 
- 1.4.12

4 years agofix typo
Mike Bayer [Thu, 29 Apr 2021 21:44:17 +0000 (17:44 -0400)] 
fix typo

Change-Id: I664eb4f4c023ec41d51c444919ca4b6867267738

4 years agoMerge "Ensure iterable passed to Select is not a mapped class"
mike bayer [Thu, 29 Apr 2021 21:28:32 +0000 (21:28 +0000)] 
Merge "Ensure iterable passed to Select is not a mapped class"

4 years agoMerge "Fix ForeignKeyConstraint.copy() error"
mike bayer [Thu, 29 Apr 2021 21:28:19 +0000 (21:28 +0000)] 
Merge "Fix ForeignKeyConstraint.copy() error"

4 years agoEnsure iterable passed to Select is not a mapped class
Mike Bayer [Thu, 29 Apr 2021 20:38:03 +0000 (16:38 -0400)] 
Ensure iterable passed to Select is not a mapped class

Fixed regression caused by :ticket:`5395` where tuning back the check for
sequences in :func:`_sql.select` now caused failures when doing 2.0-style
querying with a mapped class that also happens to have an ``__iter__()``
method. Tuned the check some more to accommodate this as well as some other
interesting ``__iter__()`` scenarios.

Fixes: #6300
Change-Id: Idf1983fd764b91a7d5fa8117aee8a3def3cfe5ff

4 years agoFix ForeignKeyConstraint.copy() error
Gord Thompson [Thu, 29 Apr 2021 18:57:06 +0000 (12:57 -0600)] 
Fix ForeignKeyConstraint.copy() error

Fixed an issue with the (deprecated in 1.4)
:meth:`_schema.ForeignKeyConstraint.copy` method that caused an error when
invoked with the ``schema`` argument.

Fixes: #6353
Change-Id: I03330d9ec254d64377f2b2e86af69a4eaff43ac6

4 years agoMerge "fix mapper._primary_key_propkeys"
mike bayer [Thu, 29 Apr 2021 19:54:00 +0000 (19:54 +0000)] 
Merge "fix mapper._primary_key_propkeys"

4 years agoMerge "Use non-subquery form for empty IN"
mike bayer [Thu, 29 Apr 2021 19:53:02 +0000 (19:53 +0000)] 
Merge "Use non-subquery form for empty IN"

4 years agoUse non-subquery form for empty IN
Mike Bayer [Wed, 28 Apr 2021 22:31:51 +0000 (18:31 -0400)] 
Use non-subquery form for empty IN

Revised the "EMPTY IN" expression to no longer rely upon using a subquery,
as this was causing some compatibility and performance problems. The new
approach for selected databases takes advantage of using a NULL-returning
IN expression combined with the usual "1 != 1" or "1 = 1" expression
appended by AND or OR. The expression is now the default for all backends
other than SQLite, which still had some compatibility issues regarding
tuple "IN" for older SQLite versions.

Third party dialects can still override how the "empty set" expression
renders by implementing a new compiler method
``def visit_empty_set_op_expr(self, type_, expand_op)``, which takes
precedence over the existing
``def visit_empty_set_expr(self, element_types)`` which remains in place.

Fixes: #6258
Fixes: #6397
Change-Id: I2df09eb00d2ad3b57039ae48128fdf94641b5e59

4 years agoSupport stream_results in the pg8000 dialect
Tony Locke [Thu, 29 Apr 2021 18:25:09 +0000 (14:25 -0400)] 
Support stream_results in the pg8000 dialect

### Description
This change adds support for stream_results for the pg8000 dialect by adding a server side cursor. The server-side cursor is a wrapper around a standard DBAPI cursor, and uses the SQL-level cursors. This is being discussed in issue https://github.com/sqlalchemy/sqlalchemy/issues/6198 and this pull request is really to give a concrete example of what I was suggesting.

### Checklist

<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [ ] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [x] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

**Have a nice day!**

Closes: #6356
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6356
Pull-request-sha: 071e118a6b09a26c511b39b0d589ebd2de8d508c

Change-Id: Id1a865adf0ff64294c71814681f5b4d593939db6

4 years agofix mapper._primary_key_propkeys
Mike Bayer [Thu, 29 Apr 2021 16:03:47 +0000 (12:03 -0400)] 
fix mapper._primary_key_propkeys

Fixed issue in :meth:`_orm.Session.bulk_save` when used with persistent
objects which would fail to track the primary key of mappings where the
column name of the primary key were different than the attribute name.

Fixes: #6392
Change-Id: I9b89bf00f900b7d2287517249e4f9356f20f0bdb

4 years agoaccommodate HasEntityNamespace in context.all_selected_columns
Mike Bayer [Thu, 29 Apr 2021 14:40:00 +0000 (10:40 -0400)] 
accommodate HasEntityNamespace in context.all_selected_columns

Fixed regression in hybrid_property where a hybrid against a SQL function
would generate an ``AttributeError`` when attempting to generate an entry
for the ``.c`` collection of a subquery in some cases; among other things
this would impact its use in cases like that of ``Query.count()``.

Fixes: #6401
Change-Id: Icc243c699e9a5c88448076c6427ec389eaa8b8ed

4 years agochangelog updates
Mike Bayer [Thu, 29 Apr 2021 13:18:15 +0000 (09:18 -0400)] 
changelog updates

Change-Id: I43d6373f00d55599bc11f01a2ed8f644c4477dd5

4 years agoMerge "Propertly ignore ``Identity`` in MySQL and MariaDb."
mike bayer [Thu, 29 Apr 2021 12:59:42 +0000 (12:59 +0000)] 
Merge "Propertly ignore ``Identity`` in MySQL and MariaDb."

4 years agoclarify individual isolation level section
Mike Bayer [Thu, 29 Apr 2021 12:42:40 +0000 (08:42 -0400)] 
clarify individual isolation level section

also rewrite the "individual sessions" section
to not rely upon context from the previous section,
this is a bad habit and should be fixed whereever we can
find it becuase people click on individual sections out of
context.

Change-Id: I288ffcc84ff462fb36cd7f4075f39d53c55fbf35

4 years agoPropertly ignore ``Identity`` in MySQL and MariaDb.
Federico Caselli [Wed, 21 Apr 2021 20:49:09 +0000 (22:49 +0200)] 
Propertly ignore ``Identity`` in MySQL and MariaDb.

Ensure that the MySQL and MariaDB dialect ignore the
:class:`_sql.Identity` construct while rendering the
``AUTO_INCREMENT`` keyword in a create table.

The Oracle and PostgreSQL compiler was updated to not render
:class:`_sql.Identity` if the database version does not support it
(Oracle < 12 and PostgreSQL < 10). Previously it was rendered regardless
of the database version.

Fixes: #6338
Change-Id: I2ca0902fdd7b4be4fc1a563cf5585504cbea9360

4 years agoMerge "Use SingletonThreadPool for in-memory SQLite database created using filename...
mike bayer [Wed, 28 Apr 2021 22:53:48 +0000 (22:53 +0000)] 
Merge "Use SingletonThreadPool for in-memory SQLite database created using filename uri"

4 years agoMerge "Add .as_generic() support to mssql BIT columns"
mike bayer [Wed, 28 Apr 2021 22:53:04 +0000 (22:53 +0000)] 
Merge "Add .as_generic() support to mssql BIT columns"

4 years agoMerge "ensure SelectState.all_selected_columns not memoized as a generator"
mike bayer [Wed, 28 Apr 2021 22:51:45 +0000 (22:51 +0000)] 
Merge "ensure SelectState.all_selected_columns not memoized as a generator"

4 years agoMerge "add optional proxy_class to track w/ proxy_key"
mike bayer [Wed, 28 Apr 2021 22:50:31 +0000 (22:50 +0000)] 
Merge "add optional proxy_class to track w/ proxy_key"

4 years agoMerge "accommodate for mutiple copies of bind in ckbm"
mike bayer [Wed, 28 Apr 2021 21:10:09 +0000 (21:10 +0000)] 
Merge "accommodate for mutiple copies of bind in ckbm"

4 years agoUse SingletonThreadPool for in-memory SQLite
YongJieYongJie [Wed, 28 Apr 2021 17:30:09 +0000 (13:30 -0400)] 
Use SingletonThreadPool for in-memory SQLite
database created using filename uri

Default to using ``SingletonThreadPool`` for in-memory SQLite databases
created using URI filenames. Previously the default pool used was the
``NullPool`` that precented sharing the same database between multiple
engines.

Fixes: #6379
Closes: #6380
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6380
Pull-request-sha: 3b8024417a3a54c8269d43e40801aa4e58593540

Change-Id: Ice09622796455e796ede7711c98f3ceec13aa949

4 years ago✏️ Fix minor typos in "Selecting Rows with Core or ORM" (#6381)
Sebastián Ramírez [Wed, 28 Apr 2021 18:42:12 +0000 (20:42 +0200)] 
✏️ Fix minor typos in "Selecting Rows with Core or ORM" (#6381)

4 years ago✏️ Fix typos in "Data Manipulation with the ORM" (#6389)
Sebastián Ramírez [Wed, 28 Apr 2021 18:42:07 +0000 (20:42 +0200)] 
✏️ Fix typos in "Data Manipulation with the ORM" (#6389)

4 years ago✏️ Fix a small typo in the Glossary (#6395)
Sebastián Ramírez [Wed, 28 Apr 2021 18:42:01 +0000 (20:42 +0200)] 
✏️ Fix a small typo in the Glossary (#6395)

4 years ago✏️ Fix typos in "Working with Related Objects" (#6393)
Sebastián Ramírez [Wed, 28 Apr 2021 18:41:54 +0000 (20:41 +0200)] 
✏️ Fix typos in "Working with Related Objects" (#6393)

4 years ago✏️ Fix small typo in "Updating and Deleting Rows with Core" (#6382)
Sebastián Ramírez [Wed, 28 Apr 2021 18:39:29 +0000 (20:39 +0200)] 
✏️ Fix small typo in "Updating and Deleting Rows with Core" (#6382)

4 years agoaccommodate for mutiple copies of bind in ckbm
Mike Bayer [Wed, 28 Apr 2021 16:14:33 +0000 (12:14 -0400)] 
accommodate for mutiple copies of bind in ckbm

Fixed critical regression where bound parameter tracking as used in the SQL
caching system could fail to track all parameters for the case where the
same SQL expression containing a parameter were used in an ORM-related
query using a feature such as class inheritance, which was then embedded in
an enclosing expression which would make use of that same expression
multiple times, such as a UNION. The ORM would individually copy the
individual SELECT statements as part of compilation with class inheritance,
which then embedded in the enclosing statement would fail to accommodate
for all parameters. The logic that tracks this condition has been adjusted
to work for multiple copies of a parameter.

Fixes: #6391
Change-Id: I6db5dee0d361a3bb58d753a2d27ef2eee2b369c5

4 years agoensure SelectState.all_selected_columns not memoized as a generator
Mike Bayer [Wed, 28 Apr 2021 18:11:20 +0000 (14:11 -0400)] 
ensure SelectState.all_selected_columns not memoized as a generator

This regression was found from #6261 before release of 1.4.12

Fixes: #6261
Fixes: #6394
Change-Id: I4c2c5da02dbcf5c2cea26c81d3521de892ef428e

4 years agoadd optional proxy_class to track w/ proxy_key
Mike Bayer [Wed, 28 Apr 2021 13:56:15 +0000 (09:56 -0400)] 
add optional proxy_class to track w/ proxy_key

Fixed regression in ORM where using hybrid property to indicate an
expression from a different entity would confuse the column-labeling logic
in the ORM and attempt to derive the name of the hybrid from that other
class, leading to an attribute error. The owning class of the hybrid
attribute is now tracked along with the name.

Fixes: #6386
Change-Id: Ica9497ea34fef799d6265de44104c1f3f3b30232

4 years agodon't mutate the statement in ORM compile
Mike Bayer [Wed, 28 Apr 2021 00:44:46 +0000 (20:44 -0400)] 
don't mutate the statement in ORM compile

Fixed issue where using a :class:`_sql.Select` as a subquery in an ORM
context would modify the :class:`_sql.Select` in place to disable
eagerloads on that object, which would then cause that same
:class:`_sql.Select` to not eagerload if it were then re-used in a
top-level execution context.

Fixes: #6378
Change-Id: I945048c4c148587b933fb65a3fc83a05d05c052d

4 years ago✏️ Fix small typos in "Working with Database Metadata" (#6369)
Sebastián Ramírez [Tue, 27 Apr 2021 20:22:38 +0000 (22:22 +0200)] 
✏️ Fix small typos in "Working with Database Metadata" (#6369)

4 years agotypo in an import statement in docs (#6362)
Geraint Williams [Tue, 27 Apr 2021 20:22:29 +0000 (21:22 +0100)] 
typo in an import statement in docs (#6362)

* typo in import in docs

* fix typo in documentation import statement

4 years ago✏️ Fix small formatting typo in "Working with Data" (#6370)
Sebastián Ramírez [Tue, 27 Apr 2021 20:22:01 +0000 (22:22 +0200)] 
✏️ Fix small formatting typo in "Working with Data" (#6370)

4 years agoAdd .as_generic() support to mssql BIT columns
Gord Thompson [Thu, 22 Apr 2021 14:52:15 +0000 (08:52 -0600)] 
Add .as_generic() support to mssql BIT columns

Fixes: #6345
Change-Id: I2bdccc88e85c94d87519f58e474689ca7896f063

4 years agoMerge "have SchemaType inherit schema from metadata"
mike bayer [Tue, 27 Apr 2021 18:20:19 +0000 (18:20 +0000)] 
Merge "have SchemaType inherit schema from metadata"

4 years agohave SchemaType inherit schema from metadata
Mike Bayer [Tue, 27 Apr 2021 17:09:04 +0000 (13:09 -0400)] 
have SchemaType inherit schema from metadata

Fixed very old issue where the :class:`_types.Enum` datatype would not
inherit the :paramref:`_schema.MetaData.schema` parameter of a
:class:`_schema.MetaData` object when that object were passed to the
:class:`_types.Enum` using :paramref:`_types.Enum.metadata`.

Fixes: #6373
Change-Id: Ie77d5e8cbc0bd7bfd0039fb60a4a0bde2df58ca9

4 years agoMerge "Pass all datetime values to pyodbc for timezone-naive column"
mike bayer [Tue, 27 Apr 2021 02:03:21 +0000 (02:03 +0000)] 
Merge "Pass all datetime values to pyodbc for timezone-naive column"

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 agoMerge "Handle Sequence in _process_multiparam_default_bind"
mike bayer [Mon, 26 Apr 2021 22:42:48 +0000 (22:42 +0000)] 
Merge "Handle Sequence in _process_multiparam_default_bind"

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 agoHandle Sequence in _process_multiparam_default_bind
Mike Bayer [Mon, 26 Apr 2021 17:30:29 +0000 (13:30 -0400)] 
Handle Sequence in _process_multiparam_default_bind

Fixed issue where usage of an explicit :class:`.Sequence` would produce
inconsistent "inline" behavior for an :class:`.Insert` construct that
includes multiple values phrases; the first seq would be inline but
subsequent ones would be "pre-execute", leading to inconsistent sequence
ordering. The sequence expressions are now fully inline.

Fixes: #6361
Change-Id: Ie16794ec0e19979a7e6c8d1bef5716a9fc199889

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