]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
5 years agoMerge "Ensure all nested exception throws have a cause" into rel_1_3
mike bayer [Tue, 3 Mar 2020 17:30:20 +0000 (17:30 +0000)] 
Merge "Ensure all nested exception throws have a cause" into rel_1_3

5 years agoInclude column_property composition examples
Mike Bayer [Tue, 3 Mar 2020 13:58:35 +0000 (08:58 -0500)] 
Include column_property composition examples

Add cross-linking between column_property() and ColumnProperty

Add section to describe using .expression

remove inherited-members from ColumnProperty to greatly
decrease verbosity

Fixes: #5179
Change-Id: Ic477b16350dbf551100b31d14ff3ba8ba8221a43
(cherry picked from commit 4c81d99bab0e884473abfcb573772aa5d94264c7)

5 years agoEnsure all nested exception throws have a cause
Mike Bayer [Sat, 29 Feb 2020 19:40:45 +0000 (14:40 -0500)] 
Ensure all nested exception throws have a cause

Applied an explicit "cause" to most if not all internally raised exceptions
that are raised from within an internal exception catch, to avoid
misleading stacktraces that suggest an error within the handling of an
exception.  While it would be preferable to suppress the internally caught
exception in the way that the ``__suppress_context__`` attribute would,
there does not as yet seem to be a way to do this without suppressing an
enclosing user constructed context, so for now it exposes the internally
caught exception as the cause so that full information about the context
of the error is maintained.

Fixes: #4849
Change-Id: I55a86b29023675d9e5e49bc7edc5a2dc0bcd4751
(cherry picked from commit 8be0dae77a7e0747f0d0fb4282db4aea7f41e03a)

5 years agoUpdate dialect API documentation
Mike Bayer [Mon, 2 Mar 2020 15:28:32 +0000 (10:28 -0500)] 
Update dialect API documentation

The docstrings for connect() and on_connect() were incorrect
between Dialect vs. DefaultDialect.   Redocumented related
methods, clean up formatting, and remove unicode-related
attribute descriptions from the top level Dialect document
as these don't apply to Python 3.

Change-Id: I45baab757f8e20627eba42c30b9e8dbe26356275
(cherry picked from commit 649de79950dcf952d7a44069faf36925c23c4e63)

5 years agoWhile parsing for check constraints, ignore newline characters in the check condition
Eric Borczuk [Fri, 28 Feb 2020 16:05:13 +0000 (11:05 -0500)] 
While parsing for check constraints, ignore newline characters in the check condition

Fixed bug where PostgreSQL reflection of CHECK constraints would fail to
parse the constraint if the SQL text contained newline characters. The
regular expression has been adjusted to accommodate for this case. Pull
request courtesy Eric Borczuk.

Fixes: #5170
Closes: #5172
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5172
Pull-request-sha: 5701b7f09f723b727bbee95d19d107d6cc1d7717

Change-Id: If727e9140b645e8b685c3476fb0fa4417c1e6526
(cherry picked from commit 0fe528483afeb53300ff7a9770f7fb9c81a3a874)

5 years agoRemove print statement in favor of print() function in docs and examples
Albert Tugushev [Wed, 26 Feb 2020 16:09:29 +0000 (11:09 -0500)] 
Remove print statement in favor of print() function in docs and examples

<!-- Provide a general summary of your proposed changes in the Title field above -->

### Description
<!-- Describe your changes in detail -->
Remove print statements

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

-->

This pull request is:

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

**Have a nice day!**

Closes: #5166
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5166
Pull-request-sha: 04a7394f71298322188f0861b4dfe93e5485839d

Change-Id: Ib90a59fac929661a18748c6e44966fb87e3978c6
(cherry picked from commit a836e3df5d973f75bd8330cecb76511b67c13612)

5 years agoRemove needless clauseelement check for batch
Mike Bayer [Mon, 24 Feb 2020 19:45:38 +0000 (14:45 -0500)] 
Remove needless clauseelement check for batch

Also document more detail as to why SQL expression support
is not turned on for batch.

Fixes: #5165
Change-Id: Ia93bbf75f22b8781400086c45b86a60ef9cec360
(cherry picked from commit 88c23da948e76b1c273b6c48389d6671878696eb)

5 years agoRemove unnecessary tuple; prepare for "iterator" verbiage
Mike Bayer [Thu, 20 Feb 2020 14:01:36 +0000 (09:01 -0500)] 
Remove unnecessary tuple; prepare for "iterator" verbiage

Remove a tuple surrounding a generator expression that
is immediately iterated in any case.   Additionally
note that the bulk methods can likely accept non-list
objects such as arbitrary iterables, however without test
coverage this is not yet guaranteed; use the term "sequence"
for now.

Fixes: #5163
Change-Id: If838fe214da574763115855c1a65171533c96e64
(cherry picked from commit 2db6f20752fd37cbaaad721c74ebfc34675923f4)

5 years agoMerge "Pass DDLCompiler IdentifierPreparer to visit_ENUM" into rel_1_3
mike bayer [Mon, 17 Feb 2020 22:16:47 +0000 (22:16 +0000)] 
Merge "Pass DDLCompiler IdentifierPreparer to visit_ENUM" into rel_1_3

5 years agoMerge "Limit non-backend critical profiling tests to SQLite" into rel_1_3
mike bayer [Mon, 17 Feb 2020 22:14:21 +0000 (22:14 +0000)] 
Merge "Limit non-backend critical profiling tests to SQLite" into rel_1_3

5 years agoMerge "Begin to disallow back_populates with viewonly=True" into rel_1_3
mike bayer [Mon, 17 Feb 2020 21:01:55 +0000 (21:01 +0000)] 
Merge "Begin to disallow back_populates with viewonly=True" into rel_1_3

5 years agoLimit non-backend critical profiling tests to SQLite
Mike Bayer [Mon, 17 Feb 2020 16:51:33 +0000 (11:51 -0500)] 
Limit non-backend critical profiling tests to SQLite

issues with backend-specific profiling should be limited
to tests that are explcitly against resultset, compiler, etc.

MySQL in particular has an often varying callcount that isn't
worth running these tests against nor is it worth profiling
them for other backends like Oracle and SQL Server.

Also add the REQUIRE_SQLALCHEMY_CEXT flag to
the regen_callcounts.tox.ini script, which is part of some review
somewhere but is needed here to generate callcounts correctly.

Add a "warmup" phase for some of the ORM tests for join conditions
that have varying profile counts based on whether mappings have been
used already or not; profiling should always be against the
"warmed up" version of a function.

Change-Id: If483820235fa4cc4360cbd067a9b68d83512d587
(cherry picked from commit 386012597b9e7aa2a7f987930d00b892ed54121d)

5 years agoPass DDLCompiler IdentifierPreparer to visit_ENUM
Mike Bayer [Mon, 17 Feb 2020 20:21:59 +0000 (15:21 -0500)] 
Pass DDLCompiler IdentifierPreparer to visit_ENUM

Fixed issue where the "schema_translate_map" feature would not work with a
PostgreSQL native enumeration type (i.e. :class:`.Enum`,
:class:`.postgresql.ENUM`) in that while the "CREATE TYPE" statement would
be emitted with the correct schema, the schema would not be rendered in
the CREATE TABLE statement at the point at which the enumeration was
referenced.

Fixes: #5158
Change-Id: I41529785de2e736c70a142c2ae5705060bfed73e
(cherry picked from commit 89b8c343ed6247a562e0bcd53ef3fc180d0d4e46)

5 years agoFurther refine fractional seconds datetimeoffset fixture
Mike Bayer [Mon, 17 Feb 2020 14:41:59 +0000 (09:41 -0500)] 
Further refine fractional seconds datetimeoffset fixture

in 55f6d61e85b7f16df0b77f1c55a4fb051cd696e3 we still
forgot to accommodate for Python 3 timezone constructor
rejecting fractional minutes so the test further needs lambdas
to prevent the constructor from invoking for Python versions
less than 3.7

Change-Id: I02a83888f5ffbbe53ed0ce16c46a70942add4a3c
(cherry picked from commit a8b4ea8819e08c0eaa74b53385a91c22916401c7)

5 years agoUpdate test reqs for mariadb 10.4, 10.5
Mike Bayer [Sun, 16 Feb 2020 17:01:17 +0000 (12:01 -0500)] 
Update test reqs for mariadb 10.4, 10.5

A few except / union tests seem to be passing on these two
versions which are now up on CI.

Change-Id: I0d65795357a6d03962d7182dda198d890a4c3f97
(cherry picked from commit 2f27dd35020be46b35717cffdccaefc97b5f67dd)

5 years agoFractional seconds starts at Python 3.7
Mike Bayer [Thu, 13 Feb 2020 20:43:05 +0000 (15:43 -0500)] 
Fractional seconds starts at Python 3.7

CI didn't notice that the fractional seconds in the new SQL Server
DATETIMEOFFSET test are not available on Python 3.6. It was
inadvertently assumed this was a Python 2 incompatibility.

Change-Id: I9839eafbf7c37512eef1ecf666846983f9651c02
(cherry picked from commit 55f6d61e85b7f16df0b77f1c55a4fb051cd696e3)

5 years agoImprove ResultProxy/Row documentation before the API change
Mike Bayer [Thu, 13 Feb 2020 17:48:26 +0000 (12:48 -0500)] 
Improve ResultProxy/Row documentation before the API change

We'd like to merge Ieb9085e9bcff564359095b754da9ae0af55679f0,
however the documentation in that change should be based off
of more comprehensive documentation than what we have already.

Add the notion of "row" to the tutorial and document all
methods.   This will also be backported at least to 1.3
in terms of RowProxy.

Change-Id: I2173aecc86cf15c5a7c473b8f471639ee9082f84
(cherry picked from commit 8fabe50d7a47b50215a7ea4cf1d39409d9529e51)

5 years agoBegin to disallow back_populates with viewonly=True
Mike Bayer [Tue, 11 Feb 2020 17:51:46 +0000 (12:51 -0500)] 
Begin to disallow back_populates with viewonly=True

A viewonly=True relationship should not be mutated and ideally
mutation itself would raise an error, but we're not there yet.
Warn when a viewonly is to be the target of a back_populates
as this only means that it should be locally mutated, which
by definition will not work as expected because post-flush
it will deliver doubled results, due to its state not being
reset.

Setting a relationship to viewonly=True which is also the target of a
back_populates or backref configuration will now emit a warning and
eventually be disallowed. back_populates refers specifically to mutation
of an attribute or collection, which is disallowed when the attribute is
subject to viewonly=True.   The viewonly attribute is not subject to
persistence behaviors which means it will not reflect correct results
when it is locally mutated.

Fixes: #5149
Change-Id: Ie51382a82e1a0ff5f3cf2cdbded780e77ace7f5f
(cherry picked from commit 4376c2e5b016e8dfec7bc1b0d2ebbebae737c063)

5 years agoFix handling of None as parameter for a datetimeoffset column
Gord Thompson [Mon, 3 Feb 2020 23:42:45 +0000 (16:42 -0700)] 
Fix handling of None as parameter for a datetimeoffset column

Fixed issue where the :class:`.mssql.DATETIMEOFFSET` type would not
accommodate for the ``None`` value, introduced as part of the series of
fixes for this type first introduced in :ticket:`4983`, :ticket:`5045`.
Additionally, added support for passing a backend-specific date formatted
string through this type, as is typically allowed for date/time types on
most other DBAPIs.

Fixes: #5132
Change-Id: Iab05d67382e0f550474d50e0c3c1c888521b678a
(cherry picked from commit 532ddb0fa717bc10c3a95b7ddf3a60bbfad7ac56)

5 years agoRework combination exclusions
Mike Bayer [Mon, 10 Feb 2020 20:38:39 +0000 (15:38 -0500)] 
Rework combination exclusions

The technique arrived at for doing exclusions inside of combinations
relies upon comparing all the arguments in a particular combination
to some set of combinations that were gathered as having
"exclusions".   This logic is actually broken for the
case where the @testing.combinations has an "id", but if we fix
that, we still have the issue of all the arguments being
compared, which is complicated and also doesn't work for the
case of a py2/py3 incompatibility like a timezone that has
fractional minutes or seconds in it.   It's also not clear
if a @testing.combinations that uses lambdas will work either
(maybe it does though because lambdax == lambdax compares...).

anyway, this patch reworks it so that we hit this on the decorator
side instead, where we add our own decorator and go through
the extra effort to create a decorator that accepts an extra
argument of "exclusions" which we can then check in a way that
is local to the whole pytest @combinations thing in the first place.
The only difficulty is that pytest is very sneaky about looking
at the test function so we need to make sure __wrapped__ isn't
set when doing this.

Change-Id: Ic57aae15b378e0f4ed009e4e82ae7ba73fb6dfc5
(cherry picked from commit 12ec0e06858d84097a051a50a60fe9a1582ee95c)

5 years agoFixes for public_factory and mysql/pg dml functions
Mike Bayer [Sat, 8 Feb 2020 19:53:21 +0000 (14:53 -0500)] 
Fixes for public_factory and mysql/pg dml functions

* ensure that the location indicated by public_factory is
  importable

* adjust all of sqlalchemy.sql.expression locations to be correct

* support the case where a public_factory is against a function
  that has another public_factory already, and already replaced the
  __init__ on the target class

* Use mysql.insert(), postgresql.insert(), don't include .dml in the
  class path.

Change-Id: Iac285289455d8d7102349df3814f7cedc758e639
(cherry picked from commit 660ff51df0433607b12c58a12c7355107c1773f5)

5 years agoVendor inspect.formatannotation
Mike Bayer [Fri, 7 Feb 2020 22:55:07 +0000 (17:55 -0500)] 
Vendor inspect.formatannotation

Vendored the ``inspect.formatannotation`` function inside of
``sqlalchemy.util.compat``, which is needed for the vendored version of
``inspect.formatargspec``.  The function is not documented in cPython and
is not guaranteed to be available in future Python versions.

Fixes: #5138
Change-Id: I76bdddc28507fb1b4403f1b718d6f9cc2fb6d93c
(cherry picked from commit 47aa62abde6eba67802f2f7126cc79fbd95b5d1a)

5 years agoUpdate basic_relationships.rst
randallk [Mon, 20 Jan 2020 00:11:44 +0000 (17:11 -0700)] 
Update basic_relationships.rst

Fix relationship used in doc.

(cherry picked from commit 698a279c918b2d037fc49700c51126d624db777a)

5 years agoDocument SQLite "mixed binary" behavior
Mike Bayer [Thu, 6 Feb 2020 15:26:50 +0000 (10:26 -0500)] 
Document SQLite "mixed binary" behavior

The Pysqlite driver can store a string value with
or without an indicator that the value is to be retrieved
as bytes or as a unicode string object.    To suit the
use case where a SQLite database has mixed values on a row
by row basis, provide a recipe for a MixedBinary datatype.

Change-Id: I9a166bd6fc673d8d46a53ab9697cb3d412e5fcee
References: #5073
(cherry picked from commit ee1d914888113ceb9928ece6e0a715c813bdfcfa)

5 years agoAdd second section detailing cascade_backrefs to backref section
Mike Bayer [Tue, 4 Feb 2020 21:46:49 +0000 (16:46 -0500)] 
Add second section detailing cascade_backrefs to backref section

We only have docs for "cascade_backrefs" in the session->cascades
documentation, when this really should be mentioned in the chapter
that's all about backrefs.  Add a similar section and link to the
original for further detail.

Fixes: #5130
Change-Id: I58b6dcafd4ce43e4b9ebd86a40123502c01d4e39
(cherry picked from commit e48c685933b3b6f405134b5cb74f488075ae585d)

5 years agoWarn for runid changing in load events; add restore_load_context flag
Mike Bayer [Fri, 31 Jan 2020 16:10:08 +0000 (11:10 -0500)] 
Warn for runid changing in load events; add restore_load_context flag

Added a new flag :paramref:`.InstanceEvents.restore_load_context` and
:paramref:`.SessionEvents.restore_load_context` which apply to the
:meth:`.InstanceEvents.load`, :meth:`.InstanceEvents.refresh`, and
:meth:`.SessionEvents.loaded_as_persistent` events, which when set will
restore the "load context" of the object after the event hook has been
called.  This ensures that the object remains within the "loader context"
of the load operation that is already ongoing, rather than the object being
transferred to a new load context due to refresh operations which may have
occurred in the event. A warning is now emitted when this condition occurs,
which recommends use of the flag to resolve this case.  The flag is
"opt-in" so that there is no risk introduced to existing applications.

The change additionally adds support for the ``raw=True`` flag to
session lifecycle events.

Fixes: #5129
Change-Id: I2912f48ac8c5636297d63ed383454930e8e9a6a3
(cherry picked from commit 10b7937bb9994c365436af5e0c1931b2b07d12b1)

5 years agoMerge "Accommodate for base class when adjusting path for with_polymorphic" into...
mike bayer [Tue, 28 Jan 2020 20:51:54 +0000 (20:51 +0000)] 
Merge "Accommodate for base class when adjusting path for with_polymorphic" into rel_1_3

5 years agoMerge "Add py3.8, py3.9 token to setup.py" into rel_1_3
mike bayer [Tue, 28 Jan 2020 20:48:57 +0000 (20:48 +0000)] 
Merge "Add py3.8, py3.9 token to setup.py" into rel_1_3

5 years agoAccommodate for base class when adjusting path for with_polymorphic
Mike Bayer [Tue, 28 Jan 2020 17:34:06 +0000 (12:34 -0500)] 
Accommodate for base class when adjusting path for with_polymorphic

Fixed an additional regression in the same area as that of :ticket:`5080`
introduced in 1.3.0b3 via :ticket:`4468` where the ability to create a
joined option across a :func:`.with_polymorphic` into a relationship
against the base class of that with_polymorphic, and then further into
regular mapped relationships would fail as the base class component would
not add itself to the load path in a way that could be located by the
loader strategy. The changes applied in :ticket:`5080` have been further
refined to also accommodate this scenario.

Fixes: #5121
Change-Id: I9753dbbcb7b7640c995ad983a6d04b36fa18cf54
(cherry picked from commit c9406e58a4fd2de4bb2fd53530e04cc9fc786cbf)

5 years agoAdd pyproject
Federico Caselli [Mon, 27 Jan 2020 21:51:05 +0000 (16:51 -0500)] 
Add pyproject

- Added pyproject.toml with black arguments
- Updated black version in precommit hook
- Reformatted the code

Fixes: #5100
Closes: #5103
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5103
Pull-request-sha: 795fd5f896be4a07a2b18e6525674b815ac17593

Change-Id: I14eedbaa51fb531cbf90fcefe6a1e07c8a565625
(cherry picked from commit f49a3fc02c03e39b3d34da9dfba4fe46d71c4aff)

5 years agoAdd py3.8, py3.9 token to setup.py
Gord Thompson [Mon, 27 Jan 2020 21:49:28 +0000 (16:49 -0500)] 
Add py3.8, py3.9 token to setup.py

Fixes: #5113
<!-- Provide a general summary of your proposed changes in the Title field above -->

### Description
Add py3.8 and py3.9 tokens to setup.py

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

-->

This pull request is:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [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: #5115
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5115
Pull-request-sha: 5ae662f1ec0d89a16a03fe60d6f12712d0d21398

Change-Id: I1313df9bd117b1356c1d06d588e8e04a07ba4e39
(cherry picked from commit 9a7c65c908dc00b66e10205d5a039a2b578f116e)

5 years agoRefactor test provisioning to dialect-level files
Gord Thompson [Mon, 13 Jan 2020 01:08:22 +0000 (20:08 -0500)] 
Refactor test provisioning to dialect-level files

Fixes: #5085
<!-- Provide a general summary of your proposed changes in the Title field above -->

Move dialect-specific provisioning code to dialect-level copies of provision.py.

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

-->

This pull request is:

- [ ] A documentation / typographical error fix
- Good to go, no issue or tests are needed
- [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: #5092
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5092
Pull-request-sha: 25b9b7a9800549fb823576af8674e8d33ff4b2c1

Change-Id: Ie0b4a69aa472a60bdbd825e04c8595382bcc98e1
(cherry picked from commit 6fb7b527426b564302d6fd8ca11dfa7b78cc2e7a)

5 years agoMerge "Add keywords to MutableList.sort()" into rel_1_3
mike bayer [Fri, 24 Jan 2020 17:59:37 +0000 (17:59 +0000)] 
Merge "Add keywords to MutableList.sort()" into rel_1_3

5 years agoAdd test requirement: indexes_with_ascdesc
Gord Thompson [Mon, 20 Jan 2020 20:21:17 +0000 (15:21 -0500)] 
Add test requirement: indexes_with_ascdesc

There are some tests for indexes that include DESC in the
columns.  Firebird and maybe others don't support this concept,
so put it under a requirement rule.

Fixes: #5106
Closes: #5108
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5108
Pull-request-sha: 4b1560f28a52feb7d4a6c5d828f587a735d6a40b

Change-Id: I4744246005f3af263ea1e028d8a46795b87de62c
(cherry picked from commit 9e3977738c7c698442cb88f4201f995d8901a45f)

5 years agoAdd keywords to MutableList.sort()
Mike Bayer [Thu, 23 Jan 2020 17:28:18 +0000 (12:28 -0500)] 
Add keywords to MutableList.sort()

Added keyword arguments to the :meth:`.MutableList.sort` function so that a
key function as well as the "reverse" keyword argument can be provided.

Fixes: #5114
Change-Id: Iefb29e1ccadfad6ecba558ce575029307001b88e
(cherry picked from commit b98403f0c269a1073e8e25599d4a98147cfa425f)

5 years agoInstanceState default path is RootRegistry, not tuple
Mike Bayer [Wed, 22 Jan 2020 21:27:26 +0000 (16:27 -0500)] 
InstanceState default path is RootRegistry, not tuple

Fixed regression caused in 1.3.13 by :ticket:`5056` where a refactor of the
ORM path registry system made it such that a path could no longer be
compared to an empty tuple, which can occur in a particular kind of joined
eager loading path.   The "empty tuple" use case has been resolved so that
the path registry is compared to a path registry in all cases;  the
:class:`.PathRegistry` object itself now implements ``__eq__()`` and
``__ne__()`` methods which will take place for all equality comparisons and
continue to succeed in the not anticipated case that a non-
:class:`.PathRegistry` object is compared, while emitting a warning that
this object should not be the subject of the comparison.

Fixes: #5110
Change-Id: I6cab6cd771c131d12b17939b369212f12c6bee16
(cherry picked from commit f5eeac3d18892206abcaa30a295d12a799a8fb9b)

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