]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
5 years agoFix comment re: ODBC driver name on Windows. 5058/head
Gord Thompson [Fri, 27 Dec 2019 20:39:23 +0000 (13:39 -0700)] 
Fix comment re: ODBC driver name on Windows.

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

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

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

Change-Id: I1a7162e67912d22c135fa517b687a073f8fd9151

5 years agoUse expanding IN for all literal value IN expressions
Mike Bayer [Mon, 9 Dec 2019 23:05:00 +0000 (18:05 -0500)] 
Use expanding IN for all literal value IN expressions

The "expanding IN" feature, which generates IN expressions at query
execution time which are based on the particular parameters associated with
the statement execution, is now used for all IN expressions made against
lists of literal values.   This allows IN expressions to be fully cacheable
independently of the list of values being passed, and also includes support
for empty lists. For any scenario where the IN expression contains
non-literal SQL expressions, the old behavior of pre-rendering for each
position in the IN is maintained. The change also completes support for
expanding IN with tuples, where previously type-specific bind processors
weren't taking effect.

As part of this change, a more explicit separation between
"literal execute" and "post compile" bound parameters is being made;
as the "ansi bind rules" feature is rendering bound parameters
inline, as we now support "postcompile" generically, these should
be used here, however we have to render literal values at
execution time even for "expanding" parameters.  new test fixtures
etc. are added to assert everything goes to the right place.

Fixes: #4645
Change-Id: Iaa2b7bfbfaaf5b80799ee17c9b8507293cba6ed1

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

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

Fixes: #5048
Change-Id: I876d16bd7484eb05ce590397420552ac36da6e52

5 years agoImplement random_choices for Python 2
Mike Bayer [Fri, 20 Dec 2019 17:49:13 +0000 (12:49 -0500)] 
Implement random_choices for Python 2

Apparently py2k has no random.choices, so make a quick
one for the tests that use it.

Change-Id: Iadc3442b35f400b5bab0f711b7d3ede5dbc28f52

5 years agoEnsure comparison includes "don't compare values" feature
Mike Bayer [Fri, 20 Dec 2019 15:17:17 +0000 (10:17 -0500)] 
Ensure comparison includes "don't compare values" feature

upcoming changes for "expanding IN in all cases" and
"lambda elements" both rely upon comparisons that work
across changing bound values, so commit the testing fixture
ahead of time.   Additionally, repair the feature itself
within traversals.

Change-Id: Ie65a512dc64745614180da77435f9f745ce78c71

5 years agoMerge "Don't apply aliasing + adaption for simple relationship joins"
mike bayer [Thu, 19 Dec 2019 16:14:11 +0000 (16:14 +0000)] 
Merge "Don't apply aliasing + adaption for simple relationship joins"

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

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

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

Change-Id: Ifbe04214576e5a9fac86ca80c1dc7145c27cd50a

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

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

Change-Id: I22b71ca1b336d4b098af075cc4694c55387b64f3

5 years agoMerge remote-tracking branch 'origin/pr/5023'
Mike Bayer [Wed, 18 Dec 2019 23:01:12 +0000 (18:01 -0500)] 
Merge remote-tracking branch 'origin/pr/5023'

Change-Id: I28884213a86ff3c8fbb5f6377114bba6503cb671

5 years agoMerge remote-tracking branch 'origin/pr/5022'
Mike Bayer [Wed, 18 Dec 2019 22:57:07 +0000 (17:57 -0500)] 
Merge remote-tracking branch 'origin/pr/5022'

Change-Id: I4c195826482aa523904b68cb6537acf4a547889a

5 years agoMerge remote-tracking branch 'origin/pr/5031'
Mike Bayer [Wed, 18 Dec 2019 22:56:37 +0000 (17:56 -0500)] 
Merge remote-tracking branch 'origin/pr/5031'

Change-Id: I74d94087495de2e0b98b180ef1b5269a72d0c3bf

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

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

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

Change-Id: I2e9cb5d7f85961ec98ee51965de5b3ec4a97be2f

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

Change-Id: Icf00f9250ffe45413369a6bb2c2910da42c017ee

5 years agoDo the CompoundSelect check for number of columns in the compile phase
Mike Bayer [Mon, 16 Dec 2019 21:38:06 +0000 (16:38 -0500)] 
Do the CompoundSelect check for number of columns in the compile phase

Starting to go forward with the general idea of moving more
of Core / ORM construction into the compile phase.   Bigger
initiatives like the refactor of Query will follow onto this.

Change-Id: I0f364d3182e21e32ed85ef34cfd11fd9d11cf653

5 years agocherry-pick changelog update for 1.3.13
Mike Bayer [Mon, 16 Dec 2019 18:39:52 +0000 (13:39 -0500)] 
cherry-pick changelog update for 1.3.13

5 years agocherry-pick changelog from 1.3.12
Mike Bayer [Mon, 16 Dec 2019 18:39:52 +0000 (13:39 -0500)] 
cherry-pick changelog from 1.3.12

5 years agoEnsure cache keys are hashable in the test
Mike Bayer [Sat, 14 Dec 2019 20:36:38 +0000 (15:36 -0500)] 
Ensure cache keys are hashable in the test

Change-Id: I962ff15194e2416844086f03dddadb49f48a6c8d

5 years agoTraversal and clause generation performance improvements
Mike Bayer [Sat, 14 Dec 2019 16:39:06 +0000 (11:39 -0500)] 
Traversal and clause generation performance improvements

Added one traversal test, callcounts have been brought from 29754 to
5173 so far.

Change-Id: I164e9831600709ee214c1379bb215fdad73b39aa

5 years agoMerge remote-tracking branch 'origin/pr/5021'
Mike Bayer [Sat, 14 Dec 2019 16:16:54 +0000 (11:16 -0500)] 
Merge remote-tracking branch 'origin/pr/5021'

Change-Id: Ia41c6c692e0b89f2d45e10b10ff6e69799312dba

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

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

Fixes: #5034
Change-Id: I6502a55791d86845f34bc10889c218f00765dfdc

5 years agofix typo strucures -> structures 5031/head
Federico Caselli [Tue, 10 Dec 2019 23:08:37 +0000 (00:08 +0100)] 
fix typo strucures -> structures

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

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

Fixes: #5028
Change-Id: Id36cfe477ed836c3248824ce1b81d0016dbe99f4

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

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

Change-Id: I6e685e46ae336596272d14366445ac224c18d92c

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

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

Change-Id: Ia63a510f9c1d08b055eef62cf047f1f427f0450c

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

5 years agoAdd note re: using the MySQL ODBC "ANSI" driver for mysql+pyodbc.
Gord Thompson [Wed, 4 Dec 2019 00:41:56 +0000 (17:41 -0700)] 
Add note re: using the MySQL ODBC "ANSI" driver for mysql+pyodbc.

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

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

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

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

Fixes: #5016
Change-Id: Ia347d5a9958c0fa53317b2e340162e2009667bc2

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

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

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

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

Change-Id: Ia4c7c0d1971c6c0492515bd5fa0b1799f07fee1c

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

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

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

Fixes: #5014
Change-Id: Id38221dce1271fec527ca198b23908547b25d8a0

5 years agoMerge "Remove ORM elements from annotations at the schema level."
mike bayer [Tue, 26 Nov 2019 18:06:45 +0000 (18:06 +0000)] 
Merge "Remove ORM elements from annotations at the schema level."

5 years agoMerge "Add sequence support for MariaDB 10.3+."
mike bayer [Tue, 26 Nov 2019 17:59:53 +0000 (17:59 +0000)] 
Merge "Add sequence support for MariaDB 10.3+."

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

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

Change-Id: I4f16889c4c02cb2835dcf4886eb09ece848d8109
References: I507bc405eee6cae2c5991345d0eac53a37fe7512

5 years agoAdd sequence support for MariaDB 10.3+.
Gord Thompson [Thu, 21 Nov 2019 14:43:40 +0000 (09:43 -0500)] 
Add sequence support for MariaDB 10.3+.

Added support for use of the :class:`.Sequence` construct with MariaDB 10.3
and greater, as this is now supported by this database.  The construct
integrates with the :class:`.Table` object in the same way that it does for
other databases like PostrgreSQL and Oracle; if is present on the integer
primary key "autoincrement" column, it is used to generate defaults.   For
backwards compatibility, to support a :class:`.Table` that has a
:class:`.Sequence` on it to support sequence only databases like Oracle,
while still not having the sequence fire off for MariaDB, the optional=True
flag should be set, which indicates the sequence should only be used to
generate the primary key if the target database offers no other option.

Fixes: #4976
Closes: #4996
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4996
Pull-request-sha: cb2e1426ea0b6bc6c93dbe8f033a11df9d8c4915

Change-Id: I507bc405eee6cae2c5991345d0eac53a37fe7512

5 years agoRemove ORM elements from annotations at the schema level.
Mike Bayer [Mon, 25 Nov 2019 20:09:47 +0000 (15:09 -0500)] 
Remove ORM elements from annotations at the schema level.

Fixed issue where when constructing constraints from ORM-bound columns,
primarily :class:`.ForeignKey` objects but also :class:`.UniqueConstraint`,
:class:`.CheckConstraint` and others, the ORM-level
:class:`.InstrumentedAttribute` is discarded entirely, and all ORM-level
annotations from the columns are removed; this is so that the constraints
are still fully pickleable without the ORM-level entities being pulled in.
These annotations are not necessary to be present at the schema/metadata
level.

Fully implemented coercions for constraint columns within
schema.py, including for FK referenced columns.

Fixes: #5001
Change-Id: I895400dd979310be034085d207f096707c635909

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

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

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

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

Fixes: #5000
Change-Id: Iea6fb1bd3314d861a9bc22491b0ae1e6c5e6340d

5 years agoRaise for persistence casades set with viewonly=True
Mike Bayer [Fri, 22 Nov 2019 19:28:21 +0000 (14:28 -0500)] 
Raise for persistence casades set with viewonly=True

An error is raised if any persistence-related "cascade" settings are made
on a :func:`.relationship` that also sets up viewonly=True.   The "cascade"
settings now default to non-persistence related settings only when viewonly
is also set.  This is the continuation from :ticket:`4993` where this
setting was changed to emit a warning in 1.3.

Fixes: #4994
Change-Id: Ic70ff4d9980e422ade474c5a0ad49756c6b8a048

5 years agoMerge "Warn for settings that don't work with viewonly=True"
mike bayer [Fri, 22 Nov 2019 19:06:24 +0000 (19:06 +0000)] 
Merge "Warn for settings that don't work with viewonly=True"

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

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

Fixes: #4993
Change-Id: I4b607a96a7de2ffa15303a27fd93c162a681556d

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

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

Fixes: #4997
Change-Id: I4deb8c129900f28321c4a5c48301db5fe2aedf78

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

A few new formatting errors are caught by this version.

Change-Id: I737b33267a00f400b7ba7696a03ddb07a4c95bc0

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

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

Change-Id: I9f2de97ce5b2487411ed610b8d41169c1052bd8f

5 years agoMerge "Skip on slice assignment to self"
mike bayer [Wed, 20 Nov 2019 19:50:35 +0000 (19:50 +0000)] 
Merge "Skip on slice assignment to self"

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

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

Fixes: #4990
Change-Id: I08727880f70f4fe188de53a4dcd36746b62c7233

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

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

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

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

Fixes: #4992
Change-Id: I8f4b4db9e42ab2207a74532e3b17a56c35b0a837

5 years agoFix charset= in README.unittests.rst for MySQL 4987/head
Gord Thompson [Sun, 17 Nov 2019 16:50:48 +0000 (09:50 -0700)] 
Fix charset= in README.unittests.rst for MySQL

5 years agoMerge "Base mssql.DATETIMEOFFSET on DateTime"
mike bayer [Wed, 13 Nov 2019 18:20:38 +0000 (18:20 +0000)] 
Merge "Base mssql.DATETIMEOFFSET on DateTime"

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

Change-Id: I59e6c76a4a53ce3782bcfc4aecdeb1b4fdd7b941
References: https://github.com/sqlalchemy/sqlalchemy/issues/4980

5 years agoBase mssql.DATETIMEOFFSET on DateTime
Mike Bayer [Wed, 13 Nov 2019 15:09:54 +0000 (10:09 -0500)] 
Base mssql.DATETIMEOFFSET on DateTime

Fixed the base class of the :class:`.mssql.DATETIMEOFFSET` datatype to
be based on the :class:`.DateTime` class hierarchy, as this is a
datetime-holding datatype.

Note however that at the moment the pyodbc driver has only limited
support for this datatype and will not work with all ODBC drivers.

References: https://github.com/mkleehammer/pyodbc/issues/134

Fixes: #4980
Change-Id: I946cf22642eea4beee2a605d91218c6fd817740c

5 years agoMerge "Repair Oracle Interval"
mike bayer [Tue, 12 Nov 2019 21:30:49 +0000 (21:30 +0000)] 
Merge "Repair Oracle Interval"

5 years agocherry-pick changelog update for 1.3.12
Mike Bayer [Mon, 11 Nov 2019 22:15:33 +0000 (17:15 -0500)] 
cherry-pick changelog update for 1.3.12

5 years agocherry-pick changelog from 1.3.11
Mike Bayer [Mon, 11 Nov 2019 22:15:33 +0000 (17:15 -0500)] 
cherry-pick changelog from 1.3.11

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

5 years agoRepair Oracle Interval
Mike Bayer [Mon, 11 Nov 2019 21:51:46 +0000 (16:51 -0500)] 
Repair Oracle Interval

The :class:`.oracle.INTERVAL` class of the Oracle dialect is now correctly
a subclass of the abstract version of :class:`.Interval` as well as the
correct "emulated" base class, which allows for correct behavior under both
native and non-native modes; previously it was only based on
:class:`.TypeEngine`.

Fixes: #4971
Change-Id: I4400d9f090330388460cca930e4139e3bd21eb11

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

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

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

Change-Id: If6bbe0eb5993e1996c0c5de752eebaf7446cf93e
References: https://github.com/PyMySQL/PyMySQL/issues/816
Fixes: #4945
5 years agoMerge "Add type accessors for JSON indexed/pathed element access"
mike bayer [Mon, 11 Nov 2019 20:46:50 +0000 (20:46 +0000)] 
Merge "Add type accessors for JSON indexed/pathed element access"

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

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

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

Change-Id: Ia9e62f7c1026c1465986144c5757e35fc164a2b8

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

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

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

Fixes: #4276
Change-Id: Ica5a926c060feb40a0a7cd60b9d6e061d7825728

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

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

Fixes: #4974
Change-Id: Ia43da747c22141b05439f4511ddeceb10248582e

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

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

Change-Id: I15d2839954d77a252bab5aaf6e3fd9f388c99dd5

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

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

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

Ensure test_types tests are using __backend__

mark currently failing Oracle interval tests

Change-Id: If8db0c02b31a8008fd1673c2380f1f974c3806a6

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

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

Fixes: #4973
Change-Id: I040d34f781791c4ed5a727e1b8fb98c68ddd0622

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

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

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

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

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

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

Change-Id: I2610b2999a5b1b127ed927dcdaeee98b769643ce

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

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

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

Fixes: #4967
Change-Id: I5e21e7e78cb6d927b18afce64cacf8643b98354e

5 years agoAdd -j auto to sphinx opts
Mike Bayer [Wed, 6 Nov 2019 23:42:23 +0000 (18:42 -0500)] 
Add -j auto to sphinx opts

Sphinx supports multiprocessing via the -j flag.  set to
auto so that multiple processes based on CPU core count
will be used.

Change-Id: Id89f860e0e113d670477b0322a7950281543d9d5

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

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

    [docs] Fix, missing dot

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

    [docs] Apache Druid and Google sheets dialects

Change-Id: I6462b310635210649564ce0399393ec194daf774

5 years agoMerge "Add anonymizing context to cache keys, comparison; convert traversal"
mike bayer [Mon, 4 Nov 2019 19:50:17 +0000 (19:50 +0000)] 
Merge "Add anonymizing context to cache keys, comparison; convert traversal"

5 years agoMerge remote-tracking branch 'origin/pr/4958'
Mike Bayer [Mon, 4 Nov 2019 18:52:48 +0000 (13:52 -0500)] 
Merge remote-tracking branch 'origin/pr/4958'

Change-Id: Id59e77c64ffeb0f4636261be9fb21d2a78100f40

5 years agoAdd anonymizing context to cache keys, comparison; convert traversal
Mike Bayer [Thu, 29 Aug 2019 18:45:23 +0000 (14:45 -0400)] 
Add anonymizing context to cache keys, comparison; convert traversal

Created new visitor system called "internal traversal" that
applies a data driven approach to the concept of a class that
defines its own traversal steps, in contrast to the existing
style of traversal now known as "external traversal" where
the visitor class defines the traversal, i.e. the SQLCompiler.

The internal traversal system now implements get_children(),
_copy_internals(), compare() and _cache_key() for most Core elements.
Core elements with special needs like Select still implement
some of these methods directly however most of these methods
are no longer explicitly implemented.

The data-driven system is also applied to ORM elements that
take part in SQL expressions so that these objects, like mappers,
aliasedclass, query options, etc. can all participate in the
cache key process.

Still not considered is that this approach to defining traversibility
will be used to create some kind of generic introspection system
that works across Core / ORM.  It's also not clear if
real statement caching using the _cache_key() method is feasible,
if it is shown that running _cache_key() is nearly as expensive as
compiling in any case.    Because it is data driven, it is more
straightforward to optimize using inlined code, as is the case now,
as well as potentially using C code to speed it up.

In addition, the caching sytem now accommodates for anonymous
name labels, which is essential so that constructs which have
anonymous labels can be cacheable, that is, their position
within a statement in relation to other anonymous names causes
them to generate an integer counter relative to that construct
which will be the same every time.   Gathering of bound parameters
from any cache key generation is also now required as there is
no use case for a cache key that does not extract bound parameter
values.

Applies-to: #4639
Change-Id: I0660584def8627cad566719ee98d3be045db4b8d

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

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

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

Change-Id: Idb2fc96e23e7cc96cf96f586208c2db561518202

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

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

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

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

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

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

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

Change-Id: I13a74432976e6d3166633b98f9bb84c4856caac8

5 years agoMerge "Remove python setup.py test; fix SQL Server URL"
mike bayer [Thu, 31 Oct 2019 14:23:21 +0000 (14:23 +0000)] 
Merge "Remove python setup.py test; fix SQL Server URL"

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

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

Fixes: #4955
Change-Id: Icd97744323407977a3f7db26e8a63a1a5c576010

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

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

Fixes: #4954
Change-Id: I3afebefb13ddaf8f74c5c2b9e6e6a1a261ac5629

5 years agoMerge "Correctly interpret None passed to query.get(); warn for empty PK values"
mike bayer [Wed, 30 Oct 2019 18:20:06 +0000 (18:20 +0000)] 
Merge "Correctly interpret None passed to query.get(); warn for empty PK values"

5 years agoMerge "Remove redundant assignment in .../engine/create.py"
mike bayer [Wed, 30 Oct 2019 18:19:06 +0000 (18:19 +0000)] 
Merge "Remove redundant assignment in .../engine/create.py"

5 years agoMerge "Use simple growth scale with any max size for BufferedRowResultProxy"
mike bayer [Wed, 30 Oct 2019 18:18:48 +0000 (18:18 +0000)] 
Merge "Use simple growth scale with any max size for BufferedRowResultProxy"

5 years agoUse simple growth scale with any max size for BufferedRowResultProxy
sumau [Mon, 28 Oct 2019 19:22:08 +0000 (15:22 -0400)] 
Use simple growth scale with any max size for BufferedRowResultProxy

The maximum buffer size for the :class:`.BufferedRowResultProxy`, which
is used by dialects such as PostgreSQL when ``stream_results=True``, can
now be set to a number greater than 1000 and the buffer will grow to
that size.  Previously, the buffer would not go beyond 1000 even if the
value were set larger.   The growth of the buffer is also now based
on a simple multiplying factor currently set to 5.  Pull request courtesy
Soumaya Mauthoor.

Fixes: #4914
Closes: #4930
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4930
Pull-request-sha: 66841f56e967c784f7078a787cec5129462006c8

Change-Id: I6286220bd9d488027fadc444039421a410e19a19

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

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

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

Change-Id: Ibc6c27ccf50dfd4adbf15b6dbd393115c30d44fb

5 years agoMerge remote-tracking branch 'origin/pr/4940'
Mike Bayer [Mon, 28 Oct 2019 19:28:46 +0000 (15:28 -0400)] 
Merge remote-tracking branch 'origin/pr/4940'

Change-Id: Id88c540fab045f800818c40b7a8f7a20920ab9a6

5 years agoRemove redundant assignment in .../engine/create.py
Pedro Cunial [Mon, 28 Oct 2019 19:27:44 +0000 (15:27 -0400)] 
Remove redundant assignment in .../engine/create.py

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

### Description
<!-- Describe your changes in detail -->

Remove a redundant assignment in the engine creation file.

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

-->

This pull request is:

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

**Have a nice day!**

Closes: #4944
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4944
Pull-request-sha: 4a0e6206f0ae5ff5350ecaa6f998bc3dc0c26cdd

Change-Id: Ie491b071e3392334947d3b8ba84c7323c1b15b6e

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

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

    [docs] Fix, typo

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

    [docs] Elasticsearch dialect and dbapi

Change-Id: I5c67eca606be382f801facae3546ab6c499e9e63

5 years agoRemove python setup.py test; fix SQL Server URL
Mike Bayer [Tue, 22 Oct 2019 22:40:41 +0000 (18:40 -0400)] 
Remove python setup.py test; fix SQL Server URL

general README.unittest.rst edits

Fixes: #4789
Fixes: #4900
Change-Id: Ifddd3bfd1e6a4d24d3b0a3e1702e04e66a42a4dd

5 years agoMerge "Add public accessor `is_single_entity` to Query"
mike bayer [Mon, 28 Oct 2019 12:46:37 +0000 (12:46 +0000)] 
Merge "Add public accessor `is_single_entity` to Query"

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

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

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

Change-Id: If5db5db3ea46a93406d76ef90b5b588149ba2986

5 years agoMerge "Don't cache a query that has before_compile modifications"
mike bayer [Sun, 27 Oct 2019 15:05:46 +0000 (15:05 +0000)] 
Merge "Don't cache a query that has before_compile modifications"

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

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

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

Fixes: #4947
Change-Id: I5823c4fa00e7b6d46a2e8461b02d8b16605a6ed0

5 years agoMerge "Fix Python 3.8 SyntaxWarning: "is not" with a literal"
mike bayer [Sat, 26 Oct 2019 13:58:52 +0000 (13:58 +0000)] 
Merge "Fix Python 3.8 SyntaxWarning: "is not" with a literal"

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

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

Fixes: #4946
Change-Id: I1a1ce7ef72da8da9ad9576e1281d1df415c6af4f

5 years agoMerge "Disallow memory tests from running on Windows"
mike bayer [Fri, 25 Oct 2019 16:31:49 +0000 (16:31 +0000)] 
Merge "Disallow memory tests from running on Windows"