]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
5 years agoRewrite pool reset_on_return parsing using a util function
Mike Bayer [Sun, 11 Aug 2019 19:24:13 +0000 (15:24 -0400)] 
Rewrite pool reset_on_return parsing using a util function

Choosing a util.symbol() based on a user parameter is about to have
another use case added as part of #4623, so add a generalized solution
ahead of it.

Change-Id: I420631f81af2ffc655995b9cce9ff2ac618c16d7
(cherry picked from commit 2a079cdc76b3a0f5b4f37299d280d328586e2f7e)

5 years agoUse ternary when running conditional with Query._offset
Mike Bayer [Sun, 11 Aug 2019 14:54:49 +0000 (10:54 -0400)] 
Use ternary when running conditional with Query._offset

Fixed bug where using :meth:`.Query.first` or a slice expression in
conjunction with a query that has an expression based "offset" applied
would raise TypeError, due to an "or" conditional against "offset" that did
not expect it to be a SQL expression as opposed to an integer or None.

Fixes: #4803
Change-Id: I56b97a5d23cb45427a27a90ab557fa1ac5c6739e
(cherry picked from commit 97d2a2091ed4caee1e19168d0db39e4d94a6d12f)

5 years agoEmit SET NAMES for all MySQL connections w charset
Mike Bayer [Sun, 11 Aug 2019 21:42:59 +0000 (17:42 -0400)] 
Emit SET NAMES for all MySQL connections w charset

The MySQL dialects will emit "SET NAMES" at the start of a connection when
charset is given to the MySQL driver, to appease an apparent behavior
observed in MySQL 8.0 that raises a collation error when a UNION includes
string columns unioned against columns of the form CAST(NULL AS CHAR(..)),
which is what SQLAlchemy's polymorphic_union function does.   The issue
seems to have affected PyMySQL for at least a year, however has recently
appeared as of mysqlclient 1.4.4 based on changes in how this DBAPI creates
a connection.  As the presence of this directive impacts three separate
MySQL charset settings which each have intricate effects based on their
presense,  SQLAlchemy will now emit the directive on new connections to
ensure correct behavior.

Fixes: #4804
Change-Id: If9d7ee00d0ccaf773972b564fe455e8e9edf6627
(cherry picked from commit f5e57f7c311288d892894edcc44d901b5bfbb3d1)

5 years ago- shore up TypeDecorator docs a bit to not render tons of
Mike Bayer [Sun, 11 Aug 2019 02:20:31 +0000 (22:20 -0400)] 
- shore up TypeDecorator docs a bit to not render tons of
comparator methods

Change-Id: I8f434b18b2bd632a0db0db1376262944272d2198
(cherry picked from commit 731a20049b372ee2e0c7408519623363e22a4db4)

5 years agoClarify INSERT/UPDATE defaults vs. data marshalling
Mike Bayer [Sat, 10 Aug 2019 22:17:59 +0000 (18:17 -0400)] 
Clarify INSERT/UPDATE defaults vs. data marshalling

- Add a full introductory paragraph to INSERT/UPDATE defaults
stating what we mean when we talk about this concept.  Add a note
differentiating what a default does, vs. a rule that intercepts
data as it moves into the database, providing links

- Add a quick section referring to TypeDecorator in the ORM
section on modifying attribute behavior

- Add an "ORM tip", a new thing that we can use in Core to link
to ORM concepts when useful, in the TypeDecorator section which
mentions that for more open ended conversion of arbitrary user
data based on business rules, @validates might be useful
(although this still does not suit the case of full blown form
validation).

- add glossary entries for DML, data marshalling since we already
use these terms and I'd like to refer to them more often.

Fixes: #4796
Change-Id: Ic4cd5c1595fd51c00a9bf24c021d2e56d457d346
(cherry picked from commit cda0b4a2b909be55cef7a844a04689ec527041c0)

5 years agoCorrect name for json_serializer / json_deserializer, document and test
Mike Bayer [Fri, 9 Aug 2019 03:34:20 +0000 (23:34 -0400)] 
Correct name for json_serializer / json_deserializer, document and test

The dialects that support json are supposed to take arguments
``json_serializer`` and ``json_deserializer`` at the create_engine() level,
however the SQLite dialect calls them ``_json_serilizer`` and
``_json_deserilalizer``.  The names have been corrected, the old names are
accepted with a change warning, and these parameters are now documented as
:paramref:`.create_engine.json_serializer` and
:paramref:`.create_engine.json_deserializer`.

Fixes: #4798
Change-Id: I1dbfe439b421fe9bb7ff3594ef455af8156f8851
(cherry picked from commit 104e6907284e602a8485f32fc67fd6af0c00e4d0)

5 years agoFix typo
Nils Philippsen [Sat, 27 Jul 2019 21:13:03 +0000 (23:13 +0200)] 
Fix typo

(cherry picked from commit 867b119061759d283b9695bbf2f3e960979a96f8)

5 years agoStrong reference listen function wrapped by "once"
Mike Bayer [Sat, 3 Aug 2019 03:20:06 +0000 (23:20 -0400)] 
Strong reference listen function wrapped by "once"

Fixed issue in event system where using the ``once=True`` flag with
dynamically generated listener functions would cause event registration of
future events to fail if those listener functions were garbage collected
after they were used, due to an assumption that a listened function is
strongly referenced.  The "once" wrapped is now modified to strongly
reference the inner function persistently, and documentation is updated
that using "once" does not imply automatic de-registration of listener
functions.

Fixes: #4794
Change-Id: I06388083d1633dcc89e8919eb1e51270f966df38
(cherry picked from commit e22d2b089fad1f79d53bc6238626f32f0e796ad0)

5 years agoAlways include a schema name in SQLite PRAGMA
Mike Bayer [Fri, 2 Aug 2019 17:03:29 +0000 (13:03 -0400)] 
Always include a schema name in SQLite PRAGMA

Fixed bug where usage of "PRAGMA table_info" in SQLite dialect meant that
reflection features to detect for table existence, list of table columns,
and list of foreign keys, would default to any table in any attached
database, when no schema name was given and the table did not exist in the
base schema.  The fix explicitly runs PRAGMA for the 'main' schema and then
the 'temp' schema if the 'main' returned no rows, to maintain the behavior
of tables + temp tables in the "no schema" namespace, attached tables only
in the "schema" namespace.

Fixes: #4793
Change-Id: I75bc03ef42581c46b98987510d2d2e701df07412
(cherry picked from commit e091775f1c4c817093e9a936a3abc79b5e311f93)

5 years agoDon't assume key when matching cloned columns in _make_proxy
Mike Bayer [Thu, 1 Aug 2019 15:45:34 +0000 (11:45 -0400)] 
Don't assume key when matching cloned columns in _make_proxy

Fixed issue where internal cloning of SELECT constructs could lead to a key
error if the copy of the SELECT changed its state such that its list of
columns changed.  This was observed to be occurring in some ORM scenarios
which may be unique to 1.3 and above, so is partially a regression fix.

For 1.4, the _is_clone_of key will be removed entirely as it seems to
have no purpose.  This commit is the initial backport to 1.3 which
includes tests.

Fixes: #4780
Change-Id: I0c64962a2eba3763bea3107fc7c7d7aed8244430
(cherry picked from commit 896d47f318c5c27620fd6da805f98811941b88c5)

5 years agoMerge "Invoke column_expression() for subsequent SELECTs in CompoundSelect" into...
mike bayer [Tue, 30 Jul 2019 01:57:01 +0000 (01:57 +0000)] 
Merge "Invoke column_expression() for subsequent SELECTs in CompoundSelect" into rel_1_3

5 years agoInvoke column_expression() for subsequent SELECTs in CompoundSelect
Mike Bayer [Mon, 29 Jul 2019 18:49:22 +0000 (14:49 -0400)] 
Invoke column_expression() for subsequent SELECTs in CompoundSelect

Fixed bug where :meth:`.TypeEngine.column_expression` method would not be
applied to subsequent SELECT statements inside of a UNION or other
:class:`.CompoundSelect`, even though the SELECT statements are rendered at
the topmost level of the statement.   New logic now differentiates between
rendering the column expression, which is needed for all SELECTs in the
list, vs. gathering the returned data type for the result row, which is
needed only for the first SELECT.

Fixes: #4787
Change-Id: Iceb63e430e76d2365649aa25ead09c4e2a062e10
(cherry picked from commit 2ce8a04e726daecbf060684dcee7559634506700)

5 years agoCorrect for MySQL 8.0 table and schema names in FK reflection
Mike Bayer [Mon, 29 Jul 2019 18:07:21 +0000 (14:07 -0400)] 
Correct for MySQL 8.0 table and schema names in FK reflection

Added another fix for an upstream MySQL 8 issue where a case sensitive
table name is reported incorrectly in foreign key constraint reflection,
this is an extension of the fix first added for :ticket:`4344` which
affects a case sensitive column name.  The new issue occurs through MySQL
8.0.17, so the general logic of the 88718 fix remains in place.

.. seealso::

    https://bugs.mysql.com/bug.php?id=96365 - upstream bug

Fixes: #4751
Change-Id: I391903565db919b85b6b3c62c28f4b90ee596135
(cherry picked from commit 9a6654e3af74710b55feb6b5b0218dc767d7013b)

6 years agoMerge "Add ARRAY and MEMBER to MySQL reserved words" into rel_1_3
mike bayer [Sat, 27 Jul 2019 17:56:48 +0000 (17:56 +0000)] 
Merge "Add ARRAY and MEMBER to MySQL reserved words" into rel_1_3

6 years agoAdd ARRAY and MEMBER to MySQL reserved words
Mike Bayer [Sat, 27 Jul 2019 14:43:59 +0000 (10:43 -0400)] 
Add ARRAY and MEMBER to MySQL reserved words

Also sort the listing of reserved words.

Fixes: #4783
Change-Id: I8a7370a424d7c78efb4916d3307600b8e85f98ac
(cherry picked from commit d08d27b897569ff8f18ca869b00a058652111c24)

6 years agoEnsure all Index arguments are counted when matching expr/columns
Mike Bayer [Tue, 23 Jul 2019 22:38:48 +0000 (18:38 -0400)] 
Ensure all Index arguments are counted when matching expr/columns

Fixed issue where :class:`.Index` object which contained a mixture of
functional expressions which were not resolvable to a particular column,
in combination with string-based column names, would fail to initialize
its internal state correctly leading to failures during DDL compilation.

Fixes: #4778
Change-Id: I0fa9c627a1fde92ba8b9ed10af167c156012bd5d
(cherry picked from commit 33616a85c7c35ec1b1756a43e44a621b744e75fa)

6 years agoDon't assume m2o key is present in the dictionary
Mike Bayer [Tue, 23 Jul 2019 13:24:32 +0000 (09:24 -0400)] 
Don't assume m2o key is present in the dictionary

Fixed regression caused by new selectinload for many-to-one logic where
a primaryjoin condition not based on real foreign keys would cause
KeyError if a related object did not exist for a given key value on the
parent object.

Fixes: #4777
Change-Id: I4ba96318302be68abe0e8c3611684087a04a2322
(cherry picked from commit 8f5b65f4316e21d19b00266cdd9eded3d4ec51b2)

6 years agoVersion 1.3.7 placeholder
Mike Bayer [Sun, 21 Jul 2019 21:10:02 +0000 (17:10 -0400)] 
Version 1.3.7 placeholder

6 years ago- 1.3.6 rel_1_3_6
Mike Bayer [Sun, 21 Jul 2019 20:37:07 +0000 (16:37 -0400)] 
- 1.3.6

6 years agoFix typos
Min ho Kim [Sun, 21 Jul 2019 00:51:29 +0000 (10:51 +1000)] 
Fix typos

(cherry picked from commit 7e588aadaab27a53b226a4637be9b4022ab46956)

Change-Id: Ibd2fbf365ed2b8f0d1765ef7271d28ab3a2d073a

6 years agoOptimize out JOIN for selectinload with many to one
Mike Bayer [Fri, 19 Jul 2019 17:05:06 +0000 (13:05 -0400)] 
Optimize out JOIN for selectinload with many to one

The optimzation applied to selectin loading in :ticket:`4340` where a JOIN
is not needed to eagerly load related items is now applied to many-to-one
relationships as well, so that only the related table is queried for a
simple join condition.   In this case, the related items are queried
based on the value of a foreign key column on the parent; if these columns
are deferred or otherwise not loaded on any of the parent objects in
the collection, the loader falls back to the JOIN method.

Fixes: #4775
Change-Id: I398e0d276789ce6e0019d213a37bdf99d24ec290
(cherry picked from commit a5a66f1e580150a55a729e7b6dc804adb55b2f5c)

6 years agoMerge "Include 'p' for get_indexes() query" into rel_1_3
mike bayer [Fri, 19 Jul 2019 20:24:36 +0000 (20:24 +0000)] 
Merge "Include 'p' for get_indexes() query" into rel_1_3

6 years agoInclude 'p' for get_indexes() query
Mike Bayer [Fri, 19 Jul 2019 14:40:27 +0000 (10:40 -0400)] 
Include 'p' for get_indexes() query

Added support for reflection of indexes on PostgreSQL partitioned tables,
which was added to PostgreSQL as of version 11.

Fixes: #4771
Change-Id: I9e8e75c4d8a667b4d52d12afbd384e0a8db00466
(cherry picked from commit a739a3449ff20ba90f92305ed4bbdd36e05bc862)

6 years agoSupport tuple IN VALUES for SQLite, others
Mike Bayer [Tue, 16 Jul 2019 16:41:09 +0000 (12:41 -0400)] 
Support tuple IN VALUES for SQLite, others

Added support for composite (tuple) IN operators with SQLite, by rendering
the VALUES keyword for this backend.  As other backends such as DB2 are
known to use the same syntax, the syntax is enabled in the base compiler
using a dialect-level flag ``tuple_in_values``.   The change also includes
support for "empty IN tuple" expressions for SQLite when using "in_()"
between a tuple value and an empty set.

Fixes: #4766
Change-Id: I416e1af29b31d78f9ae06ec3c3a48ef6d6e813f5
(cherry picked from commit 88168db8e9a51ce438e06bfe792e758ed9297ab8)

6 years agoMerge "Fixes for uselist=True with m2o relationships" into rel_1_3
mike bayer [Thu, 18 Jul 2019 16:55:33 +0000 (16:55 +0000)] 
Merge "Fixes for uselist=True with m2o relationships" into rel_1_3

6 years agoFix regression for self-ref join to self error message
Mike Bayer [Thu, 18 Jul 2019 15:12:49 +0000 (11:12 -0400)] 
Fix regression for self-ref join to self error message

Fixed regression caused by :ticket:`4365` where a join from an entity to
itself without using aliases no longer raises an informative error message,
instead failing on an assertion.  The informative error condition has been
restored.

Fixes: #4773
Change-Id: Iabeb56f3f0c2a40e350fd7c69f07c02dc9804c2c
(cherry picked from commit 736186f840646773217d3f7ba3f6a5d0bbfe1fdb)

6 years agoFixes for uselist=True with m2o relationships
Mike Bayer [Thu, 18 Jul 2019 14:58:24 +0000 (10:58 -0400)] 
Fixes for uselist=True with m2o relationships

Fixed bug where a many-to-one relationship that specified ``uselist=True``
would fail to update correctly during a primary key change where a related
column needs to change.

Fixed bug where the detection for many-to-one or one-to-one use with a
"dynamic" relationship, which is an invalid configuration, would fail to
raise if the relationship were configured with ``uselist=True``.  The
current fix is that it warns, instead of raises, as this would otherwise be
backwards incompatible, however in a future release it will be a raise.

Fixes: #4772
Change-Id: Ibd5d2f7329ff245c88118e2533fc8ef42a09fef3
(cherry picked from commit 5e8c7c88de2d9bac58e82bc1e5af7fcad5405855)

6 years agoSmall text error in json field doc
Denis Kataev [Mon, 8 Jul 2019 16:32:20 +0000 (21:32 +0500)] 
Small text error in json field doc

Small fix json field doc

(cherry picked from commit 7b8ff3c335938532b70e6ffff212bd8f67c56add)

6 years agoFix doc for #4765
Denis Kataev [Wed, 17 Jul 2019 16:02:53 +0000 (21:02 +0500)] 
Fix doc for #4765

(cherry picked from commit 86d8b12a6b3f3d5481614dd79aa1977e93d91d8b)

6 years agoIntercept unresolveable comparator attrbute error for attr access
Mike Bayer [Tue, 16 Jul 2019 17:02:16 +0000 (13:02 -0400)] 
Intercept unresolveable comparator attrbute error for attr access

Fixed bug where a synonym created against a mapped attribute that does not
exist yet, as is the case when it refers to backref before mappers are
configured, would raise recursion errors when trying to test for attributes
on it which ultimately don't exist (as occurs when the classes are run
through Sphinx autodoc), as the unconfigured state of the synonym would put
it into an attribute not found loop.

Fixes: #4767
Change-Id: I9aade8628349fbf538181a0049416cec0a17179c
(cherry picked from commit 234723fa296c9fa7ac63f1c4d877edc7ba120edd)

6 years agoPin pycodestyle
Mike Bayer [Wed, 17 Jul 2019 14:40:03 +0000 (10:40 -0400)] 
Pin pycodestyle

PyCQA/pydocstyle#375

Change-Id: Ifc7ead440010e89474300407fea5770956ff1aaf
(cherry picked from commit 1a9f5754e088ff521bf41bddc42b32ec989a8877)

6 years agoSyntaxError in on_duplicate_key_update() example.
Peter Schutt [Mon, 15 Jul 2019 03:51:28 +0000 (13:51 +1000)] 
SyntaxError in on_duplicate_key_update() example.

(cherry picked from commit 26ef5ed862270bda4ab6abe544add9f8bb7ac72f)

6 years agoself_group() for FunctionFilter
Mike Bayer [Sat, 13 Jul 2019 02:43:31 +0000 (22:43 -0400)] 
self_group() for FunctionFilter

Fixed issue where the :class:`.array_agg` construct in combination with
:meth:`.FunctionElement.filter` would not produce the correct operator
precedence between the FILTER keyword and the array index operator.

Fixes: #4760
Change-Id: Ic662cd3da3330554ec673bafd80495b3f1506098
(cherry picked from commit 116faee662f618d5ecd13b1e074a27d5e5a40564)

6 years agoAdd performance improvement for Enum w/ Python 2 enum library
Mike Bayer [Wed, 10 Jul 2019 20:12:48 +0000 (16:12 -0400)] 
Add performance improvement for Enum w/ Python 2 enum library

Adjusted the initialization for :class:`.Enum` to minimize how often it
invokes the ``.__members__`` attribute of a given PEP-435 enumeration
object, to suit the case where this attribute is expensive to invoke, as is
the case for some popular third party enumeration libraries.

Fixes: #4758
Change-Id: Iffeb854c67393bdcb288944fc357a074e20e1325
(cherry picked from commit 2cc7308c96f5598ba0aea9a240b9a52629042d07)

6 years agoSupport multidimensional array literals in Postgresql
Mike Bayer [Mon, 8 Jul 2019 19:46:35 +0000 (15:46 -0400)] 
Support multidimensional array literals in Postgresql

Added support for multidimensional Postgresql array literals via nesting
the :class:`.postgresql.array` object within another one.  The
multidimensional array type is detected automatically.

Fixes: #4756
Change-Id: Ie2107ad3cf291112f6ca330dc90dc15a0a940cee
(cherry picked from commit 6bc7e0bfa9cd284e439c3b7ea67ab53014ac2773)

6 years agoEnsure .engine is part of Connectable interface, implement as descriptor
Mike Bayer [Mon, 8 Jul 2019 14:42:20 +0000 (10:42 -0400)] 
Ensure .engine is part of Connectable interface, implement as descriptor

Fixed bug where using reflection function such as :meth:`.MetaData.reflect`
with an :class:`.Engine` object that had execution options applied to it
would fail, as the resulting :class:`.OptionEngine` proxy object failed to
include a ``.engine`` attribute used within the reflection routines.

Fixes: #4754
Change-Id: I6c342af5c6db6fe362b9d25f3f26d6859f62f87a
(cherry picked from commit 3238d953b42f67761dc3019bd27f2960ae2e525f)

6 years agoAdd additional parsing to extract the "MariaDB" keyword from version string
Mike Bayer [Tue, 23 Apr 2019 22:33:08 +0000 (17:33 -0500)] 
Add additional parsing to extract the "MariaDB" keyword from version string

Enhanced MySQL/MariaDB version string parsing to accommodate for exotic
MariaDB version strings where the "MariaDB" word is embedded among other
alphanumeric characters such as "MariaDBV1".   This detection is critical in
order to correctly accomodate for API features that have split between MySQL
and MariaDB such as the "transaction_isolation" system variable.

Fixes: #4624
Change-Id: Iba4b56535855629a974b1e24e012b07383d24199
(cherry picked from commit 95dd8768d430b667ef2d7c104733aff2bae757b2)

6 years agoRepair json example in tutorial to suit non-present sqlite support
Mike Bayer [Fri, 5 Jul 2019 22:11:31 +0000 (18:11 -0400)] 
Repair json example in tutorial to suit non-present sqlite support

SQLite on CI doesn't have json functions (centos) so even
though SQLAlchemy supports it in this version, use the MySQL
compiler for the example.

Change-Id: If896273adbab2e3fdb995272f6e55de420aee220
(cherry picked from commit 1ce98ca83a4b2da12e52aa0f4ab181c83063abc2)

6 years agoAdjust JSON verbiage about "implied" datatype
Mike Bayer [Fri, 5 Jul 2019 20:16:22 +0000 (16:16 -0400)] 
Adjust JSON verbiage about "implied" datatype

SQLite and MariaDB (not MySQL) has an "implied" JSON,
MySQL has it directly

Change-Id: I2e1744de96ac4e241dc647ae2214b63cdad33428
(cherry picked from commit 1abbdf0d5233f2aa96805544381a5c14151525e4)

6 years agoRename tutorial section to "Using Aliases and Subqueries"
Mike Bayer [Fri, 5 Jul 2019 19:55:20 +0000 (15:55 -0400)] 
Rename tutorial section to "Using Aliases and Subqueries"

add some verbiage to start differentiating a subquery from
an alias.

Also, get rid of a very strange note to use ``.correlate(None)``
on a non-scalar subquery; this is unnecessary and confusing.

Change-Id: I83b2fd1275c719a32bb74060756d61bc51b52892
(cherry picked from commit f4f9ec1c2f6fad29729ee379adb537f8648d1737)

6 years agoNote DBAPIs and dialects that we don't support
Mike Bayer [Fri, 5 Jul 2019 16:19:55 +0000 (12:19 -0400)] 
Note DBAPIs and dialects that we don't support

Since we have strong CI for the DBAPIs and dialects that are actively
supported, this indicates that those DBAPIs that aren't in CI are
continuing to fall behind in support, to the point where we can
not address issues that may arise. As such, the Sybase and Firebird
dialects overall are moving into an explicit "not supported" zone
where we would like to eventually remove them.   Additionally,
a pass is made through legacy MySQL and PostgreSQL DBAPI dialects
as well as those which we aren't able to include in CI to note
that these DBAPIs aren't actively supported by the project.

Change-Id: I61f1515b97b741b7534b54e434e3e47065df7b5d
(cherry picked from commit 4bd4bae5c1132e1ca41425f742402d06026a918a)

6 years agoSquashed commit of the following:
Mike Bayer [Fri, 5 Jul 2019 14:06:16 +0000 (10:06 -0400)] 
Squashed commit of the following:

commit d4f3bedc74568b7ec543988ee2d43e64c5ace28f
Author: Carson Ip <carsonip@users.noreply.github.com>
Date:   Fri Jul 5 11:20:12 2019 +0800

    Fix typo in docstring

commit a3e4b05744f51ec5d12a2fee1ad6093de904273e
Author: Carson Ip <carsonip@users.noreply.github.com>
Date:   Fri Jul 5 11:14:57 2019 +0800

    Fix typo in docstring

Change-Id: Ifa2ebff5629bf970e5fac28bba64d501376cfae9
(cherry picked from commit 28daa34cb887e0f07e9f53e4b9e7596e6df12cd9)

6 years agoAdd tutorial section for cast(), type_coerce()
Mike Bayer [Thu, 4 Jul 2019 15:16:50 +0000 (11:16 -0400)] 
Add tutorial section for cast(), type_coerce()

Change-Id: I49f635f0ad4d07abe8ef2681c9660ec7fcf5f99b
(cherry picked from commit e03f7ab50e69ffce67585cdc7a0cb7a3cc5c0cc1)

6 years agoRework proxy_cache fix to restore performance
Mike Bayer [Tue, 2 Jul 2019 22:16:38 +0000 (18:16 -0400)] 
Rework proxy_cache fix to restore performance

Adjustment to the fix made in I7fb134cac3604f8fe62e220fb24a0945d0a1c56f.

Fixes: #4747
Change-Id: I2f1010b0abc1faa892f5e346e58f9c4a3867622f
(cherry picked from commit 9b52c8ae927ae2628dcc1763d2e31245285f4d88)

6 years agoClear proxy_set cache when creating an annotated column
Mike Bayer [Tue, 2 Jul 2019 02:33:26 +0000 (22:33 -0400)] 
Clear proxy_set cache when creating an annotated column

Fixed an unlikely issue where the "corresponding column" routine for unions
and other :class:`.CompoundSelect` objects could return the wrong column in
some overlapping column situtations, thus potentially impacting some ORM
operations when set operations are in use, if the underlying
:func:`.select` constructs were used previously in other similar kinds of
routines, due to a cached value not being cleared.

Fixes: #4747
Change-Id: I7fb134cac3604f8fe62e220fb24a0945d0a1c56f
(cherry picked from commit 6636cd9d256ccbad651eba6553ec46391380cc93)

6 years agoA few doc tweaks for alias / order_by / group_by
Mike Bayer [Mon, 1 Jul 2019 17:09:44 +0000 (13:09 -0400)] 
A few doc tweaks for alias / order_by / group_by

Change-Id: Ib3b46b45735529d68ebfb3784de4de5d2d0f4abc
(cherry picked from commit 3b60ccaed4844d25617221c853b3e46a78fd7974)

6 years agoMerge "CAST bind values against SQL Server sys into NVARCHAR" into rel_1_3
mike bayer [Fri, 28 Jun 2019 17:24:00 +0000 (17:24 +0000)] 
Merge "CAST bind values against SQL Server sys into NVARCHAR" into rel_1_3

6 years agoTest for _ORMJoin and fix issue
Denis Kataev [Fri, 28 Jun 2019 13:57:47 +0000 (09:57 -0400)] 
Test for _ORMJoin and fix issue

Fixed an issue where the :meth:`.orm._ORMJoin.join` method, which is a
not-internally-used ORM-level method that exposes what is normally an
internal process of :meth:`.Query.join`, did not propagate the ``full`` and
``outerjoin`` keyword arguments correctly.  Pull request courtesy Denis
Kataev.

Fixes: #4713
Closes: #4744
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4744
Pull-request-sha: ac8870614947259320b5d000a59fadb8c2328a04

Change-Id: If9a30a4ca56c430ddd6fec29ad519556e9001c4b
(cherry picked from commit a02ed10d5f6aa0e30970305172f51b69e0c49165)

6 years agoCAST bind values against SQL Server sys into NVARCHAR
Mike Bayer [Fri, 28 Jun 2019 14:41:38 +0000 (10:41 -0400)] 
CAST bind values against SQL Server sys into NVARCHAR

Ensured that the queries used to reflect indexes and view definitions will
explicitly CAST string parameters into NVARCHAR, as many SQL Server drivers
frequently treat string values, particularly those with non-ascii
characters or larger string values, as TEXT which often don't compare
correctly against VARCHAR characters in SQL Server's information schema
tables for some reason.    These CAST operations already take place for
reflection queries against SQL Server ``information_schema.`` tables but
were missing from three additional queries that are against ``sys.``
tables.

Fixes: #4745
Change-Id: I3056533bf1a1e8ef17742879d369ab13f8b704ea
(cherry picked from commit 345f2eb05b07713cec19c620b95ca2dfa1ca5aa0)

6 years agoAdd Load.options() for hierchical construction of loader options
Mike Bayer [Thu, 20 Jun 2019 19:37:59 +0000 (15:37 -0400)] 
Add Load.options() for hierchical construction of loader options

Added new loader option method :meth:`.Load.options` which allows loader
options to be constructed hierarchically, so that many sub-options can be
applied to a particular path without needing to call :func:`.defaultload`
many times.  Thanks to Alessio Bogon for the idea.

Also applies a large pass to the loader option documentation which
needed improvement.

Fixes: #4736
Change-Id: I93c453e30a20c074f27e87cf7e95b13dd3f2b494
(cherry picked from commit f0d1a5364fa8a9585b709239f85c4092439c4cd8)

6 years agoUnwrap TIMESTAMP when doing an isinstance()
Mike Bayer [Thu, 27 Jun 2019 17:25:12 +0000 (13:25 -0400)] 
Unwrap TIMESTAMP when doing an isinstance()

Fixed bug where the special logic to render "NULL" for the
:class:`.TIMESTAMP` datatype when ``nullable=True`` would not work if the
column's datatype were a :class:`.TypeDecorator` or a :class:`.Variant`.
The logic now ensures that it unwraps down to the original
:class:`.TIMESTAMP` so that this special case NULL keyword is correctly
rendered when requested.

Fixes: #4743
Change-Id: I02b22dfa3db06daea37b044e2206a8569e2e5d22
(cherry picked from commit 401a2691fbeebd5a26341e732644584cb096bc58)

6 years agoRevert 1ed2f162151 black target version
Mike Bayer [Thu, 27 Jun 2019 20:28:06 +0000 (16:28 -0400)] 
Revert 1ed2f162151 black target version

Unfortunately target version py27 makes Black want to break
print functions, even if you put a "from __future__ import print_function"
at the top, so it is being inconsistent in its "we've decided this
is a python 2 file" logic and basically this thing really needs
command line arguments

Change-Id: Iefa62df4224b9620e764b16b1c390647f948e85f
(cherry picked from commit b0cacfdd4f380cf7e9e3d91458868733bf81f366)

6 years agoDisable black auto-version detection
Mike Bayer [Mon, 24 Jun 2019 17:20:26 +0000 (13:20 -0400)] 
Disable black auto-version detection

We're targeting Python 2.7 still so ensure black does not
add trailing commas

Change-Id: I9896b3a71de855d834f0133fd2d6213aae40fc9d
(cherry picked from commit 1ed2f1621510b48a6c46bedf3dd579c56bd89ccb)

6 years agoRegister pytest assertion rewriting on sqlalchemy.testing.assertions
Mike Bayer [Fri, 21 Jun 2019 19:23:52 +0000 (15:23 -0400)] 
Register pytest assertion rewriting on sqlalchemy.testing.assertions

Since our various eq_(), ne_() etc. functions use assert, pytest
can rewrite this module using its enhanced string reporting.
very helpful for comparing SQL strings

Change-Id: Ia71328401fd7965bcb14eb1ccea0dc48a8f2c3ea
(cherry picked from commit 6da5242953feffac7be29ecab256de372ffc1d31)

6 years agoEnable F841
Mike Bayer [Thu, 30 May 2019 15:31:03 +0000 (11:31 -0400)] 
Enable F841

This is a very useful assertion which prevents unused variables
from being set up allows code to be more readable and sometimes
even more efficient.  test suites seem to be where the most
problems are and there do not seem to be documentation examples
that are using this, or at least the linter is not taking effect
within rst blocks.

Change-Id: I2b3341d8dd14da34879d8425838e66a4b9f8e27d
(cherry picked from commit 190e0139e834e4271268652e058c280787ae69eb)

6 years agoAdd option for "sparse" backend tests and apply to memusage
Mike Bayer [Thu, 20 Jun 2019 21:18:59 +0000 (17:18 -0400)] 
Add option for "sparse" backend tests and apply to memusage

The memusage tests are extremely time and memory intensive,
and when CI runs against MySQL or Postgresql there are many
database/driver combinations for which the "backend" tests
repeatedly run; as these tests are more oriented towards
basic dialect interaction, add a new "sparse" backend option
that will run the tests only once per base dialect.

Change-Id: I312aa0332d7ec1ff4e2faa15f6b189d6f0f68393
(cherry picked from commit 0ad64da3971bd4ac42699cf891fd689e7291cd2f)

6 years agoVersion 1.3.6 placeholder
Mike Bayer [Mon, 17 Jun 2019 18:15:16 +0000 (14:15 -0400)] 
Version 1.3.6 placeholder

6 years ago- 1.3.5 rel_1_3_5
Mike Bayer [Mon, 17 Jun 2019 17:25:51 +0000 (13:25 -0400)] 
- 1.3.5

6 years agoFix typo in documentation examples
Emile Caron [Mon, 17 Jun 2019 14:25:21 +0000 (16:25 +0200)] 
Fix typo in documentation examples

(cherry picked from commit 12253707148910d8dafb79425c0fe7d651b9e151)

6 years agoMerge "Remove unused "time_func"" into rel_1_3
mike bayer [Mon, 17 Jun 2019 14:49:02 +0000 (14:49 +0000)] 
Merge "Remove unused "time_func"" into rel_1_3

6 years agoRemove unused "time_func"
Mike Bayer [Mon, 17 Jun 2019 13:11:01 +0000 (09:11 -0400)] 
Remove unused "time_func"

This compat name is not used and is also referring to a
deprecated API for the win32 case.

Fixes: #4731
Change-Id: I0f2b07347c15455b58c27e29a19fb55e159f332a
(cherry picked from commit 0fff647a8f1fb863ec99195a65cf6e64ce204445)

6 years agoPostgreSQL now reflects per-column sort order on indexes.
Eli Collins [Thu, 13 Jun 2019 14:37:16 +0000 (10:37 -0400)] 
PostgreSQL now reflects per-column sort order on indexes.

Added support for column sorting flags when reflecting indexes for
PostgreSQL, including ASC, DESC, NULLSFIRST, NULLSLAST.  Also adds this
facility to the reflection system in general which can be applied to other
dialects in future releases.  Pull request courtesy Eli Collins.

Fixes: #4717
Closes: #4725
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4725
Pull-request-sha: 3cbb067bd46776fdb125553ba0ac192cb45d060c

Change-Id: I8b0617d68580cfe4ff79d758a077263f33e852c2
(cherry picked from commit b4be7ceb86baeb8e1db4de38911a8c9e7acdd532)

6 years agoMerge "Turn off the is_literal flag when proxying literal_column() to Label" into...
mike bayer [Mon, 17 Jun 2019 01:57:44 +0000 (01:57 +0000)] 
Merge "Turn off the is_literal flag when proxying literal_column() to Label" into rel_1_3

6 years agoTurn off the is_literal flag when proxying literal_column() to Label
Mike Bayer [Sat, 15 Jun 2019 22:06:50 +0000 (18:06 -0400)] 
Turn off the is_literal flag when proxying literal_column() to Label

Fixed a series of quoting issues which all stemmed from the concept of the
:func:`.literal_column` construct, which when being "proxied" through a
subquery to be referred towards by a label that matches its text, the label
would not have quoting rules applied to it, even if the string in the
:class:`.Label` were set up as a :class:`.quoted_name` construct.  Not
applying quoting to the text of the :class:`.Label` is a bug because this
text is strictly a SQL identifier name and not a SQL expression, and the
string should not have quotes embedded into it already unlike the
:func:`.literal_column` which it may be applied towards.   The existing
behavior of a non-labeled :func:`.literal_column` being propagated as is on
the outside of a subquery is maintained in order to help with manual
quoting schemes, although it's not clear if valid SQL can be generated for
such a construct in any case.

Fixes: #4730
Change-Id: I300941f27872fc4298c74a1d1ed65aef1a5cdd82
(cherry picked from commit 009acc95b8804b5b62fbd43c6fdd61d6fd407ef7)

6 years agoConsult is_attrbute flag to determine descriptor; enable for assoc proxy
Mike Bayer [Sat, 15 Jun 2019 02:44:59 +0000 (22:44 -0400)] 
Consult is_attrbute flag to determine descriptor; enable for assoc proxy

Fixed bug where the :attr:`.Mapper.all_orm_descriptors` accessor would
return an entry for the :class:`.Mapper` itself under the declarative
``__mapper___`` key, when this is not a descriptor.  The ``.is_attribute``
flag that's present on all :class:`.InspectionAttr` objects is now
consulted, which has also been modified to be ``True`` for an association
proxy, as it was erroneously set to False for this object.

Fixes: #4729
Change-Id: Ia02388cc25d004e32d337140b62a587f3e5a0b7b
(cherry picked from commit 79d07c9abc7d4d3abb6bf2ca5ca66e87d3a11f08)

6 years agoRun PK/FK sync for multi-level inheritance w/ no intermediary update
Mike Bayer [Wed, 12 Jun 2019 17:15:59 +0000 (13:15 -0400)] 
Run PK/FK sync for multi-level inheritance w/ no intermediary update

Also fix DetectKeySwitch for intermediary class relationship

Fixed a series of related bugs regarding joined table inheritance more than
two levels deep, in conjunction with modification to primary key values,
where those primary key columns are also linked together in a foreign key
relationship as is typical for joined table inheritance.  The intermediary
table in a  three-level inheritance hierachy will now get its UPDATE if
only the primary key value has changed and passive_updates=False (e.g.
foreign key constraints not being enforced), whereas before it would be
skipped; similarly, with passive_updates=True (e.g. ON UPDATE  CASCADE in
effect), the third-level table will not receive an UPDATE statement as was
the case earlier which would fail since CASCADE already modified it.   In a
related issue, a relationship linked to a three-level inheritance hierarchy
on the primary key of an intermediary table of a joined-inheritance
hierarchy will also correctly have its foreign key column updated when the
parent object's primary key is modified, even if that parent object is a
subclass of the linked parent class, whereas before these classes would
not be counted.

Fixes: #4723
Change-Id: Idc408ead67702068e64d583a15149dd4beeefc24
(cherry picked from commit 3f7840c2ade87e415c24c69ac5d0494d294750e0)

6 years agoAccommodate value of None for ON DUPLICATE KEY UPDATE
Lukas Banic [Mon, 10 Jun 2019 15:24:53 +0000 (11:24 -0400)] 
Accommodate value of None for ON DUPLICATE KEY UPDATE

Fixed bug where MySQL ON DUPLICATE KEY UPDATE would not accommodate setting
a column to the value NULL.  Pull request courtesy Lukáš Banič.

Fixes: #4715
Closes: #4716
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4716
Pull-request-sha: bfad6e6bdfb7d6dd5176deaf30d875f3d0f15e06

Change-Id: Ia8831cc171d131bf3824be8db4fd1d231231bba3
(cherry picked from commit 59e9276f04beef4459571cba4226f9d4eaef6be9)

6 years agopsycopg2 NOTICE fixup
Mike Bayer [Sun, 9 Jun 2019 14:59:23 +0000 (10:59 -0400)] 
psycopg2 NOTICE fixup

- don't call relatively expensive isEnabledFor(), just call _log_notices
- don't reset the list if it's empty
- fix the test to use a custom function to definitely create a notice, confirmed
that PG seems to no longer create the "implicit sequence" notices
- assert that the reset of the notices works too
- update the docs to illustrate for folks who haven't worked with logging before

Change-Id: I7291e647c177d338e0ad673f3106b4d503e4b3ea
(cherry picked from commit b0bf421f1b12eeedd77ec6c39df8e5e6cc1fcc3f)

6 years ago- add --max-worker-restart to better tolerate oracle / python 3.8 crashes
Mike Bayer [Sat, 8 Jun 2019 15:23:25 +0000 (11:23 -0400)] 
- add --max-worker-restart to better tolerate oracle / python 3.8 crashes

Change-Id: I4f59cd69dc2319732acf64cb000946c09124ceff
(cherry picked from commit e2521b595ae8b5b4ca8147c5ee13e2fc0f597e63)

6 years agoRework Session transaction FAQs
Mike Bayer [Fri, 7 Jun 2019 18:50:22 +0000 (14:50 -0400)] 
Rework Session transaction FAQs

In preparation for #4712, add an errors.rst code to the Session's
exception about waiting to be rolled back and rework the FAQ entry
to be much more succinct.  When this FAQ was first written, I found
it hard to describe why flush worked this way but as the use case is
clearer now, and #4712 actually showed it being confusing when it doesn't
work this way, we can make a simpler and more definitive statement
about this behavior.   Additionally, language about "subtransactions"
is minimized as I might be removing or de-emphasizing this concept in
2.0 (though maybe not as it does seem to work well).

Change-Id: I557872aff255b07e14dd843aa024e027a017afb8
(cherry picked from commit 4bd3cf69b2a7f5b1977e7be2b8588fd5d3424d11)

6 years agoApply adaptation for most recent aliased=True first
Mike Bayer [Fri, 31 May 2019 20:47:19 +0000 (16:47 -0400)] 
Apply adaptation for most recent aliased=True first

Fixed regression in :meth:`.Query.join` where the ``aliased=True`` flag
would not properly apply clause adaptation to filter criteria, if a
previous join were made to the same entity.  This is because the adapters
were placed in the wrong order.   The order has been reversed so that the
adapter for the most recent ``aliased=True`` call takes precedence as was
the case in 1.2 and earlier.  This broke the "elementtree" examples among
other things.

Fixes: #4704
Change-Id: I69f76c97b11157100854d552b5a0ce0103642ec4
(cherry picked from commit e6572789bb6fec5f1ac07653908c0f29d7904ece)

6 years agoMerge "PostgreSQL enum with no elements returns NULL for the "label", skip this"...
mike bayer [Fri, 31 May 2019 12:03:41 +0000 (12:03 +0000)] 
Merge "PostgreSQL enum with no elements returns NULL for the "label", skip this" into rel_1_3

6 years agoPostgreSQL enum with no elements returns NULL for the "label", skip this
Mike Bayer [Fri, 31 May 2019 00:42:35 +0000 (20:42 -0400)] 
PostgreSQL enum with no elements returns NULL for the "label", skip this

Fixed bug where PostgreSQL dialect could not correctly reflect an ENUM
datatype that has no members, returning a list with ``None`` for the
``get_enums()`` call and raising a TypeError when reflecting a column which
has such a datatype.   The inspection now returns an empty list.

Fixes: #4701
Change-Id: I202bab19728862cbc64deae211d5ba6a103b8317
(cherry picked from commit 754e7f52cf64b72988bdf8211c603809b32c16de)

6 years agoRework AliasedClass __getattr__ to use top-level getattr()
Dmytro Starosud [Wed, 29 May 2019 13:47:13 +0000 (16:47 +0300)] 
Rework AliasedClass __getattr__ to use top-level getattr()

Reworked the attribute mechanics used by :class:`.AliasedClass` to no
longer rely upon calling ``__getattribute__`` on the MRO of the wrapped
class, and to instead resolve the attribute normally on the wrapped class
using getattr(), and then unwrap/adapt that.  This allows a greater range
of attribute styles on the mapped class including special ``__getattr__()``
schemes; but it also makes the code simpler and more resilient in general.

Fixes: #4694
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: I28901e2472d3c21e881fe5cafa3b1d3af704fad8
(cherry picked from commit 5ac10699e1111283ae848f9d3a6dcc4e09d8c1ef)

6 years agoUse fully vendored getfullargspec
Mike Bayer [Wed, 29 May 2019 21:27:19 +0000 (17:27 -0400)] 
Use fully vendored getfullargspec

Replaced the Python compatbility routines for ``getfullargspec()`` with a
fully vendored version from Python 3.3.  Originally, Python was emitting
deprecation warnings for this function in Python 3.8 alphas.  While this
change was reverted, it was observed that Python 3 implementations for
``getfullargspec()`` are an order of magnitude slower as of the 3.4 series
where it was rewritten against ``Signature``.  While Python plans to
improve upon this situation, SQLAlchemy projects for now are using a simple
replacement to avoid any future issues.

Fixes: #4674
Change-Id: I1ab8729c4072634db80c79bb7bc44197dc5e7114
(cherry picked from commit df99e1ef5f334ce7f4c8118c3e0bdf2949f54de3)

6 years agoupdate LICENSE to be the exact MIT formatting
Mike Bayer [Tue, 28 May 2019 16:40:31 +0000 (12:40 -0400)] 
update LICENSE to be the exact MIT formatting

Change-Id: I9ee75862924cd8f95ea8d812ab2e2a0ff4e48a66
(cherry picked from commit e624c2cc70d970687cf027c4527fe6f9fa870bc0)

6 years agoReformat license name
Mike Bayer [Tue, 28 May 2019 13:46:20 +0000 (09:46 -0400)] 
Reformat license name

While we have the OSI classifier for "MIT License", it looks
like for the "license" field, this is normally just the word
"MIT" and not "MIT License".   While the pypa docs suggest we
only need it as the OSI classifier, keep it also in "license"
in order to appease common tooling.

Change-Id: Ife51bbc74d6c1b8ab9a736024818fbba35316e17
(cherry picked from commit fff65b814a16914aae41bd63cdef6bf55a676c67)

6 years agoVersion 1.3.5 placeholder
Mike Bayer [Tue, 28 May 2019 02:11:35 +0000 (22:11 -0400)] 
Version 1.3.5 placeholder

6 years ago- 1.3.4 rel_1_3_4
Mike Bayer [Tue, 28 May 2019 01:54:20 +0000 (21:54 -0400)] 
- 1.3.4

6 years agoAdjust test_concurrency failure modes
Mike Bayer [Tue, 28 May 2019 01:15:47 +0000 (21:15 -0400)] 
Adjust test_concurrency failure modes

The test added for #4686 can raise for "B" missing which
is normal and should not fail the test.  Also ensure mappers are
cleared to prevent subsequent tests elsewhere from being
affected.

Change-Id: I4c5791223e7fd21e04dcd095daa7d868e77dbd97
(cherry picked from commit 8b2eb2a2d0f4c7e283d96cf3e5263b5dd48e3b14)

6 years agoMerge "MYSQL: added support for drop check/constraint" into rel_1_3
mike bayer [Mon, 27 May 2019 22:36:50 +0000 (22:36 +0000)] 
Merge "MYSQL: added support for drop check/constraint" into rel_1_3

6 years agoAdd documentation / tracker URLs for pypi
Mike Bayer [Mon, 27 May 2019 21:26:35 +0000 (17:26 -0400)] 
Add documentation / tracker URLs for pypi

Change-Id: I379b3d9e59ff8cda17c2d738fde794249f105510
(cherry picked from commit 9feec16b149aaaadb5b55933c7bb020becca45f5)

6 years agoMYSQL: added support for drop check/constraint
Hannes Hansen [Thu, 23 May 2019 20:27:21 +0000 (16:27 -0400)] 
MYSQL: added support for drop check/constraint

Added support for DROP CHECK constraint which is required by MySQL 8.0.16
to drop a CHECK constraint; MariaDB supports plain DROP CONSTRAINT.  The
logic distinguishes between the two syntaxes by checking the server version
string for MariaDB presence.    Alembic migrations has already worked
around this issue by implementing its own DROP for MySQL / MariaDB CHECK
constraints, however this change implements it straight in Core so that its
available for general use.   Pull request courtesy Hannes Hansen.

Fixes: #4650
Closes: #4659
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4659
Pull-request-sha: 5b654a55e23c2ca498ca3b1cae4f53859e93e8f7

Change-Id: I967710f890722f11cf1f40406adbb17464d16194
(cherry picked from commit c55023641d390b2b09601b10dbc5663e4bd5a466)

6 years agoUse py.test for versioned_history tests, nose no longer runs
Mike Bayer [Sat, 25 May 2019 13:14:45 +0000 (09:14 -0400)] 
Use py.test for versioned_history tests, nose no longer runs
without warnings under python 3

Fixes: #4697
Change-Id: I46d395d3b6642acd9317e27d6a5723ae5201e877
(cherry picked from commit 0694c7f272819d013b5e1931f1baf0ebfb05e666)

6 years agodoc grammar updates
Mengxi Zhang [Wed, 22 May 2019 19:46:16 +0000 (12:46 -0700)] 
doc grammar updates

(cherry picked from commit aabd369670fff4d99501c0be4632a9873372ba78)

6 years agoMerge "Include active_history when propagating attribute listeners" into rel_1_3
mike bayer [Thu, 23 May 2019 18:28:34 +0000 (18:28 +0000)] 
Merge "Include active_history when propagating attribute listeners" into rel_1_3

6 years ago- formatting fix
Mike Bayer [Thu, 23 May 2019 18:27:24 +0000 (14:27 -0400)] 
- formatting fix

Change-Id: I39593d2414ee9ec5e5ed1a9e2b00cbf9fe743b79
(cherry picked from commit 94d7457cb753d350640047e0ee39167383b797e7)

6 years agoInclude active_history when propagating attribute listeners
Mike Bayer [Thu, 23 May 2019 15:35:51 +0000 (11:35 -0400)] 
Include active_history when propagating attribute listeners

Fixed issue where the :paramref:`.AttributeEvents.active_history` flag
would not be set for an event listener that propgated to a subclass via the
:paramref:`.AttributeEvents.propagate` flag.   This bug has been present
for the full span of the :class:`.AttributeEvents` system.

Fixes: #4695
Change-Id: Ie384f4847f37c267d94b6d56e7538438efc1a54c
(cherry picked from commit 174ece15cb167b774d0b48aa2083e13837f99017)

6 years agoImprove docstrings for AtributeEvents re: propagate flag
Mike Bayer [Wed, 22 May 2019 15:43:01 +0000 (11:43 -0400)] 
Improve docstrings for AtributeEvents re: propagate flag

Make sure the flag is illustrated as well as that every event
has a seealso encouraging the user to look at the top level
listen options.

Fixes: #4691
Change-Id: I137bd74e5d93971bbd04758c7a022a026e13b423
(cherry picked from commit 999bd50753a46785d8031d080af661f608b867c5)

6 years agoAdd QueryableAttribute._impl_uses_objects accessor for AssociationProxy
Mike Bayer [Sun, 19 May 2019 16:38:14 +0000 (12:38 -0400)] 
Add QueryableAttribute._impl_uses_objects accessor for AssociationProxy

Fixed regression where new association proxy system was still not proxying
hybrid attributes when they made use of the ``@hybrid_property.expression``
decorator to return an alternate SQL expression, or when the hybrid
returned an arbitrary :class:`.PropComparator`, at the expression level.
This involved futher generalization of the heuristics used to detect the
type of object being proxied at the level of :class:`.QueryableAttribute`,
to better detect if the descriptor ultimately serves mapped classes or
column expressions.

Fixes: #4690
Change-Id: I5b5300661291c94a23de53bcf92d747701720aa1
(cherry picked from commit c785a528ea200a8905d1b5d7ab4088d501606d2b)

6 years agoAdd .pre-commit-config.yaml
Mike Bayer [Sat, 18 May 2019 14:47:39 +0000 (10:47 -0400)] 
Add .pre-commit-config.yaml

See https://pre-commit.com/ for documentation on how to use
this file.

SQLAlchemy and related projects make use of Black and zimports
for code formatting, this hook allows for automated pre-commit
runs.

Change-Id: I4bbb49747e9f7fb52251dc61ecda98361cd036fd
(cherry picked from commit 69ebf2cc365baf82016c9d1672fe89e39594b523)

6 years agoMutex the declarative scan/map process against configure_mappers()
Mike Bayer [Thu, 16 May 2019 15:26:04 +0000 (11:26 -0400)] 
Mutex the declarative scan/map process against configure_mappers()

Applied the mapper "configure mutex" against the declarative class mapping
process, to guard against the race which can occur if mappers are used
while dynamic module import schemes are still in the process of configuring
mappers for related classes.  This does not guard against all possible race
conditions, such as if the concurrent import has not yet encountered the
dependent classes as of yet, however it guards against as much as possible
within the SQLAlchemy declarative process.

Fixes: #4686
Change-Id: I0349036b8078bd42265ab40862cfbfe5bf9d5b44
(cherry picked from commit 5039c6f01d0bd1f58f950e80cddf7472444a70a4)

6 years agoDocument and test modification of .values in before_compile_update
Mike Bayer [Thu, 16 May 2019 00:27:30 +0000 (20:27 -0400)] 
Document and test modification of .values in before_compile_update

Change-Id: I2a694bcf24b06806dc98651015e7c7a8b090ff65
(cherry picked from commit 89e6beaf46ebdd626e292eb20f7b6ae0c3a9ae5c)

6 years agoRecognize message 20047 as disconnect event in MSDialect_pymssql
Jon Schuff [Tue, 14 May 2019 20:45:10 +0000 (16:45 -0400)] 
Recognize message 20047 as disconnect event in MSDialect_pymssql

Added error code 20047 to "is_disconnect" for pymssql.  Pull request
courtesy Jon Schuff.

Fixes: #4680
Closes: #4681
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4681
Pull-request-sha: bc81c935ec0e352734d9ad1b322caf6d08079c3d

Change-Id: Ifc7ffc4c933b08a34fad537dc48e05d2cfa66d42
(cherry picked from commit 02c18e753b26aa038ce47d0b46b8f0281093d88b)

6 years agoMerge "Resolve RST306 issues" into rel_1_3
mike bayer [Tue, 14 May 2019 14:49:58 +0000 (14:49 +0000)] 
Merge "Resolve RST306 issues" into rel_1_3

6 years agoContinue to assume None for un-accessed attribute on persistent
Mike Bayer [Mon, 13 May 2019 18:56:12 +0000 (14:56 -0400)] 
Continue to assume None for un-accessed attribute on persistent
object during m2o fetch

Fixed regression in new relationship m2o comparison logic first introduced
at :ref:`change_4359` when comparing to an attribute that is persisted as
NULL and is in an un-fetched state in the mapped instance.  Since the
attribute has no explicit default, it needs to default to NULL when
accessed in a persistent setting.

Fixes: #4676
Change-Id: I17160c30131187c735f025a785ff0276a246f6bb
(cherry picked from commit b6619f267ba6a327d6bff1aa650dd3ab9b718b29)

6 years agoResolve RST306 issues
Mike Bayer [Mon, 13 May 2019 15:52:17 +0000 (11:52 -0400)] 
Resolve RST306 issues

The latest flake8 seems to look for these and they are in fact
correctable with a backslash.  Also need to add r to the strings
to avoid W605.

Change-Id: I8045309aa2ad29978ba7e99c45f75bc1457dff3d
(cherry picked from commit 663ed1a0772f6c6d53b1f4f9a2f652d0e5ce0b8a)

6 years agoFixes typo in core/connections.rst
Michael J Ward [Tue, 23 Apr 2019 20:44:06 +0000 (15:44 -0500)] 
Fixes typo in core/connections.rst

The generated sql was using the incorrect `user_schema` instead
of the correct `user_schema_one` translated table name.

(cherry picked from commit 9bba68a5a70d9e58bbc7490f7313c3b9dc2bb9ba)

6 years agoAdd autoincrement to test_orm AnnotatedOverheadTest for Oracle
Mike Bayer [Sat, 11 May 2019 15:40:56 +0000 (11:40 -0400)] 
Add autoincrement to test_orm AnnotatedOverheadTest for Oracle

Fixes: #4675
Change-Id: I593c3a891462818e7095a30bf6cd7795ca143ad1
(cherry picked from commit b26642e2364836fe9a8ee25c1cf4551901ce0c37)

6 years agoCorrect fix and tests for #4661
Mike Bayer [Sat, 11 May 2019 02:36:40 +0000 (22:36 -0400)] 
Correct fix and tests for #4661

For #4661 we need to still warn if we are only deleting one row,
even if sane multi rowcount is false.   Tests were failing for
pyodbc since the warning was removed for the single-row case.
the UPDATE logic raises if a single row doesn't match even
if sane multi rowcount is false, so this is now more consistent
with that.  Add tests for the UPDATE case also.  It is possible
there are already tests for this but as the DELETE case wasn't
well covered it's not clear.

Fixes: #4661
Change-Id: Ie57f765ff31bf806206837c5fbfe449b02ebf4be
(cherry picked from commit bdafff8982d9e7fbf9a39182f1fb8e65d475bbb9)