]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
3 years agoadd all the machine names in uppercase
Mike Bayer [Wed, 11 Aug 2021 22:24:59 +0000 (18:24 -0400)] 
add all the machine names in uppercase

windows seems to be returning the name in uppercase,
we might have to revert this whole thing if things
continue to not work

Change-Id: I365a07e3521f9f43a3d9d5f93da7788a8a052ff0

3 years agoMerge "limit greenlet dependency to pypi-listed platforms"
mike bayer [Wed, 11 Aug 2021 20:22:59 +0000 (20:22 +0000)] 
Merge "limit greenlet dependency to pypi-listed platforms"

3 years agoMerge "cx_oracle patches"
mike bayer [Wed, 11 Aug 2021 17:41:41 +0000 (17:41 +0000)] 
Merge "cx_oracle patches"

3 years agolimit greenlet dependency to pypi-listed platforms
Mike Bayer [Mon, 26 Jul 2021 22:06:41 +0000 (18:06 -0400)] 
limit greenlet dependency to pypi-listed platforms

The setup requirements have been modified such ``greenlet`` is a default
requirement only for those platforms that are well known for ``greenlet``
to be installable and for which there is already a pre-built binary on
pypi; the current list is ``x86_64 aarch64 ppc64le amd64 win32``. For other
platforms, greenlet will not install by default, which should enable
installation and test suite running of SQLAlchemy 1.4 on platforms that
don't support ``greenlet``, excluding any asyncio features. In order to
install with the ``greenlet`` dependency included on a machine architecture
outside of the above list, the ``[asyncio]`` extra may be included by
running ``pip install sqlalchemy[asyncio]`` which will then attempt to
install ``greenlet``.

Additionally, the test suite has been repaired so that tests can complete
fully when greenlet is not installed, with appropriate skips for
asyncio-related tests.

Fixes: #6136
Change-Id: I8f3a1c00a4a8b6a273484af1da1f7aaadf588ae7

3 years agoFix example with deprecated code 6875/head
João Sampaio [Wed, 11 Aug 2021 14:36:49 +0000 (11:36 -0300)] 
Fix example with deprecated code

Just a few lines above, it is said that creating a mapping with `mapper()` is deprecated in favor of `mapper_registry.map_imperatively()`. This PR fixes an example in the documentation that still uses the old function.

3 years agoMerge "create concise + deterministic cache key for unboundload.options"
mike bayer [Tue, 10 Aug 2021 01:36:24 +0000 (01:36 +0000)] 
Merge "create concise + deterministic cache key for unboundload.options"

3 years agoMerge "add columns_clause_froms and related use cases"
mike bayer [Mon, 9 Aug 2021 18:53:06 +0000 (18:53 +0000)] 
Merge "add columns_clause_froms and related use cases"

3 years agocreate concise + deterministic cache key for unboundload.options
Mike Bayer [Mon, 9 Aug 2021 18:43:53 +0000 (14:43 -0400)] 
create concise + deterministic cache key for unboundload.options

Fixed issue in loader strategies where the use of the
:meth:`_orm.Load.options` method, particularly when nesting multiple calls,
would generate an overly long and more importantly non-deterministic cache
key, leading to very large cache keys which were also not allowing
efficient cache usage, both in terms of total memory used as well as number
of entries used in the cache itself.

Fixes: #6869
Change-Id: I42bd3564d55a5fb95a21d0e7eef30d50c1274da0

4 years agoMerge "Dispatch independent ctes on compound select"
mike bayer [Sun, 8 Aug 2021 16:38:48 +0000 (16:38 +0000)] 
Merge "Dispatch independent ctes on compound select"

4 years agoDispatch independent ctes on compound select
Eric Masseran [Fri, 6 Aug 2021 08:11:09 +0000 (04:11 -0400)] 
Dispatch independent ctes on compound select

Fix issue in :class:`_sql.CTE` where new :meth:`_sql.HasCTE.add_cte` method
added in version 1.4.21 / :ticket:`6752` failed to function correctly for
"compound select" structures such as :func:`_sql.union`,
:func:`_sql.union_all`, :func:`_sql.except`, etc. Pull request courtesy
Eric Masseran.

Fixes: #6752
Closes: #6849
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6849
Pull-request-sha: 1c4b4d72b2789cf89ff5043ca964ebdd6c9a6617

Change-Id: I49a16a4fc2af8299502011f3a02d8a2ad93255e3

4 years agoMerge "dont qualify literal_binds with literal_execute"
mike bayer [Sat, 7 Aug 2021 18:56:11 +0000 (18:56 +0000)] 
Merge "dont qualify literal_binds with literal_execute"

4 years agoadd columns_clause_froms and related use cases
Mike Bayer [Fri, 23 Jul 2021 20:07:50 +0000 (16:07 -0400)] 
add columns_clause_froms and related use cases

Added new attribute :attr:`_sql.Select.columns_clause_froms` that will
retrieve the FROM list implied by the columns clause of the
:class:`_sql.Select` statement. This differs from the old
:attr:`_sql.Select.froms` collection in that it does not perform any ORM
compilation steps, which necessarily deannotate the FROM elements and do
things like compute joinedloads etc., which makes it not an appropriate
candidate for the :meth:`_sql.Select.select_from` method. Additionally adds
a new parameter
:paramref:`_sql.Select.with_only_columns.maintain_column_froms` that
transfers this collection to :meth:`_sql.Select.select_from` before
replacing the columns collection.

In addition, the :attr:`_sql.Select.froms` is renamed to
:meth:`_sql.Select.get_final_froms`, to stress that this collection is not
a simple accessor and is instead calculated given the full state of the
object, which can be an expensive call when used in an ORM context.

Additionally fixes a regression involving the
:func:`_orm.with_only_columns` function to support applying criteria to
column elements that were replaced with either
:meth:`_sql.Select.with_only_columns` or :meth:`_orm.Query.with_entities` ,
which had broken as part of :ticket:`6503` released in 1.4.19.

Fixes: #6808
Change-Id: Ib5d66cce488bbaca06dab4f68fb5cdaa73e8823e

4 years agoMerge "Refactor mypy plugin"
mike bayer [Sat, 7 Aug 2021 18:35:26 +0000 (18:35 +0000)] 
Merge "Refactor mypy plugin"

4 years agoRefactor mypy plugin
Bryan Forbes [Wed, 14 Jul 2021 19:00:11 +0000 (15:00 -0400)] 
Refactor mypy plugin

A major refactor of the mypy plugin

Closes: #6764
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6764
Pull-request-sha: 3e2295b2da7b57a6669f26db0df78f6409934184

Change-Id: I067d56dcfbc998ddd1b22a448f756859428b9e31

4 years agoMerge "Modernize tests - dml_values"
mike bayer [Sat, 7 Aug 2021 16:56:53 +0000 (16:56 +0000)] 
Merge "Modernize tests - dml_values"

4 years agoMerge "Add count example to 2.0 migration table"
mike bayer [Sat, 7 Aug 2021 16:52:52 +0000 (16:52 +0000)] 
Merge "Add count example to 2.0 migration table"

4 years agoMerge "Modernize tests - remaining core SQL"
mike bayer [Sat, 7 Aug 2021 16:48:06 +0000 (16:48 +0000)] 
Merge "Modernize tests - remaining core SQL"

4 years agoMerge "accommodate for untracked boundparam lambda in offline_string"
mike bayer [Sat, 7 Aug 2021 16:45:43 +0000 (16:45 +0000)] 
Merge "accommodate for untracked boundparam lambda in offline_string"

4 years agoMerge "Provide default for implicitly_named_constraints"
mike bayer [Sat, 7 Aug 2021 16:45:03 +0000 (16:45 +0000)] 
Merge "Provide default for implicitly_named_constraints"

4 years agodont qualify literal_binds with literal_execute
Mike Bayer [Sat, 7 Aug 2021 15:02:59 +0000 (11:02 -0400)] 
dont qualify literal_binds with literal_execute

this appears to be unnecessary and prevents end-user
literal_binds case from working.

Fixed issue where the ``literal_binds`` compiler flag, as used externally
to render bound parameters inline, would fail to work when used with a
certain class of parameters known as "literal_execute", which covers things
like LIMIT and OFFSET values for dialects where the drivers don't allow a
bound parameter, such as SQL Server's "TOP" clause.  The issue locally
seemed to affect only the MSSQL dialect.

Fixes: #6863
Change-Id: Ia74cff5b0107b129a11b9b965883552b2962e449

4 years agoaccommodate for untracked boundparam lambda in offline_string
Mike Bayer [Thu, 5 Aug 2021 23:17:07 +0000 (19:17 -0400)] 
accommodate for untracked boundparam lambda in offline_string

Fixed an issue in the ``CacheKey.to_offline_string()`` method used by the
dogpile.caching example where attempting to create a proper cache key from
the special "lambda" query generated by the lazy loader would fail to
include the parameter values, leading to an incorrect cache key.

Fixes: #6858
Change-Id: Ice27087583c6f3ff79cf7d5b879e5dd0a4e58158

4 years agoupdate local_session_caching.py example for 1.4
Mike Bayer [Thu, 5 Aug 2021 17:54:06 +0000 (13:54 -0400)] 
update local_session_caching.py example for 1.4

Fixes: #6858
Change-Id: I9b4113243f9ef32f27dcd1f7e9751923283eba2d

4 years agoProvide default for implicitly_named_constraints
Gord Thompson [Tue, 3 Aug 2021 21:55:52 +0000 (15:55 -0600)] 
Provide default for implicitly_named_constraints

… so third-party dialect testing won't fail with:

"AttributeError: 'Requirements' object has no
attribute 'implicitly_named_constraints'"

Change-Id: Iafa3e36f3dd169c338dd6eaee21c73aa35e854cc

4 years agocx_oracle patches
Mike Bayer [Thu, 29 Jul 2021 18:55:37 +0000 (14:55 -0400)] 
cx_oracle patches

provided by cx_oracle developers

Change-Id: Ie30b0993d0da2ee1359042816d77d08f762c6b13

4 years agoMerge "accommodate for cloned bindparams w/ maintain_key"
mike bayer [Thu, 29 Jul 2021 15:16:41 +0000 (15:16 +0000)] 
Merge "accommodate for cloned bindparams w/ maintain_key"

4 years agoMerge "Fix type"
mike bayer [Thu, 29 Jul 2021 15:15:44 +0000 (15:15 +0000)] 
Merge "Fix type"

4 years agoMerge "Support generics in code to allow Column[int] etc"
mike bayer [Thu, 29 Jul 2021 15:15:01 +0000 (15:15 +0000)] 
Merge "Support generics in code to allow Column[int] etc"

4 years agoaccommodate for cloned bindparams w/ maintain_key
Mike Bayer [Thu, 29 Jul 2021 14:10:28 +0000 (10:10 -0400)] 
accommodate for cloned bindparams w/ maintain_key

Fixed issue where a bound parameter object that was "cloned" would cause a
name conflict in the compiler, if more than one clone of this parameter
were used at the same time in a single statement. This could occur in
particular with things like ORM single table inheritance queries that
indicated the same "discriminator" value multiple times in one query.

Fixes: #6824
Change-Id: Iba7a786fc5a2341ff7d07fc666d24ed790ad4fe8

4 years agoSupport generics in code to allow Column[int] etc
Federico Caselli [Sat, 24 Jul 2021 17:17:49 +0000 (19:17 +0200)] 
Support generics in code to allow Column[int] etc

Fixes: #6804
Fixes: #6759
Change-Id: Ie7f32c38a22dbfa059b5709b883ff464b16031ae

4 years agoaccommodate plain core textual statements
Mike Bayer [Tue, 27 Jul 2021 15:35:41 +0000 (11:35 -0400)] 
accommodate plain core textual statements

Fixed issue where the horizontal sharding extension would not correctly
accommodate for a plain textual SQL statement passed to
:meth:`_orm.Session.execute`.

Fixes: #6816
Change-Id: Ie2b71b06d10793443dbd5e1b271c56cbf9431bb3

4 years agoModernize tests - dml_values
Gord Thompson [Mon, 26 Jul 2021 18:52:23 +0000 (12:52 -0600)] 
Modernize tests - dml_values

Change-Id: Ida86ed40c43d91813151621b847376976773a5f9

4 years agoModernize tests - dml_whereclause
Gord Thompson [Sun, 25 Jul 2021 19:16:31 +0000 (13:16 -0600)] 
Modernize tests - dml_whereclause

Fixed issue where the unit of work would internally use a 2.0-deprecated
SQL expression form, emitting a deprecation warning when SQLALCHEMY_WARN_20
were enabled.

Fixes: #6812
Change-Id: I0a031e728527a1c3382848b6ddc793939362b128

4 years agoNew issue templates forms
Federico Caselli [Mon, 26 Jul 2021 14:00:23 +0000 (10:00 -0400)] 
New issue templates forms

Noting fancy. we could add checkbox and/or dropdowns if needed

**To test**: to go my fork. Link https://github.com/CaselIT/sqlalchemy/issues/new/choose

See docs at
https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-issue-forms
https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema

Closes: #6809
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6809
Pull-request-sha: 21beb5a44104ced9e43bb5342a4cdf5f5efcb02a

Change-Id: I74c671aa2790b9f08c20b0659625c8a91b5b9c72

4 years agoAdd count example to 2.0 migration table
Federico Caselli [Sat, 24 Jul 2021 16:56:15 +0000 (18:56 +0200)] 
Add count example to 2.0 migration table

Also update some further load_only(str) left in the docs

Fixes: #6794
Change-Id: If3f0ef82a4cdcc8adceef55ab1b1a6a99f4f2a08

4 years agoModernize tests - remaining core SQL
Gord Thompson [Fri, 23 Jul 2021 17:54:14 +0000 (11:54 -0600)] 
Modernize tests - remaining core SQL

Change-Id: I7d8c1f451c32dea28173b2206e66db1d0927fccf

4 years agoAdd mypy tests on github.
Federico Caselli [Thu, 22 Jul 2021 20:32:28 +0000 (22:32 +0200)] 
Add mypy tests on github.

Support skipping mypy tests based on interpreter version

Change-Id: I98963318dbb2e7e097ad5518e0e4022349ca9779

4 years agoFix type
Kazantcev Andrey [Tue, 20 Jul 2021 10:56:02 +0000 (06:56 -0400)] 
Fix type

https://github.com/sqlalchemy/sqlalchemy2-stubs/pull/132#issuecomment-883159494

Closes: #6789
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6789
Pull-request-sha: 36e9075a8ee0ff699deea8ceef6e72ed4bc1d854

Change-Id: I87fe210b5d69c1e2500fb8e1440592ff44ceaacf

4 years agoVersion 1.4.23 placeholder
Mike Bayer [Thu, 22 Jul 2021 00:14:13 +0000 (20:14 -0400)] 
Version 1.4.23 placeholder

4 years ago- 1.4.22 rel_1_4_22
Mike Bayer [Wed, 21 Jul 2021 22:53:27 +0000 (18:53 -0400)] 
- 1.4.22

4 years agoApply new uniquing rules for future ORM selects
Mike Bayer [Wed, 21 Jul 2021 19:44:27 +0000 (15:44 -0400)] 
Apply new uniquing rules for future ORM selects

Fixed issue where usage of the :meth:`_result.Result.unique` method with an
ORM result that included column expressions with unhashable types, such as
``JSON`` or ``ARRAY`` using non-tuples would silently fall back to using
the ``id()`` function, rather than raising an error. This now raises an
error when the :meth:`_result.Result.unique` method is used in a 2.0 style
ORM query. Additionally, hashability is assumed to be True for result
values of unknown type, such as often happens when using SQL functions of
unknown return type; if values are truly not hashable then the ``hash()``
itself will raise.

For legacy ORM queries, since the legacy :class:`_orm.Query` object
uniquifies in all cases, the old rules remain in place, which is to use
``id()`` for result values of unknown type as this legacy uniquing is
mostly for the purpose of uniquing ORM entities and not column values.

Fixes: #6769
Change-Id: I5747f706f1e97c78867b5cf28c73360497273808

4 years agoMerge "Modernize tests - legacy_select"
mike bayer [Wed, 21 Jul 2021 21:23:37 +0000 (21:23 +0000)] 
Merge "Modernize tests - legacy_select"

4 years agoMerge "dont warn for dictionary passed positionally"
mike bayer [Wed, 21 Jul 2021 21:22:46 +0000 (21:22 +0000)] 
Merge "dont warn for dictionary passed positionally"

4 years agoModernize tests - legacy_select
Gord Thompson [Wed, 14 Jul 2021 15:56:18 +0000 (09:56 -0600)] 
Modernize tests - legacy_select

Change-Id: I04057cc3d3f93de60b02999803e2ba6a23cdf68d

4 years agodont warn for dictionary passed positionally
Mike Bayer [Tue, 20 Jul 2021 15:03:08 +0000 (11:03 -0400)] 
dont warn for dictionary passed positionally

Fixed issue where use of the :paramref:`_sql.case.whens` parameter passing
a dictionary positionally and not as a keyword argument would emit a 2.0
deprecation warning, referring to the deprecation of passing a list
positionally. The dictionary format of "whens", passed positionally, is
still supported and was accidentally marked as deprecated.

Removes warning filter for case statement.

Fixes: #6786
Change-Id: I8efd1882563773bec89ae5e34f0dfede77fc4683

4 years agoimplement cache key for return_defaults token
Mike Bayer [Wed, 21 Jul 2021 15:18:01 +0000 (11:18 -0400)] 
implement cache key for return_defaults token

Fixed critical caching issue where the ORM's persistence feature using
INSERT..RETURNING would cache an incorrect query when mixing the "bulk
save" and standard "flush" forms of INSERT.

Fixes: #6793
Change-Id: Ifeb61c1226d3fa6d5e1c2e29b6f5ff77a27d6a2d

4 years agoMerge "Documentation improvements"
mike bayer [Tue, 20 Jul 2021 19:19:26 +0000 (19:19 +0000)] 
Merge "Documentation improvements"

4 years agoDocumentation improvements
Federico Caselli [Tue, 13 Jul 2021 19:47:28 +0000 (21:47 +0200)] 
Documentation improvements

Also remove deprecated usage:
- load_only does not accept strings
- case.whens is positional only

Ref #6712
Ref #5994
Ref #6121
Ref #6785
Ref https://groups.google.com/g/sqlalchemy/c/-cnhThEu3kk

Change-Id: I5db49a075b9d3d332518b9d189a24b13b502e2af

4 years agoEncourage primary_key for secondary tables
Mike Bayer [Tue, 20 Jul 2021 13:17:17 +0000 (09:17 -0400)] 
Encourage primary_key for secondary tables

Change-Id: Ied56e52eaccf5d6dcb2729bdcf829f3ac4632f4c

4 years agoguard against unexpected weakref cleanups
Mike Bayer [Fri, 16 Jul 2021 15:34:13 +0000 (11:34 -0400)] 
guard against unexpected weakref cleanups

Added some guards against ``KeyError`` in the event system to accommodate
the case that the interpreter is shutting down at the same time
:meth:`_engine.Engine.dispose` is being called, which would cause stack
trace warnings.

Fixes: #6740
Change-Id: I2c42e9edac2371e68b39d8360494c5fddfd6cd8c

4 years agoMerge "apply list() around weakkeydictionary iteration"
mike bayer [Fri, 16 Jul 2021 15:17:23 +0000 (15:17 +0000)] 
Merge "apply list() around weakkeydictionary iteration"

4 years agoreset key/name when TableValuedColumn is adapted
Mike Bayer [Fri, 16 Jul 2021 14:14:56 +0000 (10:14 -0400)] 
reset key/name when TableValuedColumn is adapted

Fixed issue in new :meth:`_schema.Table.table_valued` method where the
resulting :class:`_sql.TableValuedColumn` construct would not respond
correctly to alias adaptation as is used throughout the ORM, such as for
eager loading, polymorphic loading, etc.

Fixes: #6775
Change-Id: I77cec4b6e1b1003f2b6be242b54ada8e4a435250

4 years agolimit None->null coercion to not occur with crud
Mike Bayer [Thu, 15 Jul 2021 15:25:31 +0000 (11:25 -0400)] 
limit None->null coercion to not occur with crud

Fixed issue where type-specific bound parameter handlers would not be
called upon in the case of using the :meth:`_sql.Insert.values` method with
the Python ``None`` value; in particular, this would be noticed when using
the :class:`_types.JSON` datatype as well as related PostgreSQL specific
types such as :class:`_postgresql.JSONB` which would fail to encode the
Python ``None`` value into JSON null, however the issue was generalized to
any bound parameter handler in conjunction with this specific method of
:class:`_sql.Insert`.

The issue with coercions forcing out ``null()`` may still impact
SQL expression usage as well; the change here is limited to crud
as the behavior there is relevant to some use cases, which may
need to be evaluated separately.

Fixes: #6770
Change-Id: If53edad811b37dada7578a89daf395628db058a6

4 years agoapply list() around weakkeydictionary iteration
Mike Bayer [Thu, 15 Jul 2021 14:36:53 +0000 (10:36 -0400)] 
apply list() around weakkeydictionary iteration

Fixed an issue where clearing of mappers during things like test suite
teardowns could cause a "dictionary changed size" warning during garbage
collection, due to iteration of a weak-referencing dictionary. A ``list()``
has been applied to prevent concurrent GC from affecting this operation.

Fixes: #6771
Change-Id: I3e1d67e978b2726a282d8b327457f2d4b239a0c6

4 years agoupdate case statement in dictlike-polymorphic
Mike Bayer [Thu, 15 Jul 2021 02:58:07 +0000 (22:58 -0400)] 
update case statement in dictlike-polymorphic

this was using a long-ago not working form of case().

Change-Id: I39c7cec2e46dd215d7acb7d3ee6debd30fa1ec34

4 years agoVersion 1.4.22 placeholder
Mike Bayer [Wed, 14 Jul 2021 20:57:29 +0000 (16:57 -0400)] 
Version 1.4.22 placeholder

4 years ago- 1.4.21 rel_1_4_21
Mike Bayer [Wed, 14 Jul 2021 20:50:15 +0000 (16:50 -0400)] 
- 1.4.21

4 years agoEnsure alias traversal block works when adapt_from_selectables present
Mike Bayer [Wed, 14 Jul 2021 14:29:50 +0000 (10:29 -0400)] 
Ensure alias traversal block works when adapt_from_selectables present

Fixed regression which appeared in version 1.4.3 due to :ticket:`6060`
where rules that limit ORM adaptation of derived selectables interfered
with other ORM-adaptation based cases, in this case when applying
adaptations for a :func:`_orm.with_polymorphic` against a mapping which
uses a :func:`_orm.column_property` which in turn makes use of a scalar
select that includes a :func:`_orm.aliased` object of the mapped table.

Fixes: #6762
Change-Id: Ice3dc34b97d12b59f044bdc0c5faaefcc4015227

4 years agotypo 6761/head
Leo Thorp [Wed, 14 Jul 2021 09:14:38 +0000 (04:14 -0500)] 
typo

4 years agochangelog updates
Mike Bayer [Tue, 13 Jul 2021 19:26:15 +0000 (15:26 -0400)] 
changelog updates

Change-Id: Ib21d015fda144204bdeaecd21f8af86a9b3b9e8e

4 years agoMerge "Modernize tests - union"
mike bayer [Tue, 13 Jul 2021 19:17:28 +0000 (19:17 +0000)] 
Merge "Modernize tests - union"

4 years agoMerge "Adjust CTE recrusive col list to accommodate dupe col names"
mike bayer [Tue, 13 Jul 2021 15:15:33 +0000 (15:15 +0000)] 
Merge "Adjust CTE recrusive col list to accommodate dupe col names"

4 years agoMerge "Extract format_constraint truncation rules to ON CONFLICT"
mike bayer [Tue, 13 Jul 2021 15:09:05 +0000 (15:09 +0000)] 
Merge "Extract format_constraint truncation rules to ON CONFLICT"

4 years agoAdjust CTE recrusive col list to accommodate dupe col names
Mike Bayer [Sat, 3 Jul 2021 23:48:55 +0000 (19:48 -0400)] 
Adjust CTE recrusive col list to accommodate dupe col names

Fixed issue in CTE constructs where a recursive CTE that referred to a
SELECT that has duplicate column names, which are typically deduplicated
using labeling logic in 1.4, would fail to refer to the deduplicated label
name correctly within the WITH clause.

As part of this change we are also attempting to remove the
behavior of SelectStatementGrouping forcing off the "asfrom"
contextual flag, which will have the result of additional labeling
being applied to some UNION and similar statements when they are
interpreted as subqueries.  To maintain compatibility with
"grouping", the Grouping/SelectStatementGrouping are now broken
out into two separate compiler cases, as the "asfrom" logic appears
to be tailored towards table valued SELECTS as column expressions.

Fixes: #6710
Change-Id: I8af07a5c670dbe5736cd9f16084ef82f5e4c8642

4 years agoMerge "labeling refactor"
mike bayer [Tue, 13 Jul 2021 14:25:13 +0000 (14:25 +0000)] 
Merge "labeling refactor"

4 years agoExtract format_constraint truncation rules to ON CONFLICT
Mike Bayer [Mon, 12 Jul 2021 22:19:08 +0000 (18:19 -0400)] 
Extract format_constraint truncation rules to ON CONFLICT

Fixed issue where a too-long constraint name rendered as part of the "ON
CONFLICT ON CONSTRAINT" element of the :class:`_postgresql.Insert`
construct due to naming convention generation would not correctly truncate
the name in the same way that it normally renders within a CREATE TABLE
statement, thus producing a non-matching and too-long constraint name.

Fixes: #6755
Change-Id: Ib27014a5ecbc9cd5861a396f8bb49fbc60bf49fe

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 agoModernize tests - union
Gord Thompson [Mon, 5 Jul 2021 17:17:13 +0000 (11:17 -0600)] 
Modernize tests - union

Change-Id: I2ccb714a249350f23e2b5f78f5f9ffb0d4f7efb0

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"