]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
4 years agoMerge "labeling refactor"
mike bayer [Tue, 13 Jul 2021 14:25:13 +0000 (14:25 +0000)] 
Merge "labeling refactor"

4 years agoMerge remote-tracking branch 'origin/pr/6751'
Mike Bayer [Tue, 13 Jul 2021 14:02:34 +0000 (10:02 -0400)] 
Merge remote-tracking branch 'origin/pr/6751'

Change-Id: Id8e5d7527eda6cae46e273e787d7dedbc4c02b9e

4 years agolabeling refactor
Mike Bayer [Tue, 6 Jul 2021 15:26:53 +0000 (11:26 -0400)] 
labeling refactor

To service #6718 and #6710, the system by which columns are
given labels in a SELECT statement as well as the system that
gives them keys in a .c or .selected_columns collection have
been refactored to provide a single source of truth for
both, in constrast to the previous approach that included
similar logic repeated in slightly different ways.

Main ideas:

1. ColumnElement attributes ._label, ._anon_label, ._key_label
   are renamed to include the letters "tq", meaning
   "table-qualified" - these labels are only used when rendering
   a SELECT that has LABEL_STYLE_TABLENAME_PLUS_COL for its
   label style; as this label style is primarily legacy, the
   "tq" names should be isolated so that in a 2.0 style application
   these aren't being used at all

2. The means by which the "labels" and "proxy keys" for the elements
   of a SELECT has been centralized to a single source of truth;
   previously, the three of _generate_columns_plus_names,
   _generate_fromclause_column_proxies, and _column_naming_convention
   all had duplicated rules between them, as well as that there
   were a little bit of labeling rules in compiler._label_select_column
   as well; by this we mean that the various "anon_label" "anon_key"
   methods on ColumnElement were called by all four of these methods,
   where there were many cases where it was necessary that one method
   comes up with the same answer as another of the methods.  This
   has all been centralized into _generate_columns_plus_names
   for all the names except the "proxy key", which is generated
   by _column_naming_convention.

3. compiler._label_select_column has been rewritten to both not make
   any naming decisions nor any "proxy key" decisions, only whether
   to label or not to label; the _generate_columns_plus_names method
   gives it the information, where the proxy keys come from
   _column_naming_convention; previously, these proxy keys were matched
   based on restatement of similar (but not really the same) logic in
   two places.   The heuristics of "whether to label or not to label"
   are also reorganized to be much easier to read and understand.

4. a new method compiler._label_returning_column is added for dialects
   to use in their "generate returning columns" methods.   A
   github search reveals a small number of third party dialects also
   doing this using the prior _label_select_column method so we
   try to make sure _label_select_column continues to work the
   exact same way for that specific use case; for the "SELECT" use
   case it now needs

5. After some attempts to do it different ways, for the case where
   _proxy_key is giving us some kind of anon label, we are hard
   changing it to "_no_label" right now, as there's not currently
   a way to fully match anonymized labels from stmt.c or
   stmt.selected_columns to what will be in the result map.  The
   idea of "_no_label" is to encourage the user to use label('name')
   for columns they want to be able to target by string name that
   don't have a natural name.

Change-Id: I7a92a66f3a7e459ccf32587ac0a3c306650daf11

4 years agoMerge "implement independent CTEs"
mike bayer [Mon, 12 Jul 2021 21:53:11 +0000 (21:53 +0000)] 
Merge "implement independent CTEs"

4 years agoMerge "Modernize tests - select(whereclause)"
mike bayer [Mon, 12 Jul 2021 21:52:09 +0000 (21:52 +0000)] 
Merge "Modernize tests - select(whereclause)"

4 years agoMerge "represent tablesample.sampling as FunctionElement in all cases"
mike bayer [Mon, 12 Jul 2021 21:48:50 +0000 (21:48 +0000)] 
Merge "represent tablesample.sampling as FunctionElement in all cases"

4 years agoimplement independent CTEs
Mike Bayer [Mon, 12 Jul 2021 18:28:19 +0000 (14:28 -0400)] 
implement independent CTEs

Added new method :meth:`_sql.HasCTE.add_cte` to each of the
:func:`_sql.select`, :func:`_sql.insert`, :func:`_sql.update` and
:func:`_sql.delete` constructs. This method will add the given
:class:`_sql.CTE` as an "independent" CTE of the statement, meaning it
renders in the WITH clause above the statement unconditionally even if it
is not otherwise referenced in the primary statement. This is a popular use
case on the PostgreSQL database where a CTE is used for a DML statement
that runs against database rows independently of the primary statement.

Fixes: #6752
Change-Id: Ibf635763e40269cbd10f4c17e208850d8e8d0188

4 years agoCorrect docs: pg8000 supports PostgreSQL UUID 6751/head
Tony Locke [Mon, 12 Jul 2021 16:39:52 +0000 (17:39 +0100)] 
Correct docs: pg8000 supports PostgreSQL UUID

4 years agoMerge "repair schema_translate_map for schema type use cases"
mike bayer [Mon, 12 Jul 2021 00:16:34 +0000 (00:16 +0000)] 
Merge "repair schema_translate_map for schema type use cases"

4 years agorepresent tablesample.sampling as FunctionElement in all cases
Mike Bayer [Sun, 11 Jul 2021 23:40:59 +0000 (19:40 -0400)] 
represent tablesample.sampling as FunctionElement in all cases

Fixed regression where the :func:`_sql.tablesample` construct would fail to
be executable when constructed given a floating-point sampling value not
embedded within a SQL function.

Fixes: #6735
Change-Id: I557bcd4bdbffc4329ad69d5659ba99b1c8deb554

4 years agorepair schema_translate_map for schema type use cases
Mike Bayer [Sun, 11 Jul 2021 23:23:40 +0000 (19:23 -0400)] 
repair schema_translate_map for schema type use cases

Fixed issue where the PostgreSQL ``ENUM`` datatype as embedded in the
``ARRAY`` datatype would fail to emit correctly in create/drop when the
``schema_translate_map`` feature were also in use. Additionally repairs a
related issue where the same ``schema_translate_map`` feature would not
work for the ``ENUM`` datatype in combination with a ``CAST``, that's also
intrinsic to how the ``ARRAY(ENUM)`` combination works on the PostgreSQL
dialect.

Fixes: #6739
Change-Id: I44b1ad4db4af3acbf639aa422c46c22dd3b0d3a6

4 years agoMerge "implement deferred scalarobject history load"
mike bayer [Sat, 10 Jul 2021 16:07:12 +0000 (16:07 +0000)] 
Merge "implement deferred scalarobject history load"

4 years agoMerge "Add additional support to honor _proxy_key in Core selects"
mike bayer [Fri, 9 Jul 2021 21:29:40 +0000 (21:29 +0000)] 
Merge "Add additional support to honor _proxy_key in Core selects"

4 years agoimplement deferred scalarobject history load
Mike Bayer [Fri, 2 Jul 2021 15:23:20 +0000 (11:23 -0400)] 
implement deferred scalarobject history load

Modified the approach used for history tracking of scalar object
relationships that are not many-to-one, i.e. one-to-one relationships that
would otherwise be one-to-many. When replacing a one-to-one value, the
"old" value that would be replaced is no longer loaded immediately, and is
instead handled during the flush process. This eliminates an historically
troublesome lazy load that otherwise often occurs when assigning to a
one-to-one attribute, and is particularly troublesome when using
"lazy='raise'" as well as asyncio use cases.

This change does cause a behavioral change within the
:meth:`_orm.AttributeEvents.set` event, which is nonetheless currently
documented, which is that the event applied to such a one-to-one attribute
will no longer receive the "old" parameter if it is unloaded and the
:paramref:`_orm.relationship.active_history` flag is not set. As is
documented in :meth:`_orm.AttributeEvents.set`, if the event handler needs
to receive the "old" value when the event fires off, the active_history
flag must be established either with the event listener or with the
relationship. This is already the behavior with other kinds of attributes
such as many-to-one and column value references.

The change additionally will defer updating a backref on the "old" value
in the less common case that the "old" value is locally present in the
session, but isn't loaded on the relationship in question, until the
next flush occurs.  If this causes an issue, again the normal
:paramref:`_orm.relationship.active_history` flag can be set to ``True``
on the relationship.

A private flag which restores the old value is retained for now,
as support within relevant test suites to exercise the old and
new behaviors together.  This is so that if the behavioral change
produces problems we have test harnesses set up to further examine these
behaviors.   The "legacy" style can go away in 2.0 or in a much later
1.4 release.

Fixes: #6708
Change-Id: Id7f72fc39dcbec9119b665e528667a9919bb73b4

4 years agoadd python 2.7 to pr workflow to help catch py3 only issues
Federico Caselli [Thu, 8 Jul 2021 21:28:49 +0000 (23:28 +0200)] 
add python 2.7 to pr workflow to help catch py3 only issues

Change-Id: If26b3c2ca84636859adc7623ec912f9e44cbbc3c

4 years agoDocs: fixed typo in "Cascades" 6726/head
Chris [Wed, 7 Jul 2021 01:12:00 +0000 (03:12 +0200)] 
Docs: fixed typo in "Cascades"

4 years agoAdd additional support to honor _proxy_key in Core selects
Mike Bayer [Mon, 5 Jul 2021 18:37:58 +0000 (14:37 -0400)] 
Add additional support to honor _proxy_key in Core selects

Fixed ORM regression where ad-hoc label names generated for hybrid
properties and potentially other similar types of ORM-enabled expressions
would usually be propagated outwards through subqueries, allowing the name
to be retained in the final keys of the result set even when selecting from
subqueries. Additional state is now tracked in this case that isn't lost
when a hybrid is selected out of a Core select / subquery.

as we have removed things like column.label() from
ORM, since we now have to export the cols with the same names
as what we will render, experiment with giving a greater role
to the _proxy_key annotation so that a desired name can be
carried through more transarently.

Fixes: #6718
Change-Id: Icb313244c13ea1a8f58d3e05d07aa3e1039e15bf

4 years agoModernize tests - select(whereclause)
Gord Thompson [Sun, 4 Jul 2021 21:56:40 +0000 (15:56 -0600)] 
Modernize tests - select(whereclause)

Change-Id: I306cfbea9920b35100e3087dcc21d7ffa6c39c55

4 years agoReplace all http:// links to https://
Federico Caselli [Sun, 4 Jul 2021 17:29:19 +0000 (19:29 +0200)] 
Replace all http:// links to https://

Also replace http://pypi.python.org/pypi with https://pypi.org/project

Change-Id: I84b5005c39969a82140706472989f2a30b0c7685

4 years agoModernize tests
Gord Thompson [Thu, 24 Jun 2021 18:16:32 +0000 (12:16 -0600)] 
Modernize tests

Eliminate engine.execute() and engine.scalar()

Change-Id: I99f76d0e615ddebab2da4fd07a40a0a2796995c7

4 years agoMerge "Update docs re: deprecated internal dialects"
mike bayer [Sat, 3 Jul 2021 21:56:09 +0000 (21:56 +0000)] 
Merge "Update docs re: deprecated internal dialects"

4 years agoMerge "Update link for mysql case sensitivity"
mike bayer [Sat, 3 Jul 2021 21:55:27 +0000 (21:55 +0000)] 
Merge "Update link for mysql case sensitivity"

4 years agoUpdate link for mysql case sensitivity
Gord Thompson [Sun, 27 Jun 2021 12:40:58 +0000 (06:40 -0600)] 
Update link for mysql case sensitivity

Change-Id: Ia4ff3e86d944bd5cfaa0ae2086b1d20fa027ba14

4 years agoMerge "Modernize tests - Connection.connect"
mike bayer [Sat, 3 Jul 2021 21:53:18 +0000 (21:53 +0000)] 
Merge "Modernize tests - Connection.connect"

4 years agoAdd Result to the link description in the docs index
Federico Caselli [Thu, 1 Jul 2021 21:16:24 +0000 (23:16 +0200)] 
Add Result to the link description in the docs index

Change-Id: Ic6d9e1c92e1f7a4bbfe4446ac063d033e8b0089c

4 years agoclear new Query._memoized_select_entities in _from_selectable
Mike Bayer [Wed, 30 Jun 2021 20:04:07 +0000 (16:04 -0400)] 
clear new Query._memoized_select_entities in _from_selectable

Fixed regression caused in 1.4.19 due to #6503 and related involving
:meth:`_orm.Query.with_entities` where the new structure used would be
inappropriately transferred to an enclosing :class:`_orm.Query` when making
use of set operations such as :meth:`_orm.Query.union`, causing the JOIN
instructions within to be applied to the outside query as well.

Fixes: #6698
Change-Id: Ia9f294215ebc01330d142a0a3e5be9d02be9380f

4 years agoEnsure compiler uses quote_schema hook for translates renders
Mike Bayer [Wed, 30 Jun 2021 14:52:09 +0000 (10:52 -0400)] 
Ensure compiler uses quote_schema hook for translates renders

Fixed regression where the special dotted-schema name handling for the SQL
Server dialect would not function correctly if the dotted schema name were
used within the ``schema_translate_map`` feature.

Fixes: #6697
Change-Id: Idb610755cbf8122e71223d5dd0a17fcb61b1b98d

4 years agoapply quoting to "ON CONSTRAINT" symbol
Mike Bayer [Wed, 30 Jun 2021 13:22:00 +0000 (09:22 -0400)] 
apply quoting to "ON CONSTRAINT" symbol

Fixed issue in :meth:`_postgresql.Insert.on_conflict_do_nothing` and
:meth:`_postgresql.Insert.on_conflict_do_update` where the name of a unique
constraint passed as the ``constraint`` parameter would not be properly
quoted if it contained characters which required quoting.

Fixes: #6696
Change-Id: I4ffca9b8c72cef4ed39e2de96831ccc11a620422

4 years agorewrite "one-to-one", again
Mike Bayer [Tue, 29 Jun 2021 23:22:20 +0000 (19:22 -0400)] 
rewrite "one-to-one", again

Use the term "collection" instead of "many" as the
"side" where "uselist=False" goes.  Clarify that
one-to-one is in many ways a convention.

Fixes: #6692
Change-Id: I2bc7b24c9f57747306fdcf4b6376ac7eb3bff78b

4 years agoUpdate docs re: deprecated internal dialects
Gord Thompson [Tue, 29 Jun 2021 20:22:42 +0000 (14:22 -0600)] 
Update docs re: deprecated internal dialects

Change-Id: I3d9432a03e133af312595cf0883ce81b05043665

4 years agoVersion 1.4.21 placeholder
Mike Bayer [Mon, 28 Jun 2021 20:36:16 +0000 (16:36 -0400)] 
Version 1.4.21 placeholder

4 years ago- 1.4.20 rel_1_4_20
Mike Bayer [Mon, 28 Jun 2021 20:29:28 +0000 (16:29 -0400)] 
- 1.4.20

4 years agochangelog typo fixes
Mike Bayer [Mon, 28 Jun 2021 20:28:37 +0000 (16:28 -0400)] 
changelog typo fixes

Change-Id: I66e16cf1a2321f9706a602e7683f767d37163010

4 years agoBe less fiscal regarding validators functions
MiÅ‚osz StypiÅ„ski [Thu, 24 Jun 2021 16:21:30 +0000 (12:21 -0400)] 
Be less fiscal regarding validators functions

Adjusted the check in the mapper for a callable object that is used as a
``@validates`` validator function or a ``@reconstructor`` reconstruction
function, to check for "callable" more liberally such as to accommodate
objects based on fundamental attributes like ``__func__`` and
``__call___``, rather than testing for ``MethodType`` / ``FunctionType``,
allowing things like cython functions to work properly. Pull request
courtesy MiÅ‚osz StypiÅ„ski.

Fixes: #6538
Closes: #6539
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6539
Pull-request-sha: ed1d7fe5c9386bab0416ff32095afc777c26b6ca

Change-Id: I8350558bc9a9ba58f43e48e12ce25a0b30e4d767

4 years agoMerge "Fix missing None handling of Table.prefixes"
mike bayer [Mon, 28 Jun 2021 15:06:57 +0000 (15:06 +0000)] 
Merge "Fix missing None handling of Table.prefixes"

4 years agoFix missing None handling of Table.prefixes
Kai Mueller [Thu, 24 Jun 2021 15:57:20 +0000 (11:57 -0400)] 
Fix missing None handling of Table.prefixes

Fixed issue where passing ``None`` for the value of
:paramref:`_schema.Table.prefixes` would not store an empty list, but
rather the constant ``None``, which may be unexpected by third party
dialects. The issue is revealed by a usage in recent versions of Alembic
that are passing ``None`` for this value. Pull request courtesy Kai
Mueller.

Fixes: #6685
Closes: #6672
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6672
Pull-request-sha: b79aca0ee4011b244978b35fed4c687ffbe56dc9

Change-Id: I758641c6fbde6f2607d074fecea7efa6728aeea0

4 years agoDon't require space after MySQL pk comment
Daniël van Eeden [Wed, 23 Jun 2021 14:00:43 +0000 (10:00 -0400)] 
Don't require space after MySQL pk comment

Made a small adjustment in the table reflection feature of the MySQL
dialect to accommodate for alternate MySQL-oriented databases such as TiDB
which include their own "comment" directives at the end of a constraint
directive within "CREATE TABLE" where the format doesn't have the
additional space character after the comment, in this case the TiDB
"clustered index" feature. Pull request courtesy Daniël van Eeden.

Fixes: #6659
Closes: #6660
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6660
Pull-request-sha: 98791a441b2e3d26aa7cef9d3e2907fac113e30f

Change-Id: I20d206e0cdb809e4c6997b87159edf41249f7cd9

4 years agoMerge "ensure with poly entities are also reconstituted for GC'ed AC"
mike bayer [Sat, 26 Jun 2021 23:03:00 +0000 (23:03 +0000)] 
Merge "ensure with poly entities are also reconstituted for GC'ed AC"

4 years agoModernize tests - Connection.connect
Gord Thompson [Sat, 26 Jun 2021 16:17:57 +0000 (10:17 -0600)] 
Modernize tests - Connection.connect

Change-Id: I61639dc2d7e7bcae6c53e2a15680b11fce3efa5d

4 years agoensure with poly entities are also reconstituted for GC'ed AC
Mike Bayer [Sat, 26 Jun 2021 20:40:09 +0000 (16:40 -0400)] 
ensure with poly entities are also reconstituted for GC'ed AC

Fixed regression in ORM regarding an internal reconstitution step for the
func:`_orm.with_polymorphic` construct, when the user-facing object is
garbage collected as the query is processed. The reconstitution was not
ensuring the sub-entities for the "polymorphic" case were handled, leading
to an ``AttributeError``.

Fixes: #6680
Change-Id: Id35b16d0f2aadb50b5a7385a21fa81b9d8a8325f

4 years agoset _render_for_subquery for legacy set ops
Mike Bayer [Fri, 25 Jun 2021 20:10:01 +0000 (16:10 -0400)] 
set _render_for_subquery for legacy set ops

Adjusted :meth:`_orm.Query.union` and similar set operations to be
correctly compatible with the new capabilities just added in
:ticket:`6661`, with SQLAlchemy 1.4.19, such that the SELECT statements
rendered as elements of the UNION or other set operation will include
directly mapped columns that are mapped as deferred; this both fixes a
regression involving unions with multiple levels of nesting that would
produce a column mismatch, and also allows the :func:`_orm.undefer` option
to be used at the top level of such a :class:`_orm.Query` without having to
apply the option to each of the elements within the UNION.

Fixes: #6678
Change-Id: Iba97ce7fd8a965499853256fd2eb7f61512db60f

4 years agoMerge "turn pg provision error into a warning"
mike bayer [Sat, 26 Jun 2021 19:07:42 +0000 (19:07 +0000)] 
Merge "turn pg provision error into a warning"

4 years agoturn pg provision error into a warning
Mike Bayer [Sat, 26 Jun 2021 13:55:00 +0000 (09:55 -0400)] 
turn pg provision error into a warning

We haven't had any real cases of the PG "cant drop tables"
condition since this error was first introduced; instead we
seem to get it for a non-critical query during pool reconnect
tests, and I have not been able to isolate what is causing it.
Therefore turn the error into a new class of warning that can
emit within the test suite without failing the test, so that
if we do get a real PG drop timeout, the warning will be there
to show us what the query was in which it was stuck.

Change-Id: I1a9b3c4f7a25b7b9c1af722a721fc44ad5575b0f

4 years agohave automap suppress overlaps warning for mapped secondary
Mike Bayer [Fri, 25 Jun 2021 20:51:50 +0000 (16:51 -0400)] 
have automap suppress overlaps warning for mapped secondary

Fixed regression in :mod:`sqlalchemy.ext.automap` extension such that the
use case of creating an explicit mapped class to a table that is also the
:paramref:`_orm.relationship.secondary` element of a
:func:`_orm.relationship` that automap will be generating would emit the
"overlaps" warnings introduced in 1.4 and discussed at :ref:`error_qzyx`.
While generating this case from automap is still subject to the same
caveats that the "overlaps" warning refers towards, as automap is intended
for more ad-hoc use cases, the condition which produces the warning is
disabled when a many-to-many relationship with this particular pattern is
generated.

Fixes: #6679
Change-Id: Ib3a53982b076ed4999b0d3235f84008b9e2f1cce

4 years agoAdd "impl" parameter to PickleType
jason3gb [Thu, 24 Jun 2021 16:11:04 +0000 (12:11 -0400)] 
Add "impl" parameter to PickleType

Add a impl parameter to :class:`_types.PickleType` constructor, allowing
any arbitary type to be used in place of the default implementation of
:class:`_types.LargeBinary`. Pull request courtesy jason3gb.

Fixes: #6646
Closes: #6657
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6657
Pull-request-sha: e49bcd368d1f71dba92225d8d6e3af2bbe7142f7

Change-Id: Ib79f3b0ebbc94393f673f5a5ba6558260083d0cf

4 years agoMerge "Fix typo in _warn_for_legacy_exec_format"
mike bayer [Thu, 24 Jun 2021 16:08:33 +0000 (16:08 +0000)] 
Merge "Fix typo in _warn_for_legacy_exec_format"

4 years agoMerge "Use Py_TPFLAGS_HAVE_GC for Row"
mike bayer [Thu, 24 Jun 2021 15:11:26 +0000 (15:11 +0000)] 
Merge "Use Py_TPFLAGS_HAVE_GC for Row"

4 years agoFix typo in _warn_for_legacy_exec_format
gordthompson [Thu, 24 Jun 2021 13:44:21 +0000 (07:44 -0600)] 
Fix typo in _warn_for_legacy_exec_format

Change-Id: Idc24b5ab4b5a25fcfb7115c5d7be4c2ece520674

4 years agoMerge "Add Executable to DefaultGenerator"
mike bayer [Thu, 24 Jun 2021 13:17:15 +0000 (13:17 +0000)] 
Merge "Add Executable to DefaultGenerator"

4 years agoUse Py_TPFLAGS_HAVE_GC for Row
Mike Bayer [Thu, 24 Jun 2021 13:12:31 +0000 (09:12 -0400)] 
Use Py_TPFLAGS_HAVE_GC for Row

Fixed an issue in the C extension for the :class:`_result.Row` class which
could lead to a memory leak in the unlikely case of a :class:`_result.Row`
object which referred to an ORM object that then was mutated to refer back
to the ``Row`` itself, creating a cycle. The Python C APIs for tracking GC
cycles has been added to the native :class:`_result.Row` implementation to
accommodate for this case.

Fixes: #5348
Change-Id: I3ac32012f29fbb59f8921cf2a124fa3a7ac5f0d1

4 years agoAdd Executable to DefaultGenerator
Mike Bayer [Wed, 23 Jun 2021 20:34:05 +0000 (16:34 -0400)] 
Add Executable to DefaultGenerator

Fixed the class hierarchy for the :class:`_schema.Sequence` and the more
general :class:`_schema.DefaultGenerator` base, as these are "executable"
as statements they need to include :class:`_sql.Executable` in their
hierarchy, not just :class:`_roles.StatementRole` as was applied
arbitrarily to :class:`_schema.Sequence` previously. The fix allows
:class:`_schema.Sequence` to work in all ``.execute()`` methods including
with :meth:`_orm.Session.execute` which was not working in the case that a
``do_orm_execute()`` handler was also established.

Fixes: #6668
Change-Id: I0d192258c7cbd1bce2552f9e748e8fdd680dc45f

4 years agoMerge "consider "*" col as textual ordered"
mike bayer [Wed, 23 Jun 2021 18:08:56 +0000 (18:08 +0000)] 
Merge "consider "*" col as textual ordered"

4 years agoconsider "*" col as textual ordered
Mike Bayer [Wed, 23 Jun 2021 12:50:48 +0000 (08:50 -0400)] 
consider "*" col as textual ordered

Fixed old issue where a :func:`_sql.select()` made against the token "*",
which then yielded exactly one column, would fail to correctly organize the
``cursor.description`` column name into the keys of the result object.

Fixes: #6665
Change-Id: Ie8c00f62998972ad4a19a750d2642d00fde006f6

4 years agoVersion 1.4.20 placeholder
Mike Bayer [Wed, 23 Jun 2021 01:30:40 +0000 (21:30 -0400)] 
Version 1.4.20 placeholder

4 years ago- 1.4.19 rel_1_4_19
Mike Bayer [Wed, 23 Jun 2021 01:22:33 +0000 (21:22 -0400)] 
- 1.4.19

4 years agorefer to undefer here
Mike Bayer [Wed, 23 Jun 2021 01:21:16 +0000 (21:21 -0400)] 
refer to undefer here

this is the option one might want to use to undefer
a deferred column into a subquery; the message here explains
that is not applicable in 1.4.

Change-Id: Iea6c48f69c540e11ff5c3f6c8c56cc5cf2bf257b

4 years agoMerge "apply render_schema_translates to identity insert directives"
mike bayer [Wed, 23 Jun 2021 01:02:48 +0000 (01:02 +0000)] 
Merge "apply render_schema_translates to identity insert directives"

4 years agoMerge "Add impl property to PostgreSQL / Oracle INTERVAL class"
mike bayer [Tue, 22 Jun 2021 22:49:52 +0000 (22:49 +0000)] 
Merge "Add impl property to PostgreSQL / Oracle INTERVAL class"

4 years agoMerge "Export deferred columns but not col props; fix CTE labeling"
mike bayer [Tue, 22 Jun 2021 22:05:35 +0000 (22:05 +0000)] 
Merge "Export deferred columns but not col props; fix CTE labeling"

4 years agoAdd impl property to PostgreSQL / Oracle INTERVAL class
MajorDallas [Tue, 22 Jun 2021 19:34:09 +0000 (15:34 -0400)] 
Add impl property to PostgreSQL / Oracle INTERVAL class

Fixed issue where the ``INTERVAL`` datatype on PostgreSQL and Oracle would
produce an ``AttributeError`` when used in the context of a comparison
operation against a ``timedelta()`` object. Pull request courtesy
MajorDallas.

Fixes: #6649
Closes: #6650
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6650
Pull-request-sha: dd217a975e5f0d3157e81c731791225b6a32889f

Change-Id: I773caf2673294fdb3c92b42895ad714e944d1bf8

4 years agoExport deferred columns but not col props; fix CTE labeling
Mike Bayer [Tue, 22 Jun 2021 17:27:18 +0000 (13:27 -0400)] 
Export deferred columns but not col props; fix CTE labeling

Refined the behavior of ORM subquery rendering with regards to deferred
columns and column properties to be more compatible with that of 1.3 while
also providing for 1.4's newer features. As a subquery in 1.4 does not make
use of loader options, including :func:`_orm.deferred`, a subquery that is
against an ORM entity with deferred attributes will now render those
deferred attributes that refer directly to mapped table columns, as these
are needed in the outer SELECT if that outer SELECT makes use of these
columns; however a deferred attribute that refers to a composed SQL
expression as we normally do with :func:`_orm.column_property` will not be
part of the subquery, as these can be selected explicitly if needed in the
subquery. If the entity is being SELECTed from this subquery, the column
expression can still render on "the outside" in terms of the derived
subquery columns. This produces essentially the same behavior as when
working with 1.3. However in this case the fix has to also make sure that
the ``.selected_columns`` collection of an ORM-enabled :func:`_sql.select`
also follows these rules, which in particular allows recursive CTEs to
render correctly in this scenario, which were previously failing to render
correctly due to this issue.

As part of this change the _exported_columns_iterator() method has been
removed and logic simplified to use ._all_selected_columns from any
SelectBase object where _exported_columns_iterator() was used before.
Additionally sets up UpdateBase to include ReturnsRows in its hierarchy;
the literal point of ReturnsRows was to be a common base for UpdateBase
and SelectBase so it was kind of weird it wasn't there.

Fixes: #6661
Fixed issue in CTE constructs mostly relevant to ORM use cases where a
recursive CTE against "anonymous" labels such as those seen in ORM
``column_property()`` mappings would render in the
``WITH RECURSIVE xyz(...)`` section as their raw internal label and not a
cleanly anonymized name.

Fixes: #6663
Change-Id: I26219d4d8e6c0915b641426e9885540f74fae4d2

4 years agoImprove regexp used by pymssql to parse db version
Federico Caselli [Mon, 21 Jun 2021 19:01:57 +0000 (21:01 +0200)] 
Improve regexp used by pymssql to parse db version

Made improvements to the server version regexp used by the pymssql
dialect to prevent a regexp overflow in case of an invalid version
string.

Fixes: #5557
Change-Id: Ia3e95a9f11f5a121d84474c97f6b122cf8d9c9cf

4 years agoMerge "Implement MySQL-specific MATCH"
mike bayer [Mon, 21 Jun 2021 22:30:31 +0000 (22:30 +0000)] 
Merge "Implement MySQL-specific MATCH"

4 years agoMerge "adjust patchfile from 6ca7c2eb"
mike bayer [Mon, 21 Jun 2021 22:30:06 +0000 (22:30 +0000)] 
Merge "adjust patchfile from 6ca7c2eb"

4 years agoapply render_schema_translates to identity insert directives
Mike Bayer [Mon, 21 Jun 2021 22:13:55 +0000 (18:13 -0400)] 
apply render_schema_translates to identity insert directives

Fixed bug where the "schema_translate_map" feature would fail to function
correctly in conjunction with an INSERT into a table that has an IDENTITY
column, where the value of the IDENTITY column were specified in the values
of the INSERT thus triggering SQLAlchemy's feature of setting IDENTITY
INSERT to "on"; it's in this directive where the schema translate map would
fail to be honored.

Fixes: #6658
Change-Id: I8235aa639dd465d038a2ad48e7a669f3e5c5c37c

4 years agoImplement MySQL-specific MATCH
Anton Kovalevich [Fri, 18 Jun 2021 14:33:48 +0000 (10:33 -0400)] 
Implement MySQL-specific MATCH

Added new construct :class:`_mysql.match`, which provides for the full
range of MySQL's MATCH operator including multiple column support and
modifiers. Pull request courtesy Anton Kovalevich.

Fixes: #6132
Closes: #6133
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6133
Pull-request-sha: dc6842f13688849a848e2ecbb81600e6edf8b3a9

Change-Id: I66bbfd7947aa2e43a031772e9b5ae238d94e5223

4 years agofurther fixes to test_options_entities_three
Mike Bayer [Mon, 21 Jun 2021 20:39:11 +0000 (16:39 -0400)] 
further fixes to test_options_entities_three

this needs to be on default dialect for consistent
rendering of "JOIN"

Change-Id: I0bd16d8ef8161e2deef7e9aff61f9ad02106f30d

4 years agoadjust patchfile from 6ca7c2eb
Mike Bayer [Mon, 21 Jun 2021 20:34:16 +0000 (16:34 -0400)] 
adjust patchfile from 6ca7c2eb

code formatting modified table.py such that the patchfile
would no longer apply and this was missed in review.

Change-Id: I0af91cf92baa79f196b4d9f3af1bab3bb0984a23

4 years agoMerge "accommodate no cls info found in _scan_declarative"
mike bayer [Mon, 21 Jun 2021 19:20:27 +0000 (19:20 +0000)] 
Merge "accommodate no cls info found in _scan_declarative"

4 years agoensure test has deterministic FROM rendering
Mike Bayer [Mon, 21 Jun 2021 17:08:59 +0000 (13:08 -0400)] 
ensure test has deterministic FROM rendering

test_options_entities_replaced_with_equivs_three did not
have deterministic FROM ordering, so adding an inner
join from user->address should ensure there's a single
FROM element that is a series of joins.

Change-Id: Ic78e14959699c8d2ae7b3c278f4d8ee1e3a2b590

4 years agoaccommodate no cls info found in _scan_declarative
Mike Bayer [Mon, 21 Jun 2021 16:52:42 +0000 (12:52 -0400)] 
accommodate no cls info found in _scan_declarative

Fixed issue in mypy plugin where class info for a custom declarative base
would not be handled correctly on a cached mypy pass, leading to an
AssertionError being raised.

Fixes: #6476
Change-Id: If78340673e6a4d16d8f7cf787ce3bdb02c8bd47b

4 years agoMerge "ensure greenlet_spawn propagates BaseException"
mike bayer [Sat, 19 Jun 2021 04:11:29 +0000 (04:11 +0000)] 
Merge "ensure greenlet_spawn propagates BaseException"

4 years agoMerge "Added netezza in external dialects in documentation"
mike bayer [Sat, 19 Jun 2021 03:46:07 +0000 (03:46 +0000)] 
Merge "Added netezza in external dialects in documentation"

4 years agoensure greenlet_spawn propagates BaseException
Mike Bayer [Fri, 18 Jun 2021 21:42:53 +0000 (17:42 -0400)] 
ensure greenlet_spawn propagates BaseException

Fixed bug in asyncio implementation where the greenlet adaptation system
failed to propagate ``BaseException`` subclasses, most notably including
``asyncio.CancelledError``, to the exception handling logic used by the
engine to invalidate and clean up the connection, thus preventing
connections from being correctly disposed when a task was cancelled.

Fixes: #6652
Change-Id: Id3809e6c9e7bced46a7a3b5a0d1906c4168dc4fc

4 years agoAdded netezza in external dialects in documentation
Abhishek Jog [Wed, 16 Jun 2021 19:15:24 +0000 (15:15 -0400)] 
Added netezza in external dialects in documentation

### Description
IBM Netezza Performance Server (aka Netezza, NPS) now has fully function SQLAlchemy dialect. Need to add it in SQLAlchemy 1.3 documentation.
This PR fixes https://github.com/sqlalchemy/sqlalchemy/issues/6609

### 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:

- [x] 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.
- [ ] 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!**

Fixes: #6610
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6610
Pull-request-sha: 2de51ff3887048e7df39e71b30b0e1824cfa0f56

Change-Id: I3a3f49981a4aaca0874bc2765cd782da61a258ef
(cherry picked from commit 86b64dddd46c3985f3d844dc8afb8d009a0aad1e)

4 years agoMerge "memoize current options and joins w with_entities/with_only_cols"
mike bayer [Fri, 18 Jun 2021 14:38:12 +0000 (14:38 +0000)] 
Merge "memoize current options and joins w with_entities/with_only_cols"

4 years agoFix typos in "Working with Related Objects" docs (#6651)
Samuel Cattini-Schultz [Thu, 17 Jun 2021 18:51:38 +0000 (04:51 +1000)] 
Fix typos in "Working with Related Objects" docs (#6651)

* Fix typo in "Working with Related Objects" docs

* Fix typo in "Working with Related Objects" docs

4 years agomemoize current options and joins w with_entities/with_only_cols
Mike Bayer [Tue, 15 Jun 2021 19:13:34 +0000 (15:13 -0400)] 
memoize current options and joins w with_entities/with_only_cols

Fixed further regressions in the same area as that of :ticket:`6052` where
loader options as well as invocations of methods like
:meth:`_orm.Query.join` would fail if the left side of the statement for
which the option/join depends upon were replaced by using the
:meth:`_orm.Query.with_entities` method, or when using 2.0 style queries
when using the :meth:`_sql.Select.with_only_columns` method. A new set of
state has been added to the objects which tracks the "left" entities that
the options / join were made against which is memoized when the lead
entities are changed.

Fixes: #6503
Fixes: #6253
Change-Id: I211b2af98b0b20d1263fb15dc513884dcc5de6a4

4 years agopin async scoping tests at python 3.7
Mike Bayer [Wed, 16 Jun 2021 17:15:16 +0000 (13:15 -0400)] 
pin async scoping tests at python 3.7

as it relies upon asyncio.current_task that's not in 3.6

Change-Id: I2b09295bf736811f260640102214a531c9b9e816

4 years agoImplement async_scoped_session
jason3gb [Wed, 16 Jun 2021 14:18:08 +0000 (10:18 -0400)] 
Implement async_scoped_session

Implemented :class:`_asyncio.async_scoped_session` to address some
asyncio-related incompatibilities between :class:`_orm.scoped_session` and
:class:`_asyncio.AsyncSession`, in which some methods (notably the
:meth:`_asyncio.async_scoped_session.remove` method) should be used with
the ``await`` keyword.

Fixes: #6583
Closes: #6603
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6603
Pull-request-sha: 0e8ef87dc824dcd83dca01641441afc453c8e07a

Change-Id: I9bfe56f8670302ff0015d9dc56c1e3ac5b92b118

4 years agoMerge "set autocommit for psycopg2 pre-ping"
mike bayer [Tue, 15 Jun 2021 18:49:39 +0000 (18:49 +0000)] 
Merge "set autocommit for psycopg2 pre-ping"

4 years agopg 13 is in CI
Mike Bayer [Tue, 15 Jun 2021 13:24:20 +0000 (09:24 -0400)] 
pg 13 is in CI

Change-Id: I9fc638995a7c49a3ca3bf3c439428cae95d3c7b9
References: #6637

4 years agoclarify one-to-one examples
Mike Bayer [Mon, 14 Jun 2021 14:33:14 +0000 (10:33 -0400)] 
clarify one-to-one examples

Fixes: #6580
Change-Id: I804cee4c8f8cdb2a4d79beda73c74eccd32b457f

4 years agoclarify relationship to aliased class criteria
Mike Bayer [Mon, 14 Jun 2021 14:26:28 +0000 (10:26 -0400)] 
clarify relationship to aliased class criteria

the AC itself has to be used in additional WHERE/ORDER BY
etc, not the original class.

Change-Id: I66a0086349257cb281940e743c0f45e6c2e9e282

4 years agodocument missing ColumnCollection methods
Mike Bayer [Mon, 14 Jun 2021 01:08:24 +0000 (21:08 -0400)] 
document missing ColumnCollection methods

add additional notes regarding the methods that are on this
object.

Fixes: #6629
Change-Id: I68446cb16cbfcef9af9c2998687b3b536607cf0d

4 years agoset autocommit for psycopg2 pre-ping
Mike Bayer [Fri, 11 Jun 2021 14:23:51 +0000 (10:23 -0400)] 
set autocommit for psycopg2 pre-ping

Fixed issue where the pool "pre ping" feature would implicitly start a
transaction, which would then interfere with custom transactional flags
such as PostgreSQL's "read only" mode when used with the psycopg2 driver.

Fixes: #6621
Change-Id: I29117c393e50c090cc2587efcccfe1e986738928

4 years agoVersion 1.4.19 placeholder
Mike Bayer [Thu, 10 Jun 2021 18:20:38 +0000 (14:20 -0400)] 
Version 1.4.19 placeholder

4 years ago- 1.4.18 rel_1_4_18
Mike Bayer [Thu, 10 Jun 2021 18:13:44 +0000 (14:13 -0400)] 
- 1.4.18

4 years agochangelog updates
Mike Bayer [Thu, 10 Jun 2021 18:13:07 +0000 (14:13 -0400)] 
changelog updates

Change-Id: I250e3e084ddb75b535913f9e0d7c219d64e35695

4 years agofix typo
Mike Bayer [Thu, 10 Jun 2021 14:18:11 +0000 (10:18 -0400)] 
fix typo

Change-Id: I3f5fcb1928051a1c2ac5e51917c95af086fb0380

4 years agoMerge "simplify relationship caching options"
mike bayer [Wed, 9 Jun 2021 14:02:04 +0000 (14:02 +0000)] 
Merge "simplify relationship caching options"

4 years agosimplify relationship caching options
Mike Bayer [Tue, 8 Jun 2021 19:43:13 +0000 (15:43 -0400)] 
simplify relationship caching options

Clarified the current purpose of the
:paramref:`_orm.relationship.bake_queries` flag, which in 1.4 is to enable
or disable "lambda caching" of statements within the "lazyload" and
"selectinload" loader strategies; this is separate from the more
foundational SQL query cache that is used for most statements.
Additionally, the lazy loader no longer uses its own cache for many-to-one
SQL queries, which was an implementation quirk that doesn't exist for any
other loader scenario. Finally, the "lru cache" warning that the lazyloader
and selectinloader strategies could emit when handling a wide array of
class/relationship combinations has been removed; based on analysis of some
end-user cases, this warning doesn't suggest any significant issue. While
setting ``bake_queries=False`` for such a relationship will remove this
cache from being used, there's no particular performance gain in this case
as using no caching vs. using a cache that needs to refresh often likely
still wins out on the caching being used side.

Fixes: #6072
Fixes: #6487
Change-Id: Ida61f09b837d3acdafa07344d7d747d7f3ab226a

4 years agoMerge "Propagate asyncio flag from the dialect to selected pool classes"
mike bayer [Wed, 9 Jun 2021 13:55:06 +0000 (13:55 +0000)] 
Merge "Propagate asyncio flag from the dialect to selected pool classes"

4 years agoPropagate asyncio flag from the dialect to selected pool classes
Federico Caselli [Thu, 3 Jun 2021 20:38:15 +0000 (22:38 +0200)] 
Propagate asyncio flag from the dialect to selected pool classes

Fixed an issue that presented itself when using the :class:`_pool.NullPool`
or the :class:`_pool.StaticPool` with an async engine. This mostly affected
the aiosqlite dialect.

Fixes: #6575
Change-Id: Ic1e27d99ffcb20ed4de82ea78f430a0f3b629d86

4 years agoMerge "restore adapter logic in ORM loading"
mike bayer [Tue, 8 Jun 2021 18:00:44 +0000 (18:00 +0000)] 
Merge "restore adapter logic in ORM loading"

4 years agorestore adapter logic in ORM loading
Mike Bayer [Mon, 7 Jun 2021 22:49:04 +0000 (18:49 -0400)] 
restore adapter logic in ORM loading

Fixed regression involving how the ORM would resolve a given mapped column
to a result row, where under cases such as joined eager loading, a slightly
more expensive "fallback" could take place to set up this resolution due to
some logic that was removed since 1.3. The issue could also cause
deprecation warnings involving column resolution to be emitted when using a
1.4 style query with joined eager loading.

In order to ensure we don't look up columns by string name in the ORM,
we've turned on future_result=True in all cases, which I thought was
already the assumption here, but apparently not.    That in turn
led to the issue that Session autocommit relies on close_with_result=True,
which is legacy result only.   This was also hard to figure out.
So a new exception is raised if one tries to use future_result=True
along with close_with_result, and the Session now has an explicit path
for "autocommit" that sets these flags to their legacy values.

This does leave the possibility of some of these fallback cases
emitting warnings for users using session in autocommit along with
joined inheritance and column properties, as this patch identifies
that joined inheritance + column properties produce the fallback
logic when looking up in the result via the adapted column, which
in those tests is actually a Label object that doesn't adapt
nicely.

Fixes: #6596
Change-Id: I107a47e873ae05ab50853bb00a9ea0e1a88d5aee

4 years agoMerge "Add note regarding encryption-related pragmas passed in the url in pysqlcipher."
mike bayer [Tue, 8 Jun 2021 13:12:52 +0000 (13:12 +0000)] 
Merge "Add note regarding encryption-related pragmas passed in the url in pysqlcipher."

4 years agoMerge "repair Join.is_derived_from() to not rely on simple identity"
mike bayer [Tue, 8 Jun 2021 13:07:19 +0000 (13:07 +0000)] 
Merge "repair Join.is_derived_from() to not rely on simple identity"

4 years agorepair Join.is_derived_from() to not rely on simple identity
Mike Bayer [Mon, 7 Jun 2021 21:47:07 +0000 (17:47 -0400)] 
repair Join.is_derived_from() to not rely on simple identity

Fixed issue where query production for joinedload against a complex left
hand side involving joined-table inheritance could fail to produce a
correct query, due to a clause adaption issue.

Fixes: #6595
Change-Id: Id4b839d52447cdc103b392dd8946c4cfa7a829e1

4 years agoAdd note regarding encryption-related pragmas
Federico Caselli [Mon, 7 Jun 2021 19:14:05 +0000 (21:14 +0200)] 
Add note regarding encryption-related pragmas
passed in the url in pysqlcipher.

Fixes: #6589
Change-Id: I86f93f84ef2bd374c4832a70e26e4901d024ed4b