]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
5 years agoVersion 1.3.14 placeholder
Mike Bayer [Wed, 22 Jan 2020 16:57:04 +0000 (11:57 -0500)] 
Version 1.3.14 placeholder

5 years ago- 1.3.13 rel_1_3_13
Mike Bayer [Wed, 22 Jan 2020 16:50:02 +0000 (11:50 -0500)] 
- 1.3.13

5 years agoClarify documentation for lazy_loaded_from
Mike Bayer [Wed, 22 Jan 2020 16:01:59 +0000 (11:01 -0500)] 
Clarify documentation for lazy_loaded_from

This attribute was never available in conjunction with
mapper options, and additionally the use of baked queries
in the lazy loader strategy prevent this attribute from
being reliably available within the before_compile hook
unless baked queries are turned off entirely.

Fixes: #5109
Change-Id: I5fa12c68463d20475e7470647a784efe846b8af7
(cherry picked from commit 8426f97cdb77076abddabbd2a755022e85b870e8)

5 years agoAdjust natural path to relationship's base mapper for aliased class also
Mike Bayer [Mon, 20 Jan 2020 17:41:22 +0000 (12:41 -0500)] 
Adjust natural path to relationship's base mapper for aliased class also

Fixed regression in loader options introduced in 1.3.0b3 via :ticket:`4468`
where the ability to create a loader option using
:meth:`.PropComparator.of_type` targeting an aliased entity that is an
inheriting subclass of the entity which the preceding relationship refers
to would fail to produce a matching path.   See also :ticket:`5082` fixed
in this same release which involves a similar kind of issue.

Fixes: #5107
Change-Id: I5c6717b925060c3f8da42190d1f00d05248befd8
(cherry picked from commit c9bf876d93b9389d6d3b619565f6da166bab5ec2)

5 years agoMerge "Adjust use_mapper_path rule for poly subclasses" into rel_1_3
mike bayer [Mon, 20 Jan 2020 20:20:29 +0000 (20:20 +0000)] 
Merge "Adjust use_mapper_path rule for poly subclasses" into rel_1_3

5 years agoAdjust use_mapper_path rule for poly subclasses
Mike Bayer [Mon, 13 Jan 2020 18:50:38 +0000 (13:50 -0500)] 
Adjust use_mapper_path rule for poly subclasses

We must change the approach from 2734439 as the information
loss is breaking subquery eager loading.

Move the adjustment into a deeper set of logic inside
of path_regsitry.  We can distinguish between a path
that will "naturally" build from an aliased entity
at the base, vs. one that will "naturally" build
on all raw mappers, based on if when we observe that
we are being given a with_polymorphic(), if the existing
parent path is already in progress or not.

In general, we prefer paths to have as much of the original
information as possible, and the "natural path" is supposed
to be where the loader lookup stuff happens.

Fixes: #5082
Change-Id: I3c0ee72993bae8a6f067bdef3dc9a57d83f64950
(cherry picked from commit 7cc2de880b0de2b127a54910761f357f3753c689)

5 years agoImprove regex parsing of CHECK constraints for PostgreSQL.
Gord Thompson [Thu, 19 Dec 2019 17:20:39 +0000 (12:20 -0500)] 
Improve regex parsing of CHECK constraints for PostgreSQL.

Fixed issue where the PostgreSQL dialect would fail to parse a reflected
CHECK constraint that was a boolean-valued function (as opposed to a
boolean-valued expression).

Fixes: #5039
Closes: #5044
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5044
Pull-request-sha: b6903c656422abf658c4cc88b8cd03291d3a50f8

Change-Id: I7d39b104a8ce346cb593d541c1b4e5eab88867f9
(cherry picked from commit d8ac1e9e6bfc931d2f14f9846d6924106f56b7e6)

5 years agoUpdate index.rst
Tom Nolan [Wed, 15 Jan 2020 21:47:57 +0000 (13:47 -0800)] 
Update index.rst

(cherry picked from commit 27234a1a7ff32f294936d1ec2591203c9701a246)

5 years agoRemove return statement in __init__.
Heckad [Sat, 4 Jan 2020 00:23:07 +0000 (03:23 +0300)] 
Remove return statement in __init__.

(cherry picked from commit b5bddb2ca17fe2e711b69205d9ed809dbfc77bfa)

5 years agoEstablish that contains_eager()->alias can be replaced by of_type
Mike Bayer [Tue, 14 Jan 2020 22:32:12 +0000 (17:32 -0500)] 
Establish that contains_eager()->alias can be replaced by of_type

One test in test_of_type was creating a cartesian product
because contains_eager() was used with "alias" to refer
to a with_polymorphic(), but the wp was not used with of_type(),
so the pathing did not know that additional entities were present.

while the docs indicate that of_type() should be used, there is no
reason to use "alias" when you are using of_type().   Attempts
to make this automatic don't work as the current usage contract
with "alias" is that the contains_eager() chain can continue
along in terms of the base entities, which is another example
of the implicit swapping of entities for an aliased version of
themselves that really should be entirely marked as deprecated
throughout 1.4 and removed in 2.0.

So instead, add test coverage for the of_type() versions of
things and begin to make the case that we can remove "alias"
entirely, where previously we thought we would only deprecate
the string form.

For the 1.3 backport we are also picking a little bit of the
lambda combinations improvements that landed in 217948f5c7 and for
some reason were not backported.

Fixes: #5096
Change-Id: Ia7b021c4044332ab3282267815f208da64410e95
(cherry picked from commit b54b6ff7c09d15cedec3d65b10cd383ef41f1fbc)

5 years agoAdd explanation of `polymorphic_identity` to docs
Eli [Tue, 29 Oct 2019 02:43:30 +0000 (19:43 -0700)] 
Add explanation of `polymorphic_identity` to docs

Fixes: #4951
Change-Id: I592063ffc7c9ffa0eff8bffd53f6ce407a551d15
(cherry picked from commit 295441bab3051e96e7651047acb02cabca9ac0f5)

5 years agoIntegrate mapper-level version_id_col with versioned_history
Mike Bayer [Fri, 10 Jan 2020 18:16:43 +0000 (13:16 -0500)] 
Integrate mapper-level version_id_col with versioned_history

as the versioned_history example supplies an integer version
counter for the purposes of generating an audit trail, this
counter is also suited to be used for optimistic concurrency
detection using the version_id_col feature.   Build upon
the test that was first added in ac54ba0f2d8df5a76b6852841b6b3321c0e6c0e2
to provide a flag and some basic documentation.

Fixes: #2861
Change-Id: I50236beae4c49b33ada8fdcc4c524273b4e21c75
(cherry picked from commit 48b37a062a26a41bd5c9243d2365a6c06a77a347)

5 years agoAlter unique bound parameter key on deserialize
Mike Bayer [Fri, 10 Jan 2020 15:30:13 +0000 (10:30 -0500)] 
Alter unique bound parameter key on deserialize

Fixed bug in sqlalchemy.ext.serializer where a unique
:class:`.BindParameter` object could conflict with itself if it were
present in the mapping itself, as well as the filter condition of the
query, as one side would be used against the non-deserialized version and
the other side would use the deserialized version.  Logic is added to
:class:`.BindParameter` similar to its "clone" method which will uniquify
the parameter name upon deserialize so that it doesn't conflict with its
original.

Fixes: #5086
Change-Id: Ie1edce137e92ac496c822831d038999be5d1fc2d
(cherry picked from commit 4b17d0306421cab9821125fb774d1ff89b36e77e)

5 years agoSet use_mapper_path=True for with_poly subentities
Mike Bayer [Tue, 7 Jan 2020 02:06:10 +0000 (21:06 -0500)] 
Set use_mapper_path=True for with_poly subentities

Fixed regression in joined eager loading introduced in 1.3.0b3 via
:ticket:`4468` where the ability to create a joined option across a
:func:`.with_polymorphic` into a polymorphic subclass using
:meth:`.RelationshipProperty.of_type` and then further along regular mapped
relationships would fail as the polymorphic subclass would not add itself
to the load path in a way that could be located by the loader strategy.  A
tweak has been made to resolve this scenario.

Fixes: #5082
Change-Id: I1c7b8d70ed94436c655e433bf34394b13d384c35
(cherry picked from commit 2734439fff953a7bb8aecdedb5f851441b5122e9)

5 years agoMerge "Fix QueryContext ref cycle on joinedload" into rel_1_3
mike bayer [Tue, 7 Jan 2020 01:53:06 +0000 (01:53 +0000)] 
Merge "Fix QueryContext ref cycle on joinedload" into rel_1_3

5 years agoSupport GenericFunction.name passed as a quoted_name
Mike Bayer [Mon, 6 Jan 2020 19:09:01 +0000 (14:09 -0500)] 
Support GenericFunction.name passed as a quoted_name

A function created using :class:`.GenericFunction` can now specify that the
name of the function should be rendered with or without quotes by assigning
the :class:`.quoted_name` construct to the .name element of the object.
Prior to 1.3.4, quoting was never applied to function names, and some
quoting was introduced in :ticket:`4467` but no means to force quoting for
a mixed case name was available.  Additionally, the :class:`.quoted_name`
construct when used as the name will properly register its lowercase name
in the function registry so that the name continues to be available via the
``func.`` registry.

Fixes: #5079
Change-Id: I0653ab8b16e75e628ce82dbbc3d0f77f8336c407
(cherry picked from commit a697fcc1cb87b5a4e4f0c70361bd598086f4210f)

5 years agoFix QueryContext ref cycle on joinedload
Carson Ip [Fri, 3 Jan 2020 22:09:20 +0000 (17:09 -0500)] 
Fix QueryContext ref cycle on joinedload

Avoid storing a reference to itself when dealing with create_eager_joins. Also fix a cheating test.

Fixes: #5071
Closes: #5072
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5072
Pull-request-sha: 75ebaf7c91e96d7567eb5760be713dc134c58763

Change-Id: I511ddc0979b46f7928217347199eca4b1d0b4a49
(cherry picked from commit 5ecb7732fb62d80adb4434bdd0e606e43aa14a98)

5 years agohappy new year
Mike Bayer [Wed, 1 Jan 2020 19:24:39 +0000 (14:24 -0500)] 
happy new year

Change-Id: I77ed4eb4ea52d96a571f4acc9e85e237c223e079

5 years agoSource base cleanups
Mike Bayer [Wed, 1 Jan 2020 15:51:15 +0000 (10:51 -0500)] 
Source base cleanups

in trying to apply 2020 copyright to files, the pre-commit
hooks complain about random file issues.

- remove old corrections.py utility, this had something to do
  with repairing refs in the sphinx docs

- run pre commit hooks on all files

- formatting adjustments to work around code formatting collisions
  (long import lines that zimports can't rewrite correctly)

- for 1.3, update conf.py with formatted version

Change-Id: I260744866f69e902eb93665c7c728ee94d3371a2
(cherry picked from commit 748bf710fdeeed327933a5e7c277c7f79f6053a6)

5 years agoFix DATETIMEOFFSET formatting to preserve fractional seconds.
Gord Thompson [Tue, 31 Dec 2019 17:42:09 +0000 (12:42 -0500)] 
Fix DATETIMEOFFSET formatting to preserve fractional seconds.

Fixed issue where a timezone-aware ``datetime`` value being converted to
string for use as a parameter value of a :class:`.mssql.DATETIMEOFFSET`
column was omitting the fractional seconds.

Fixes: #5045
Closes: #5046
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5046
Pull-request-sha: 99dc7b23f69b7b068795a02d20b88bf352c7dcd7

Change-Id: I971629466fe0675536bbdf55693f0c1821dfb3cc
(cherry picked from commit 0d316e42f0645283c222f050c403c9c8d20463ec)

5 years agoMerge "Fix test failures under Windows" into rel_1_3
mike bayer [Wed, 1 Jan 2020 00:18:40 +0000 (00:18 +0000)] 
Merge "Fix test failures under Windows" into rel_1_3

5 years agoRepair uncovered warning in persistnce.py; update versioning tests
Mike Bayer [Tue, 31 Dec 2019 16:53:07 +0000 (11:53 -0500)] 
Repair uncovered warning in persistnce.py; update versioning tests

Repaired a warning in the ORM flush process that was not covered by  test
coverage when deleting objects that use the "version_id" feature. This
warning is generally unreachable unless using a dialect that sets the
"supports_sane_rowcount" flag to False, which  is not typically the case
however is possible for some MySQL configurations as well as older Firebird
drivers, and likely some third party dialects.

As part of this change, we would like to establish that versionining-
related warnings are not expected to emit for the core set of
test-covered dialects, and if they are we would like the check for
warning emitted to be explicit, rather than an ignore.

Fixes: #5068
Change-Id: Iee097554e43cbb54ced1be056635809e67cf30d6
(cherry picked from commit 7210595a79cd33b3b0da48db2806856fe018f495)

5 years agoBump test_build_query numbers
Mike Bayer [Tue, 31 Dec 2019 18:01:59 +0000 (13:01 -0500)] 
Bump test_build_query numbers

Due to the decreased caching introduced in
 Ifd93856eba550483f95f9ae63d49f36ab068b85a, callcounts have risen
here however they did not pass the threshold in the review.
Bump them now instead.

Change-Id: Iac1dad695f25b8db2fdb0b6b1d5d9a0b183259b5
(cherry picked from commit 65428cf95023a462ec452d7c6a1a6aff7c4c20a4)

5 years agoFix test failures under Windows
Federico Caselli [Tue, 31 Dec 2019 01:29:33 +0000 (20:29 -0500)] 
Fix test failures under Windows

Fixed a few test failures which would occur on Windows due to SQLite file
locking issues, as well as some timing issues in connection pool related
tests; pull request courtesy Federico Caselli.

Note the pool related issues were fixed by Mike in
I1a7162e67912d22c135fa517b687a073f8fd9151 but are being ticketed
here.

Fixes: #4946
Closes: #5055
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5055
Pull-request-sha: 36925573aff828bbdd725a4fed5394e06c775a98

Change-Id: Ic53ec82f5d588d0e26a2d033a17c6109900d7f63
(cherry picked from commit f461d710f9f848029603cf76f7c26725afdea11e)

5 years agoNote time passage requirement for pool.invalidate()
Mike Bayer [Fri, 27 Dec 2019 19:10:36 +0000 (14:10 -0500)] 
Note time passage requirement for pool.invalidate()

For Windows, time.time() may only have 16 millisecond
accuracy, so invalidation routines which compare
the time.time() of invalidate() to the time.time() when
the ConnectionRecord last connected may fail in a unit test
environment that does not pause at least this much time
since the ConnectionRecord startup.  Using >= for comparison
instead of > was considered but this only leads to more confusing
results as the ConnecitonRecord goes into a re-connect loop
as time continues to not pass.

Overall, while using routines such as Python 3.7's time_ns()
might be helpful, for now make sure tests which rely on this
are marked under timing intensive and add small sleeps.

Change-Id: I1a7162e67912d22c135fa517b687a073f8fd9151
(cherry picked from commit f1a22596e2283371f2216245ac4b7ff9a0fb6a9a)

5 years agoMerge "Test for short term reference cycles and resolve as many as possible" into...
mike bayer [Tue, 31 Dec 2019 01:10:34 +0000 (01:10 +0000)] 
Merge "Test for short term reference cycles and resolve as many as possible" into rel_1_3

5 years agoMerge "Include GROUP BY in _should_nest_selectable criteria" into rel_1_3
mike bayer [Tue, 31 Dec 2019 01:04:56 +0000 (01:04 +0000)] 
Merge "Include GROUP BY in _should_nest_selectable criteria" into rel_1_3

5 years agoFix newly found rst issue
Mike Bayer [Tue, 31 Dec 2019 01:01:23 +0000 (20:01 -0500)] 
Fix newly found rst issue

Likely due to new versions flake8-rst-docstrings or similar,
repair an incorrectly formatted code example in a doc string
causing all the gerrits to fail.

Change-Id: Ib2b242f435005a9e075315881c30c4a599d322e7

5 years agoTest for short term reference cycles and resolve as many as possible
Mike Bayer [Fri, 27 Dec 2019 20:02:31 +0000 (15:02 -0500)] 
Test for short term reference cycles and resolve as many as possible

Added test support and repaired a wide variety of unnecessary reference
cycles created for short-lived objects, mostly in the area of ORM queries.

For the 1.3 backport, includes the prefix_anon_map() optimization
from 1.4 / master which inlines the anonymous symbol generation
into a single object.   This removes a cycle from the compiler
that otherwise results in a signficantly higher number of
unreachable cycles.

Fixes: #5056
Change-Id: Ifd93856eba550483f95f9ae63d49f36ab068b85a
(cherry picked from commit 492930ed572de5f5550d514bc2ca52a57f108350)

5 years agoInclude GROUP BY in _should_nest_selectable criteria
Mike Bayer [Mon, 30 Dec 2019 18:08:17 +0000 (13:08 -0500)] 
Include GROUP BY in _should_nest_selectable criteria

Fixed bug where usage of joined eager loading would not properly wrap the
query inside of a subquery when :meth:`.Query.group_by` were used against
the query.   When any kind of result-limiting approach is used, such as
DISTINCT, LIMIT, OFFSET, joined eager loading embeds the row-limited query
inside of a subquery so that the collection results are not impacted.   For
some reason, the presence of GROUP BY was never included in this criterion,
even though it has a similar effect as using DISTINCT.   Additionally, the
bug would prevent using GROUP BY at all for a joined eager load query for
most database platforms which forbid non-aggregated, non-grouped columns
from being in the query, as the additional columns for the joined eager
load would not be accepted by the database.

Fixes: #5065
Change-Id: I9a2ed8196f83297ec38012138d1a5acdf9e88155
(cherry picked from commit 2d5fa22c7d53ff8109d47ba5ae4fe3b9849ddd09)

5 years agoMerge "Fix WeakSequence circular reference" into rel_1_3
mike bayer [Sun, 29 Dec 2019 16:08:09 +0000 (16:08 +0000)] 
Merge "Fix WeakSequence circular reference" into rel_1_3

5 years agoImprove two phase transaction requirement detection for PG
Federico Caselli [Sun, 29 Dec 2019 02:23:23 +0000 (21:23 -0500)] 
Improve two phase transaction requirement detection for PG

Improved detection of two phase transactions requirement for the PostgreSQL
database by testing that max_prepared_transactions is set to a value
greater than 0.  Pull request courtesy Federico Caselli.

Fixes: #5057
Closes: #5059
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5059
Pull-request-sha: c30c3b1a5216d281db84f9fa48466edaf7a26d1e

Change-Id: I4360f62eacdf1173172ee24cd05a68e9a448290c
(cherry picked from commit 92fd25f3e1f69b6fbdc3b2bbd81508a01a2668b3)

5 years agoFix WeakSequence circular reference
Carson Ip [Fri, 27 Dec 2019 17:05:30 +0000 (12:05 -0500)] 
Fix WeakSequence circular reference

Fixed a reference cycle which could impact the GC behavior of the
:class:`.WeakSequence` object, currently used within one place in certain
mapper configurations.  The issue only affects configuration-time
structures. Pull request courtesy Carson Ip.

Fixes: #5050
Closes: #5051
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5051
Pull-request-sha: db672f45f4f139722edd2dcc6b0c19892725c9de

Change-Id: I72673a33e655c44b68283ec1a2d7358b904e90ae
(cherry picked from commit f7a7af70c4f6f07011fa2d521fb1560917896427)

5 years agoCopy bind_processors when altering for expanding IN
Mike Bayer [Fri, 20 Dec 2019 16:40:10 +0000 (11:40 -0500)] 
Copy bind_processors when altering for expanding IN

Fixed issue where the collection of value processors on a
:class:`.Compiled` object would be mutated when "expanding IN" parameters
were used with a datatype that has bind value processors; in particular,
this would mean that when using statement caching and/or baked queries, the
same compiled._bind_processors collection would be mutated concurrently.
Since these processors are the same function for a given bind parameter
namespace every time, there was no actual negative effect of this issue,
however, the execution of a :class:`.Compiled` object should never be
causing any changes in its state, especially given that they are intended
to be thread-safe and reusable once fully constructed.

Fixes: #5048
Change-Id: I876d16bd7484eb05ce590397420552ac36da6e52
(cherry picked from commit ee961ce5778348fba8287e3192fe8848badf8456)

5 years agoMerge "Don't apply aliasing + adaption for simple relationship joins" into rel_1_3
mike bayer [Thu, 19 Dec 2019 18:29:52 +0000 (18:29 +0000)] 
Merge "Don't apply aliasing + adaption for simple relationship joins" into rel_1_3

5 years agoDon't apply aliasing + adaption for simple relationship joins
Mike Bayer [Thu, 19 Dec 2019 02:50:24 +0000 (21:50 -0500)] 
Don't apply aliasing + adaption for simple relationship joins

Identified a performance issue in the system by which a join is constructed
based on a mapped relationship.   The clause adaption system would be used
for the majority of join expressions including in the common case where no
adaptation is needed.   The conditions under which this adaptation occur
have been refined so that average non-aliased joins along a simple
relationship without a "secondary" table use about 70% less function calls.

Change-Id: Ifbe04214576e5a9fac86ca80c1dc7145c27cd50a
(cherry picked from commit 7e9f273835ac68df894568ba4292bfbc74ce187b)

5 years agoMerge "Add CTE prefixes" into rel_1_3
mike bayer [Thu, 19 Dec 2019 15:21:38 +0000 (15:21 +0000)] 
Merge "Add CTE prefixes" into rel_1_3

5 years agoImprove documentation for refresh_flush event
Mike Bayer [Thu, 19 Dec 2019 14:19:53 +0000 (09:19 -0500)] 
Improve documentation for refresh_flush event

This event does not include INSERTed primary key columns
and additionally will always be limited to default/onupdate
columns.    Note better choices for interception of INSERT
events.

Change-Id: I22b71ca1b336d4b098af075cc4694c55387b64f3
(cherry picked from commit 944fa6952157651faae53a12a92782b4265ddc8d)

5 years agoAdd pass through exact pyodbc connection string.
Gord Thompson [Wed, 4 Dec 2019 10:47:24 +0000 (03:47 -0700)] 
Add pass through exact pyodbc connection string.

(cherry picked from commit 565a56153149f0d27934abf1bc1a7fa81e59c484)

5 years agoAdd note re: pyodbc keywords in lowercase.
Gord Thompson [Wed, 4 Dec 2019 00:02:19 +0000 (17:02 -0700)] 
Add note re: pyodbc keywords in lowercase.

(cherry picked from commit 511964302467140a25fb50c68a1c96d24a079b80)

5 years agoAdd CTE prefixes
Marat Sharafutdinov [Wed, 18 Dec 2019 15:39:59 +0000 (10:39 -0500)] 
Add CTE prefixes

Added support for prefixes to the :class:`.CTE` construct, to allow
support for Postgresql 12 "MATERIALIZED" and "NOT MATERIALIZED" phrases.
Pull request courtesy Marat Sharafutdinov.

Fixes: #5040
Closes: #5043
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5043
Pull-request-sha: d1b9059a0b6dae8dc2479ac670999b4af07908e0

Change-Id: I2e9cb5d7f85961ec98ee51965de5b3ec4a97be2f
(cherry picked from commit f8c562c4f8def3b104d157d9f39d0e11f7d9fd8d)

5 years ago"does not support reflection" -> "does not support nullable booleans"
Mike Bayer [Tue, 17 Dec 2019 14:57:30 +0000 (09:57 -0500)] 
"does not support reflection" -> "does not support nullable booleans"

Change-Id: Icf00f9250ffe45413369a6bb2c2910da42c017ee
(cherry picked from commit 051c2fde4c3b4bf7edcaa7578c0b1420986aaf0c)

5 years agoVersion 1.3.13 placeholder
Mike Bayer [Mon, 16 Dec 2019 18:39:52 +0000 (13:39 -0500)] 
Version 1.3.13 placeholder

5 years ago- 1.3.12 rel_1_3_12
Mike Bayer [Mon, 16 Dec 2019 18:32:33 +0000 (13:32 -0500)] 
- 1.3.12

5 years agoAdd dialect for Apache Solr
Ahmed Adel [Tue, 3 Dec 2019 07:06:20 +0000 (09:06 +0200)] 
Add dialect for Apache Solr

(cherry picked from commit 6e873b299949f530eca0bff12feb798ff15ba89e)

5 years agoClose connection if begin fails
Mike Bayer [Fri, 13 Dec 2019 17:44:23 +0000 (12:44 -0500)] 
Close connection if begin fails

Fixed issue where by if the "begin" of a transaction failed at the Core
engine/connection level, such as due to network error or database is locked
for some transactional recipes, within the context of the :class:`.Session`
procuring that connection from the connection pool and then immediately
returning it, the ORM :class:`.Session` would not close the connection
despite this connection not being stored within the state of that
:class:`.Session`.  This would lead to the connection being cleaned out by
the connection pool weakref handler within garbage collection which is an
unpreferred codepath that in some special configurations can emit errors in
standard error.

Fixes: #5034
Change-Id: I6502a55791d86845f34bc10889c218f00765dfdc
(cherry picked from commit ff471152b62f71accda62d9ede87e0107b8a8bcb)

5 years agoUse label reference coercion for select() distinct keyword argument
Mike Bayer [Fri, 6 Dec 2019 16:38:55 +0000 (11:38 -0500)] 
Use label reference coercion for select() distinct keyword argument

Fixed bug where "distinct" keyword passed to :func:`.select` would not
treat a string value as a "label reference" in the same way that the
:meth:`.select.distinct` does; it would instead raise unconditionally. This
keyword argument and the others passed to :func:`.select` will ultimately
be deprecated for SQLAlchemy 2.0.

Fixes: #5028
Change-Id: Id36cfe477ed836c3248824ce1b81d0016dbe99f4
(cherry picked from commit 926952c4afe0b2e16c4a74f05958bded7b932760)

5 years agoInclude DISTINCT in error message for label reference
Mike Bayer [Fri, 6 Dec 2019 15:24:25 +0000 (10:24 -0500)] 
Include DISTINCT in error message for label reference

Needed to add tests to ensure this label reference is handled
correctly, so also modified the exception message to
be more clear if someone has this error within distinct().

Change-Id: I6e685e46ae336596272d14366445ac224c18d92c
(cherry picked from commit 55f66e430d18b8daa51121cbc18537e2dab1ad9f)

5 years agoIntroduce lambda combinations
Mike Bayer [Thu, 5 Dec 2019 00:18:57 +0000 (19:18 -0500)] 
Introduce lambda combinations

As the ORM's combinatoric tests mostly use entities and
table metadata that's defined in fixtures, we can't use
@testing.combinations directly as it takes place at the
module level.   Instead we use lambdas, but to reduce
verbosity we use a code replacement so that the namespace
of the lambda can be provided at runtime rather than
module import time.

Change-Id: Ia63a510f9c1d08b055eef62cf047f1f427f0450c
(cherry picked from commit 1ab483ac5481cb60e898f0bfdad54e5ca45bbb80)

5 years agoSkip sub-minute timezone tests for Python 3 < 3.7
Mike Bayer [Mon, 2 Dec 2019 16:47:08 +0000 (11:47 -0500)] 
Skip sub-minute timezone tests for Python 3 < 3.7

The datetime.timezone class as of Python 3.7, or SQLAlchemy's port for Python
2, supports seconds and microseconds.  For Python 3.6 and earlier, it is not
supported.

Fixes: #5016
Change-Id: Ia347d5a9958c0fa53317b2e340162e2009667bc2
(cherry picked from commit 380f4389922004589bfa7cb4f9b8c8208aa68659)

5 years agoMerge "Add DATETIMEOFFSET support for mssql+pyodbc" into rel_1_3
mike bayer [Sat, 30 Nov 2019 18:32:10 +0000 (18:32 +0000)] 
Merge "Add DATETIMEOFFSET support for mssql+pyodbc" into rel_1_3

5 years agoAdd DATETIMEOFFSET support for mssql+pyodbc
Gord Thompson [Tue, 26 Nov 2019 14:57:48 +0000 (09:57 -0500)] 
Add DATETIMEOFFSET support for mssql+pyodbc

Repaired support for the :class:`.mssql.DATETIMEOFFSET` datatype on PyODBC,
by adding PyODBC-level result handlers as it does not include native
support for this datatype.  This includes usage of the Python 3 "timezone"
tzinfo subclass in order to set up a timezone, which on Python 2 makes
use of a minimal backport of "timezone" in sqlalchemy.util.

Fixes: #4983
Closes: #4986
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4986
Pull-request-sha: e3a5a8dda01c7580dc93271092c4f9beaac4be11

Change-Id: Ia4c7c0d1971c6c0492515bd5fa0b1799f07fee1c
(cherry picked from commit f521577f6e1ebc8029b4395a3bff6783522ae8b8)

5 years agoGracefully degrade for SQLite JSON receiving direct numeric value
Mike Bayer [Fri, 29 Nov 2019 15:50:44 +0000 (10:50 -0500)] 
Gracefully degrade for SQLite JSON receiving direct numeric value

Fixed issue to workaround SQLite's behavior of assigning "numeric" affinity
to JSON datatypes, first described at :ref:`change_3850`, which returns
scalar numeric JSON values as a number and not as a string that can be JSON
deserialized.  The SQLite-specific JSON deserializer now gracefully
degrades for this case as an exception and bypasses deserialization for
single numeric values, as from a JSON perspective they are already
deserialized.

Also adds a combinatoric fixture for JSON single values within
the dialect-general test suite.

Fixes: #5014
Change-Id: Id38221dce1271fec527ca198b23908547b25d8a0
(cherry picked from commit bb338b91752f4f758edd9b2549a228e891596ae0)

5 years agoDon't clear metadata in TablesTest setup
Mike Bayer [Tue, 26 Nov 2019 16:09:00 +0000 (11:09 -0500)] 
Don't clear metadata in TablesTest setup

Some upcoming commits will make use of @metadata_fixture
within a TablesTest class.  As the fixture takes place before
setup, remove anything in setup that would interfere with it.

Change-Id: I4f16889c4c02cb2835dcf4886eb09ece848d8109
References: I507bc405eee6cae2c5991345d0eac53a37fe7512
(cherry picked from commit d9e43c518f90c0a79c05d7e6ea2559aef5157f52)

5 years agoGeneralize DescriptorProps.uses_objects
Mike Bayer [Sat, 23 Nov 2019 17:25:20 +0000 (12:25 -0500)] 
Generalize DescriptorProps.uses_objects

Previously, uses_objects was specific to the SynonymAttribute;
generalize it so that it defaults to False for other DescriptorProps.
Immediate fix is against CompositeProperty.

Fixed regression introduced in 1.3.0 related to the association proxy
refactor in :ticket:`4351` that prevented :func:`.composite` attributes
from working in terms of an association proxy that references them.

Add test coverage for association proxies that refer to Composite
attributes as endpoints.

Fixes: #5000
Change-Id: Iea6fb1bd3314d861a9bc22491b0ae1e6c5e6340d
(cherry picked from commit c2432d9d190bdc67f274b8da9296ff9ed044bef1)

5 years agoWarn for settings that don't work with viewonly=True
Mike Bayer [Wed, 20 Nov 2019 17:15:57 +0000 (12:15 -0500)] 
Warn for settings that don't work with viewonly=True

Setting persistence-related flags on :func:`.relationship` while also
setting viewonly=True will now emit a regular warning, as these flags do
not make sense for a viewonly=True relationship.   In particular, the
"cascade" settings have their own warning that is generated based on the
individual values, such as "delete, delete-orphan", that should not apply
to a viewonly relationship.   Note however that in the case of "cascade",
these settings are still erroneously taking effect even though the
relationship is set up as "viewonly".   In 1.4, all persistence-related
cascade settings will be disallowed on a viewonly=True relationship in
order to resolve this issue.

Fixes: #4993
Change-Id: I4b607a96a7de2ffa15303a27fd93c162a681556d
(cherry picked from commit 22d1f0706bd6a6742ad13f0bec75b04e705ff46b)

5 years agoDon't raise w/ raiseload strategy for many-to-one history in flush
Mike Bayer [Fri, 22 Nov 2019 15:27:02 +0000 (10:27 -0500)] 
Don't raise w/ raiseload strategy for many-to-one history in flush

Fixed issue involving ``lazy="raise"`` strategy where an ORM delete of an
object would raise for a simple "use-get" style many-to-one relationship
that had lazy="raise" configured.  This is inconsistent vs. the change
introduced in 1.3 as part of :ticket:`4353`, where it was established that
a history operation that does not expect emit SQL should bypass the
``lazy="raise"`` check, and instead effectively treat it as
``lazy="raise_on_sql"`` for this case.  The fix adjusts the lazy loader
strategy to not raise for the case where the lazy load was instructed that
it should not emit SQL if the object were not present.

Fixes: #4997
Change-Id: I4deb8c129900f28321c4a5c48301db5fe2aedf78
(cherry picked from commit ff4b63c2bc5f118d5ec1aacff06708dbc08a37a7)

5 years agoFix rst for flake8-rst-docstrings-0.0.12
Mike Bayer [Fri, 22 Nov 2019 16:08:37 +0000 (11:08 -0500)] 
Fix rst for flake8-rst-docstrings-0.0.12

A few new formatting errors are caught by this version.

Change-Id: I737b33267a00f400b7ba7696a03ddb07a4c95bc0
(cherry picked from commit 1bf1a9c0d8e122da79898835c007ea904e238c21)

5 years agoIntroduce flag combinations fixture
Mike Bayer [Fri, 22 Nov 2019 15:54:22 +0000 (10:54 -0500)] 
Introduce flag combinations fixture

A helper for @testing.combinations when we just have lots of
true/false combinations as is the case with some ORM tests.

Change-Id: I9f2de97ce5b2487411ed610b8d41169c1052bd8f
(cherry picked from commit 431b019c435654162b0d61b8131a170c5b858fb0)

5 years agoSkip on slice assignment to self
Mike Bayer [Tue, 19 Nov 2019 14:30:31 +0000 (09:30 -0500)] 
Skip on slice assignment to self

Fixed issue where when assigning a collection to itself as a slice, the
mutation operation would fail as it would first erase the assigned
collection inadvertently.   As an assignment that does not change  the
contents should not generate events, the operation is now a no-op. Note
that the fix only applies to Python 3; in Python 2, the ``__setitem__``
hook isn't called in this case; ``__setslice__`` is used instead which
recreates the list item-by-item in all cases.

Fixes: #4990
Change-Id: I08727880f70f4fe188de53a4dcd36746b62c7233
(cherry picked from commit 560044748a8ff5488769f8ebfa8a353a8d0115fa)

5 years agoMove max-worker-restart to pytest-xdist options in tox.ini
Mike Bayer [Tue, 19 Nov 2019 17:38:58 +0000 (12:38 -0500)] 
Move max-worker-restart to pytest-xdist options in tox.ini

This way py.test can be run on the outside without a
command line error.

Change-Id: Ia3689806bffbabe176a827cca2f099e89a60ebf5
Closes: #4989
(cherry picked from commit 3ceb87da1a66f455444e69ba25ac18ea26d8751e)

5 years agoUse viewonly=True for composite secondary join example
Mike Bayer [Tue, 19 Nov 2019 15:12:35 +0000 (10:12 -0500)] 
Use viewonly=True for composite secondary join example

This example isn't writable as given.   Add additonal
warnings.  Also modernize the "query-enabled property"
section and add links to hybrids.

Fixes: #4992
Change-Id: I8f4b4db9e42ab2207a74532e3b17a56c35b0a837
(cherry picked from commit 25a6596030cbf16a870db142ddf096223c79be7a)

5 years agoAdd TypeDecorator recipe for timezone aware/UTC conversion
Mike Bayer [Wed, 13 Nov 2019 15:49:01 +0000 (10:49 -0500)] 
Add TypeDecorator recipe for timezone aware/UTC conversion

Change-Id: I59e6c76a4a53ce3782bcfc4aecdeb1b4fdd7b941
References: https://github.com/sqlalchemy/sqlalchemy/issues/4980
(cherry picked from commit e345864506346700dc4c21ff21bfc18f2c047831)

5 years agoVersion 1.3.12 placeholder
Mike Bayer [Mon, 11 Nov 2019 22:15:33 +0000 (17:15 -0500)] 
Version 1.3.12 placeholder

5 years ago- 1.3.11 rel_1_3_11
Mike Bayer [Mon, 11 Nov 2019 22:07:35 +0000 (17:07 -0500)] 
- 1.3.11

5 years agoMerge "Detect PyMySQL connection was killed" into rel_1_3
mike bayer [Mon, 11 Nov 2019 22:04:16 +0000 (22:04 +0000)] 
Merge "Detect PyMySQL connection was killed" into rel_1_3

5 years agoMerge "Test fixture improvements" into rel_1_3
mike bayer [Mon, 11 Nov 2019 21:27:41 +0000 (21:27 +0000)] 
Merge "Test fixture improvements" into rel_1_3

5 years agoDetect PyMySQL connection was killed
Mike Bayer [Mon, 11 Nov 2019 21:17:50 +0000 (16:17 -0500)] 
Detect PyMySQL connection was killed

Added "Connection was killed" message interpreted from the base
pymysql.Error class in order to detect closed connection, based on reports
that this message is arriving via a pymysql.InternalError() object which
indicates pymysql is not handling it correctly.

Change-Id: If6bbe0eb5993e1996c0c5de752eebaf7446cf93e
References: https://github.com/PyMySQL/PyMySQL/issues/816
Fixes: #4945
(cherry picked from commit 31a66b5add39b9193975f9995ce5cd9235179f00)

5 years agoTest fixture improvements
Mike Bayer [Mon, 11 Nov 2019 19:57:08 +0000 (14:57 -0500)] 
Test fixture improvements

- ensure we escape out percent signs when a CompiledSQL or RegexSQL
has percent signs in the SQL or in the parameter repr

- to support combinations, print out complete test name in skip
messages, py.test environment gives us a way to do this

Change-Id: Ia9e62f7c1026c1465986144c5757e35fc164a2b8
(cherry picked from commit 3cf0a1642eafe53e3c3b40b06cf105a32676a27f)

5 years agoAdd type accessors for JSON indexed/pathed element access
Mike Bayer [Thu, 7 Nov 2019 20:31:48 +0000 (15:31 -0500)] 
Add type accessors for JSON indexed/pathed element access

Added new accessors to expressions of type :class:`.JSON` to allow for
specific datatype access and comparison, covering strings, integers,
numeric, boolean elements.   This revises the documented approach of
CASTing to string when comparing values, instead adding specific
functionality into the PostgreSQL, SQlite, MySQL dialects to reliably
deliver these basic types in all cases.

The change also delivers a new feature to the test exclusions
system so that combinations and exclusions can be used together.

Fixes: #4276
Change-Id: Ica5a926c060feb40a0a7cd60b9d6e061d7825728
(cherry picked from commit 01cbf4d7b8acab54a054bb36dc2792b518b5cd1f)

5 years agoMerge "Exclude local columns when adapting secondary in a join condition" into rel_1_3
mike bayer [Sun, 10 Nov 2019 23:28:15 +0000 (23:28 +0000)] 
Merge "Exclude local columns when adapting secondary in a join condition" into rel_1_3

5 years agoPerform an active check for sqlite json extension
Mike Bayer [Fri, 25 Oct 2019 17:10:30 +0000 (13:10 -0400)] 
Perform an active check for sqlite json extension

Apparently some Python builds may not have json enabled
for sqlite even though version > 3.9, add an active check
for the json functions.

Fixes: #4946
Change-Id: I1a1ce7ef72da8da9ad9576e1281d1df415c6af4f
(cherry picked from commit c2e8b48a668a7ae7c1467a00e44fb1e4daa660a3)

5 years agoExclude local columns when adapting secondary in a join condition
Mike Bayer [Sun, 10 Nov 2019 20:42:40 +0000 (15:42 -0500)] 
Exclude local columns when adapting secondary in a join condition

Fixed ORM bug where a "secondary" table that referred to a selectable which
in some way would refer to the local primary table would apply aliasing to
both sides of the join condition when a relationship-related join, either
via :meth:`.Query.join` or by :func:`.joinedload`, were generated.  The
"local" side is now excluded.

Fixes: #4974
Change-Id: Ia43da747c22141b05439f4511ddeceb10248582e
(cherry picked from commit f3bfe0881726f1b3075400346f5987390ebe6c19)

5 years agoSupport exclusion rules in combinations
Mike Bayer [Sat, 9 Nov 2019 17:33:16 +0000 (12:33 -0500)] 
Support exclusion rules in combinations

Like py.test we need to be able to mark certain combination
elements with exclusion rules.   Add additional logic
to pytestlplugin and exclusions so that the exclusion decorators
can be added to the combination tuples, where they will be applied
to the decorated function along with a qualifier that the test
arguments need to match what's given.

Change-Id: I15d2839954d77a252bab5aaf6e3fd9f388c99dd5
(cherry picked from commit bbe754784ae4630dd0ebf30d3bc2be566f8a8fef)

5 years agoFix exclusions for multiple fails_on
Mike Bayer [Sat, 9 Nov 2019 18:12:13 +0000 (13:12 -0500)] 
Fix exclusions for multiple fails_on

The fails_on decorator was not being interpreted
correctly when multiple were present.

Remove obsolete fails_on from test_types that no longer
take place for MySQL, Oracle

Ensure test_types tests are using __backend__

mark currently failing Oracle interval tests

Change-Id: If8db0c02b31a8008fd1673c2380f1f974c3806a6
(cherry picked from commit 56dff403b7cbaf2de342c83d496d0937f5b719b1)

5 years agoInterpret empty LIMIT, expression LIMIT correctly
Mike Bayer [Sat, 9 Nov 2019 21:12:30 +0000 (16:12 -0500)] 
Interpret empty LIMIT, expression LIMIT correctly

Fixed issue in MSSQL dialect where an expression-based OFFSET value in a
SELECT would be rejected, even though the dialect can render this
expression inside of a ROW NUMBER-oriented LIMIT/OFFSET construct.

Fixes: #4973
Change-Id: I040d34f781791c4ed5a727e1b8fb98c68ddd0622
(cherry picked from commit b3c3562ecf67ae7c94091287504579fcace6a500)

5 years agoMerge "Support for generated columns" into rel_1_3
mike bayer [Sat, 9 Nov 2019 16:23:34 +0000 (16:23 +0000)] 
Merge "Support for generated columns" into rel_1_3

5 years agoSupport for generated columns
CaselIT [Mon, 4 Nov 2019 22:11:21 +0000 (17:11 -0500)] 
Support for generated columns

Added DDL support for "computed columns"; these are DDL column
specifications for columns that have a server-computed value, either upon
SELECT (known as "virtual") or at the point of which they are INSERTed or
UPDATEd (known as "stored").  Support is established for Postgresql, MySQL,
Oracle SQL Server and Firebird. Thanks to Federico Caselli for lots of work
on this one.

ORM round trip tests included.  The ORM makes use of existing
FetchedValue support and no additional ORM logic is present for
the basic feature.

It has been observed that Oracle RETURNING does not return the
new value of a computed column upon UPDATE; it returns the
prior value.  As this is very dangerous, a warning is emitted
if a computed column is rendered into the RETURNING clause
of an UPDATE statement.

Fixes: #4894
Closes: #4928
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4928
Pull-request-sha: d39c521d5ac6ebfb4fb5b53846451de79752e64c

Change-Id: I2610b2999a5b1b127ed927dcdaeee98b769643ce
(cherry picked from commit 602d1e6dfd538980bb8d513867b17dbc2b4b92dd)

5 years agoWork around setuptools issue #1902
Mike Bayer [Fri, 8 Nov 2019 14:48:27 +0000 (09:48 -0500)] 
Work around setuptools issue #1902

Added a workaround for a setuptools-related failure that has been observed
as occurring on Windows installations, where setuptools is not correctly
reporting a build error when the MSVC build dependencies are not installed
and therefore not allowing graceful degradation into non C extensions
builds.

Setuptools issue https://github.com/pypa/setuptools/issues/1902

Fixes: #4967
Change-Id: I5e21e7e78cb6d927b18afce64cacf8643b98354e
(cherry picked from commit 4a2dd4902a1168234f14bdd0634728086d53c406)

5 years agoSquashed commit of the following:
Mike Bayer [Wed, 6 Nov 2019 14:42:42 +0000 (09:42 -0500)] 
Squashed commit of the following:

commit e7fc2b2a73789460a29534e3566880313542f218
Author: Daniel Gaspar <danielvazgaspar@gmail.com>
Date:   Mon Nov 4 14:49:54 2019 +0000

    [docs] Fix, missing dot

commit 751d269d369fb52f079eb14e7b455da402623961
Author: Daniel Gaspar <danielvazgaspar@gmail.com>
Date:   Mon Nov 4 14:46:01 2019 +0000

    [docs] Apache Druid and Google sheets dialects

Change-Id: I6462b310635210649564ce0399393ec194daf774
(cherry picked from commit 6ccf862747783346221d02d4e804f0ef11c9fc64)

5 years agofixed typo in session.py in line 3063
L0stLink [Sat, 2 Nov 2019 10:09:03 +0000 (15:09 +0500)] 
fixed typo in session.py in line 3063

Changed : wish to detect is a "rollback" is
 to : wish to detect if a "rollback" is
, improving clarity.

(cherry picked from commit 7f260c95d65f9bb77e4e0bbb8ef78f57b183fc7c)

5 years agoExpect ordering NULLs to work and skip nested aggregate tests on sqlite >= 3.30.
Nils Philippsen [Sat, 2 Nov 2019 21:36:50 +0000 (17:36 -0400)] 
Expect ordering NULLs to work and skip nested aggregate tests on sqlite >= 3.30.

Fixed test failures which would occur with newer SQLite as of version 3.30
or greater, due to their addition of nulls ordering syntax as well as new
restrictions on aggregate functions.  Pull request courtesy Nils Philippsen.

Fixes: #4920
Closes: #4921
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4921
Pull-request-sha: e18534a9045786efdaf4963515222838c62e0300

Change-Id: Idb2fc96e23e7cc96cf96f586208c2db561518202
(cherry picked from commit 6b5d94da84452b125f6788f0e1472b94a43ffc16)

5 years agoMerge "Cache every key in reflection_cache" into rel_1_3
mike bayer [Thu, 31 Oct 2019 15:56:13 +0000 (15:56 +0000)] 
Merge "Cache every key in reflection_cache" into rel_1_3

5 years agoMerge "omit_join=True is not supported" into rel_1_3
mike bayer [Thu, 31 Oct 2019 15:55:33 +0000 (15:55 +0000)] 
Merge "omit_join=True is not supported" into rel_1_3

5 years agoImprove SQL Server pyodbc documentation
Mike Bayer [Thu, 31 Oct 2019 14:30:46 +0000 (10:30 -0400)] 
Improve SQL Server pyodbc documentation

While we were told years ago that ODBC is intended to be used with
DSNs only, however this use does not correspond well with how most
other database connectivity systems work in that modern systems
already have their own registries of connection information in any
case, meaning this is usually the best place to add details such
as hostnames and driver names, rather than having them locked away
in a server-specific ODBC registry.    So here we dial back the
language that one style or another of connecting is "preferred";
both styles are supported equally, and the critical advantage of
hostname mapping in that the target database name is both explicit
as well as modifyable is also added.

Add additional background for how DSNs work and refine other
sentences.   "URL encoding" is the correct terminology for
adding spaces and special characters to a URL.

Change-Id: I13a74432976e6d3166633b98f9bb84c4856caac8
(cherry picked from commit 65466dec6346ad84340af1cf3e431020add0f9a5)

5 years agoomit_join=True is not supported
Mike Bayer [Wed, 30 Oct 2019 18:42:10 +0000 (14:42 -0400)] 
omit_join=True is not supported

The :paramref:`.relationship.omit_join` flag was not intended to be
manually set to True, and will now emit a warning when this occurs.  The
omit_join optimization is detected automatically, and the ``omit_join``
flag was only intended to disable the optimization in the hypothetical case
that the optimization may have interfered with correct results, which has
not been observed with the modern version of this feature.   Setting the
flag to True when it is not automatically detected may cause the selectin
load feature to not work correctly when a non-default primary join
condition is in use.

Fixes: #4954
Change-Id: I3afebefb13ddaf8f74c5c2b9e6e6a1a261ac5629
(cherry picked from commit 9b774743952fa4f459a914604cc8395175eca07e)

5 years agoCache every key in reflection_cache
Mike Bayer [Thu, 31 Oct 2019 13:30:12 +0000 (09:30 -0400)] 
Cache every key in reflection_cache

Fixed bug in :class:`.Inspector` where the cache key generation did not
take into account arguments passed in the form of tuples, such as the tuple
of view name styles to return for the PostgreSQL dialect. This would lead
the inspector to cache too generally for a more specific set of criteria.
The logic has been adjusted to include every keyword element in the cache,
as every argument is expected to be appropriate for a cache else the
caching decorator should be bypassed by the dialect.

Fixes: #4955
Change-Id: Icd97744323407977a3f7db26e8a63a1a5c576010
(cherry picked from commit 9fc54801c8235a6327e0ce80b145f7ba756ae47a)

5 years agoCorrectly interpret None passed to query.get(); warn for empty PK values
lizraeli [Mon, 28 Oct 2019 19:33:41 +0000 (15:33 -0400)] 
Correctly interpret None passed to query.get(); warn for empty PK values

A warning is emitted if a primary key value is passed to :meth:`.Query.get`
that consists of None for all primary key column positions.   Previously,
passing a single None outside of a tuple would raise a ``TypeError`` and
passing a composite None (tuple of None values) would silently pass
through.   The fix now coerces the single None into a tuple where it is
handled consistently with the other None conditions.  Thanks to Lev
Izraelit for the help with this.

Fixes #4915
Closes: #4917
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4917
Pull-request-sha: b388343c7cabeecf8c779689b78e638c23f9af40

Change-Id: Ibc6c27ccf50dfd4adbf15b6dbd393115c30d44fb
(cherry picked from commit 997f4b5f2b3b4725de0960824e95fcb1150ff215)

5 years agoTypo fix
Ales Dokshanin [Wed, 23 Oct 2019 15:37:49 +0000 (18:37 +0300)] 
Typo fix

(cherry picked from commit 26d9a29514ea0949f09f75622065e737fabeabe1)

5 years agoSquashed commit of the following:
Mike Bayer [Mon, 28 Oct 2019 19:24:56 +0000 (15:24 -0400)] 
Squashed commit of the following:

commit 358500f542c3a8c707222bd2fea9478258b3d8d3
Author: Daniel Gaspar <danielvazgaspar@gmail.com>
Date:   Fri Oct 25 09:39:41 2019 +0100

    [docs] Fix, typo

commit b68127b842849ffcc19c311e4b9b4afcc16395ca
Author: Daniel Gaspar <danielvazgaspar@gmail.com>
Date:   Fri Oct 25 09:29:43 2019 +0100

    [docs] Elasticsearch dialect and dbapi

Change-Id: I5c67eca606be382f801facae3546ab6c499e9e63
(cherry picked from commit 4755e1fb41dd396ffef0b4ae93a3cbc0c151f695)

5 years agoAdd public accessor `is_single_entity` to Query
Patrick Hayes [Thu, 24 Oct 2019 14:11:52 +0000 (10:11 -0400)] 
Add public accessor `is_single_entity` to Query

Added accessor :attr:`.Query.is_single_entity` to :class:`.Query`, which
will indicate if the results returned by this :class:`.Query` will be a
list of ORM entities, or a tuple of entities or column expressions.
SQLAlchemy hopes to improve upon the behavior of single entity / tuples in
future releases such that the behavior would be explicit up front, however
this attribute should be helpful with the current behavior.  Pull request
courtesy Patrick Hayes.

Fixes: #4934
Closes: #4935
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4935
Pull-request-sha: 98f72b40a896761a65b048cc3722ff2dac4cf2b1

Change-Id: If5db5db3ea46a93406d76ef90b5b588149ba2986
(cherry picked from commit e55e749e182e257fcc60db383751d5afbe52ddfb)

5 years agoDon't cache a query that has before_compile modifications
Mike Bayer [Fri, 25 Oct 2019 15:34:37 +0000 (11:34 -0400)] 
Don't cache a query that has before_compile modifications

The :class:`.BakedQuery` will not cache a query that was modified by a
:meth:`.QueryEvents.before_compile` event, so that compilation hooks that
may be applying ad-hoc modifications to queries will take effect on each
run.  In particular this is helpful for events that modify queries used in
lazy loading as well as eager loading such as "select in" loading.  In
order to re-enable caching for a query modified by this event, a new
flag ``bake_ok`` is added; see :ref:`baked_with_before_compile` for
details.

A longer term plan to provide a new form of SQL caching should solve this
kind of issue more comprehensively.

Fixes: #4947
Change-Id: I5823c4fa00e7b6d46a2e8461b02d8b16605a6ed0
(cherry picked from commit d6db28556b095dc85fff3e0e09b0e70358a9538b)

5 years agoFix Python 3.8 SyntaxWarning: "is not" with a literal
Anders Kaseorg [Thu, 24 Oct 2019 18:27:57 +0000 (14:27 -0400)] 
Fix Python 3.8 SyntaxWarning: "is not" with a literal

Fixes this warning from Python 3.8 in `Query._set_entities`:

```
lib/sqlalchemy/orm/query.py:179: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if entities is not ():
```

Fixes #4938.

This pull request is:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [x] 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!**

Closes: #4939
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4939
Pull-request-sha: 88167460ced7f576a9aed3d0ff0a6e7e18810004

Change-Id: I21464c3e69b4db6307db99f9ccb9b34bbac4e744
(cherry picked from commit 4b61b81dba8d90165d764050d9466b286c7a80f2)

5 years agoWarn that before_compile for lazyload needs bake_queries=False
Mike Bayer [Fri, 25 Oct 2019 14:08:18 +0000 (10:08 -0400)] 
Warn that before_compile for lazyload needs bake_queries=False

The longer term future plan for ORM queries is that there
will be a new hook that receives queries before invocation
rather than "compilation", which will make use of a new
caching system.

Fixes: #4947
Change-Id: I256c16155a0cc9b7133e86e22d27040cb64eb1a9
(cherry picked from commit 172d99a8a1282b534aeadafebdd2af0162758931)

5 years agoMerge "Use default repr() for quoted_name under python 3" into rel_1_3
mike bayer [Thu, 24 Oct 2019 15:32:02 +0000 (15:32 +0000)] 
Merge "Use default repr() for quoted_name under python 3" into rel_1_3

5 years agoMerge "Support unique bound parameters for text()" into rel_1_3
mike bayer [Thu, 24 Oct 2019 14:17:42 +0000 (14:17 +0000)] 
Merge "Support unique bound parameters for text()" into rel_1_3

5 years agoUse default repr() for quoted_name under python 3
Mike Bayer [Wed, 23 Oct 2019 14:53:04 +0000 (10:53 -0400)] 
Use default repr() for quoted_name under python 3

Changed the ``repr()`` of the :class:`.quoted_name` construct to use
regular string repr() under Python 3, rather than running it through
"backslashreplace" escaping, which can be misleading.

Modified the approach of "name normalization" for the Oracle and Firebird
dialects, which converts from the UPPERCASE-as-case-insensitive convention
of these dialects into lowercase-as-case-insensitive for SQLAlchemy, to not
automatically apply the :class:`.quoted_name` construct to a name that
matches itself under upper or lower case conversion, as is the case for
many non-european characters.   All names used within metadata structures
are converted to :class:`.quoted_name` objects in any case; the change
here would only affect the output of some inspection functions.

Moved name normalize to be under default dialect, added test coverage
in test/sql/test_quote.py

Fixes: #4931
Change-Id: Ic121b20e07249824710a54423e321d94a425362f
(cherry picked from commit f9000e2a38bc879a4964a4f396e87185d0d21cd2)

5 years agoMerge "Refactor dialect tests for combinations" into rel_1_3
mike bayer [Wed, 23 Oct 2019 18:13:52 +0000 (18:13 +0000)] 
Merge "Refactor dialect tests for combinations" into rel_1_3

5 years agoSupport unique bound parameters for text()
Mike Bayer [Wed, 23 Oct 2019 17:03:09 +0000 (13:03 -0400)] 
Support unique bound parameters for text()

The :func:`.text` construct now supports "unique" bound parameters, which
will dynamically uniquify themselves on compilation thus allowing multiple
:func:`.text` constructs with the same bound parameter names to be combined
together.

This is a backport from part of 36e8fe4 / #4808 to 1.3.

Fixes: #4933
Change-Id: Ide4069ff5cccd5ed83a5f314e5f21e51dfe08b7d
(cherry picked from commit 8caaa4fba0fbe08f73d09f5b585f12c0857d0de9)

5 years agoAdd doc note for multiple table mapping
Mike Bayer [Wed, 23 Oct 2019 15:18:56 +0000 (11:18 -0400)] 
Add doc note for multiple table mapping

When mapping to a construct like OUTER JOIN, an UPDATE from the
ORM expects that all involved tables have a row already present;
document this as well as a potential workaround.

Fixes: #4927
Change-Id: Ie99f9f53cea33d9df2513f384a7c68676b197fb7
(cherry picked from commit 2cae55269b6745bd733be142a6e199d8ecf9b50a)