]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
5 years agoMerge branch 'master--changelog13-typo' of https://github.com/nphilipp/sqlalchemy...
Mike Bayer [Mon, 5 Aug 2019 14:22:58 +0000 (10:22 -0400)] 
Merge branch 'master--changelog13-typo' of https://github.com/nphilipp/sqlalchemy into nphilipp-master--changelog13-typo

Change-Id: I5708624686ec752468038364cb2bdb5b1080c98c

5 years agoMerge "Strong reference listen function wrapped by "once""
mike bayer [Mon, 5 Aug 2019 02:51:40 +0000 (02:51 +0000)] 
Merge "Strong reference listen function wrapped by "once""

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

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

5 years agoMerge "Add additional tests to verify _is_clone_of proxy level link"
mike bayer [Fri, 2 Aug 2019 14:35:08 +0000 (14:35 +0000)] 
Merge "Add additional tests to verify _is_clone_of proxy level link"

5 years agoAdd additional tests to verify _is_clone_of proxy level link
Mike Bayer [Thu, 1 Aug 2019 17:27:43 +0000 (13:27 -0400)] 
Add additional tests to verify _is_clone_of proxy level link

The commit message in 896d47f318c5c27620fd6da is not accurate,
we do in fact still need _is_clone_of when a clone of a column is
created so that we can implement _cloned_set().  Additionally,
the linkage of _is_clone_of within make_proxy() also suits
an additional use case that seems to be related to [ticket:2419].
Adjust one of the tests which likely got changed within 1.4's
refactoring of Select to test this correctly.

Change-Id: I124c7c6b02498e2dfad9797816df42a5b6f91901

5 years agoMerge "Remove threadlocal engine strategy, engine strategies pool threadlocal"
mike bayer [Thu, 1 Aug 2019 17:48:44 +0000 (17:48 +0000)] 
Merge "Remove threadlocal engine strategy, engine strategies pool threadlocal"

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

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

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

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

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

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

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

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

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

6 years agocherry-pick changelog update for 1.3.7
Mike Bayer [Sun, 21 Jul 2019 21:10:02 +0000 (17:10 -0400)] 
cherry-pick changelog update for 1.3.7

6 years agocherry-pick changelog from 1.3.6
Mike Bayer [Sun, 21 Jul 2019 21:10:01 +0000 (17:10 -0400)] 
cherry-pick changelog from 1.3.6

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

6 years agoMerge "Optimize out JOIN for selectinload with many to one"
mike bayer [Sat, 20 Jul 2019 01:46:42 +0000 (01:46 +0000)] 
Merge "Optimize out JOIN for selectinload with many to one"

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

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

6 years agoMerge "Support tuple IN VALUES for SQLite, others"
mike bayer [Fri, 19 Jul 2019 20:22:33 +0000 (20:22 +0000)] 
Merge "Support tuple IN VALUES for SQLite, others"

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

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

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

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

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

6 years agoMerge remote-tracking branch 'origin/pr/4769'
Mike Bayer [Thu, 18 Jul 2019 00:50:24 +0000 (20:50 -0400)] 
Merge remote-tracking branch 'origin/pr/4769'

Change-Id: I7cf3c4c175c0f616cb167c6a89b1591be8210aec

6 years agoMerge remote-tracking branch 'origin/pr/4770'
Mike Bayer [Thu, 18 Jul 2019 00:47:17 +0000 (20:47 -0400)] 
Merge remote-tracking branch 'origin/pr/4770'

Change-Id: Id0c21bc54fb370fc2e0fc01da211f2d3455af2fc

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

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

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

6 years agoRemove threadlocal engine strategy, engine strategies pool threadlocal
Mike Bayer [Thu, 11 Apr 2019 18:21:13 +0000 (14:21 -0400)] 
Remove threadlocal engine strategy, engine strategies pool threadlocal

The "threadlocal" execution strategy, deprecated in 1.3, has been
removed for 1.4, as well as the concept of "engine strategies" and the
``Engine.contextual_connect`` method.  The "strategy='mock'" keyword
argument is still accepted for now with a deprecation warning; use
:func:`.create_mock_engine` instead for this use case.

Fixes: #4632
Change-Id: I8a351f9fa1f7dfa2a56eec1cd2d1a4b9d65765a2
(cherry picked from commit b368c49b44c5716d93c7428ab22b6761c6ca7cf5)

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

6 years agoAdd profile sort option to test suite
Mike Bayer [Sun, 14 Jul 2019 15:43:29 +0000 (11:43 -0400)] 
Add profile sort option to test suite

I use the nfl sort a lot to see what calling changes are happening
between two versions in order to identify the offending code, so
add it as a command line option.

Change-Id: Ia1ab6dd98012a78298b325bb5c7c050fa9b767c2

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

6 years agoAllow duplicate columns in from clauses and selectables
Mike Bayer [Sun, 7 Jul 2019 15:12:31 +0000 (11:12 -0400)] 
Allow duplicate columns in from clauses and selectables

The :func:`.select` construct and related constructs now allow for
duplication of column labels and columns themselves in the columns clause,
mirroring exactly how column expressions were passed in.   This allows
the tuples returned by an executed result to match what was SELECTed
for in the first place, which is how the ORM :class:`.Query` works, so
this establishes better cross-compatibility between the two constructs.
Additionally, it allows column-positioning-sensitive structures such as
UNIONs (i.e. :class:`.CompoundSelect`) to be more intuitively constructed
in those cases where a particular column might appear in more than one
place.   To support this change, the :class:`.ColumnCollection` has been
revised to support duplicate columns as well as to allow integer index
access.

Fixes: #4753
Change-Id: Ie09a8116f05c367995c1e43623c51e07971d3bf0

6 years agoMerge "profiling plugin fixes"
mike bayer [Thu, 11 Jul 2019 16:56:54 +0000 (16:56 +0000)] 
Merge "profiling plugin fixes"

6 years agoMerge "Add performance improvement for Enum w/ Python 2 enum library"
mike bayer [Thu, 11 Jul 2019 16:20:17 +0000 (16:20 +0000)] 
Merge "Add performance improvement for Enum w/ Python 2 enum library"

6 years agoprofiling plugin fixes
Mike Bayer [Thu, 11 Jul 2019 15:56:54 +0000 (11:56 -0400)] 
profiling plugin fixes

support that we have pytest-xdist arguments now,
as well as allow force-write to reset the list of callcounts which
seem to accumulate commas for some reason

Change-Id: I54dd164c21ffbb9139937d5c3ffb1df7e9598594

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

6 years agoMerge "Support multidimensional array literals in Postgresql"
mike bayer [Mon, 8 Jul 2019 21:38:11 +0000 (21:38 +0000)] 
Merge "Support multidimensional array literals in Postgresql"

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

6 years agoSmall text error in json field doc 4769/head
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

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

6 years agoclass level docstring for Subquery
Mike Bayer [Sat, 6 Jul 2019 19:47:16 +0000 (15:47 -0400)] 
class level docstring for Subquery

Remove inherited member doc from most selectables, it's too verbose

Change-Id: I1b6635fe73342705846c0fab635b46557e560734

6 years agoMerge "SelectBase no longer a FromClause"
mike bayer [Sat, 6 Jul 2019 19:24:49 +0000 (19:24 +0000)] 
Merge "SelectBase no longer a FromClause"

6 years agoSelectBase no longer a FromClause
Mike Bayer [Thu, 13 Jun 2019 16:37:22 +0000 (12:37 -0400)] 
SelectBase no longer a FromClause

As part of the SQLAlchemy 2.0 migration project, a conceptual change has
been made to the role of the :class:`.SelectBase` class hierarchy,
which is the root of all "SELECT" statement constructs, in that they no
longer serve directly as FROM clauses, that is, they no longer subclass
:class:`.FromClause`.  For end users, the change mostly means that any
placement of a :func:`.select` construct in the FROM clause of another
:func:`.select` requires first that it be wrapped in a subquery first,
which historically is through the use of the :meth:`.SelectBase.alias`
method, and is now also available through the use of
:meth:`.SelectBase.subquery`.    This was usually a requirement in any
case since several databases don't accept unnamed SELECT subqueries
in their FROM clause in any case.

See the documentation in this change for lots more detail.

Fixes: #4617
Change-Id: I0f6174ee24b9a1a4529168e52e855e12abd60667

6 years agotarget issue #4336 at 1.4 release
Mike Bayer [Sat, 6 Jul 2019 13:57:58 +0000 (09:57 -0400)] 
target issue #4336 at 1.4 release

Change-Id: I96acdf2285ebec067ca6128b03d47776533caac0

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

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

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

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

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

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

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

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

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

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

6 years agoMerge "Test for _ORMJoin and fix issue"
mike bayer [Fri, 28 Jun 2019 17:20:49 +0000 (17:20 +0000)] 
Merge "Test for _ORMJoin and fix issue"

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

6 years agoMerge "Add Load.options() for hierchical construction of loader options"
mike bayer [Fri, 28 Jun 2019 15:16:48 +0000 (15:16 +0000)] 
Merge "Add Load.options() for hierchical construction of loader options"

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

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

6 years agoMerge "Unwrap TIMESTAMP when doing an isinstance()"
mike bayer [Thu, 27 Jun 2019 22:21:36 +0000 (22:21 +0000)] 
Merge "Unwrap TIMESTAMP when doing an isinstance()"

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

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

6 years agoUse an ordered dict for the previous change
Mike Bayer [Thu, 27 Jun 2019 20:07:13 +0000 (16:07 -0400)] 
Use an ordered dict for the previous change

Change-Id: Iaccb0a82ff053bd73fec59a83d2ee07e899cd6d7

6 years agoRemove test-within-a-test structure
Mike Bayer [Thu, 27 Jun 2019 14:07:04 +0000 (10:07 -0400)] 
Remove test-within-a-test structure

These tests in of_type were relying upon generating the
polymorphic selectable from the mapper which is proving to be
more challenging to correct when that mechanism is changing.

Change-Id: I72635fab0f6f3fc7f2b712596db310648f55b04c

6 years agoReflect "NO ACTION" as None; support "RESTRICT"
Mike Bayer [Wed, 26 Jun 2019 15:45:50 +0000 (11:45 -0400)] 
Reflect "NO ACTION" as None; support "RESTRICT"

The "NO ACTION" keyword for foreign key "ON UPDATE" is now considered to be
the default cascade for a foreign key on all supporting backends (SQlite,
MySQL, PostgreSQL) and when detected is not included in the reflection
dictionary; this is already the behavior for PostgreSQL and MySQL for all
previous SQLAlchemy versions in any case.   The "RESTRICT" keyword is
positively stored when detected; PostgreSQL does report on this keyword,
and MySQL as of version 8.0 does as well.  On earlier MySQL versions, it is
not reported by the database.

Fixes: #4741
Change-Id: I6becf1f2450605c1991158bb8a04d954dcc7396c

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

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

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

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

6 years agocherry-pick changelog update for 1.3.6
Mike Bayer [Mon, 17 Jun 2019 18:15:16 +0000 (14:15 -0400)] 
cherry-pick changelog update for 1.3.6

6 years agocherry-pick changelog from 1.3.5
Mike Bayer [Mon, 17 Jun 2019 18:15:15 +0000 (14:15 -0400)] 
cherry-pick changelog from 1.3.5

6 years agoMerge remote-tracking branch 'origin/pr/4734'
Mike Bayer [Mon, 17 Jun 2019 15:31:21 +0000 (11:31 -0400)] 
Merge remote-tracking branch 'origin/pr/4734'

Change-Id: Ic3165d61430e9b0edebf80a699e0340e442d69d2

6 years agoMerge "Remove unused "time_func""
mike bayer [Mon, 17 Jun 2019 14:48:50 +0000 (14:48 +0000)] 
Merge "Remove unused "time_func""

6 years agoMerge "PostgreSQL now reflects per-column sort order on indexes."
mike bayer [Mon, 17 Jun 2019 14:48:20 +0000 (14:48 +0000)] 
Merge "PostgreSQL now reflects per-column sort order on indexes."

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

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

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

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

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

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

6 years agoGenerate Oracle ROWNUM scheme using named subqueries
Mike Bayer [Thu, 13 Jun 2019 20:35:12 +0000 (16:35 -0400)] 
Generate Oracle ROWNUM scheme using named subqueries

The LIMIT / OFFSET scheme used in Oracle now makes use of named subqueries
rather than unnamed subqueries when it transparently rewrites a SELECT
statement to one that uses a subquery that includes ROWNUM.  The change is
part of a larger change where unnamed subqueries are no longer directly
supported by Core, as well as to modernize the internal use of the select()
construct within the Oracle dialect.

Change-Id: I27605d7cf16ce79f9d577dbc84e3bd51b7c9b4ae

6 years agoMerge "Reverse Alias nesting concept"
mike bayer [Thu, 13 Jun 2019 18:14:12 +0000 (18:14 +0000)] 
Merge "Reverse Alias nesting concept"

6 years agoReverse Alias nesting concept
Mike Bayer [Thu, 13 Jun 2019 16:45:05 +0000 (12:45 -0400)] 
Reverse Alias nesting concept

The Alias object no longer has "element" and "original", it now
has "wrapped" and "element" (the name .original is also left
as a descriptor for legacy access by third party dialects).
These two data members refer to the
dual roles Alias needs to play, where in the Python sense it needs
to refer to the thing it was applied against directly, whereas in the
SQL sense it needs to refer to the ultimate "non-alias" thing it
refers towards.   Both are necessary to maintain.  However, the change
here has each Alias object access the non-Alias object immediately
so that the "unwrapping" is simpler and does not need any special
logic.

In the SQL sense, Alias objects don't nest, the only potential
was that of the CTE, however there is no such thing as
a nested CTE, see link below.

This change is an interim change along the way to breaking Alias
into more classes and breaking away Select objects from being
FromClause objects.

Change-Id: Ie7a0d064226cb074ca745505129b5ec7d879e389
References: https://stackoverflow.com/questions/1413516/can-you-create-nested-with-clauses-for-common-table-expressions

6 years agoMerge "Run PK/FK sync for multi-level inheritance w/ no intermediary update"
mike bayer [Wed, 12 Jun 2019 23:21:03 +0000 (23:21 +0000)] 
Merge "Run PK/FK sync for multi-level inheritance w/ no intermediary update"

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

6 years agoMerge "Don't discard inactive transaction until it is explicitly rolled back"
mike bayer [Mon, 10 Jun 2019 19:06:03 +0000 (19:06 +0000)] 
Merge "Don't discard inactive transaction until it is explicitly rolled back"

6 years agoMerge "Accommodate value of None for ON DUPLICATE KEY UPDATE"
mike bayer [Mon, 10 Jun 2019 18:46:26 +0000 (18:46 +0000)] 
Merge "Accommodate value of None for ON DUPLICATE KEY UPDATE"

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

6 years agoDon't discard inactive transaction until it is explicitly rolled back
Mike Bayer [Fri, 7 Jun 2019 15:19:23 +0000 (11:19 -0400)] 
Don't discard inactive transaction until it is explicitly rolled back

The :class:`.Connection` object will now not clear a rolled-back
transaction  until the outermost transaction is explicitly rolled back.
This is essentially the same behavior that the ORM :class:`.Session` has
had for a long time, where an explicit call to ``.rollback()`` on all
enclosing transactions is required for the transaction to logically clear,
even though the DBAPI-level transaction has already been rolled back.
The new behavior helps with situations such as the "ORM rollback test suite"
pattern where the test suite rolls the transaction back within the ORM
scope, but the test harness which seeks to control the scope of the
transaction externally does not expect a new transaction to start
implicitly.

Fixes: #4712
Change-Id: Ibc6c8d981cff31594a5d26dd5203fd9cfcea1c74

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

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

6 years agoAdd "full" to the getargspec warning skip
Mike Bayer [Fri, 7 Jun 2019 20:04:22 +0000 (16:04 -0400)] 
Add "full" to the getargspec warning skip

Even though getfullargspec() is no longer deprecated in python3.8
as of b1, we aren't using it anymore so block any future warnings
from interfering with py.test or similar.

Change-Id: Ib96838ce8169e989e1c8ad3a4819b4ebd3ffdc39

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

6 years agoMerge "Add "usecase" changelog tag"
mike bayer [Mon, 3 Jun 2019 19:52:40 +0000 (19:52 +0000)] 
Merge "Add "usecase" changelog tag"