]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
5 years agoMerge "Add DATETIMEOFFSET support for mssql+pyodbc" into rel_1_3
mike bayer [Sat, 30 Nov 2019 18:32:10 +0000 (18:32 +0000)] 
Merge "Add DATETIMEOFFSET support for mssql+pyodbc" into rel_1_3

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

A few new formatting errors are caught by this version.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Ensure test_types tests are using __backend__

mark currently failing Oracle interval tests

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    [docs] Fix, missing dot

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

    [docs] Apache Druid and Google sheets dialects

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

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

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

(cherry picked from commit 7f260c95d65f9bb77e4e0bbb8ef78f57b183fc7c)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

(cherry picked from commit 26d9a29514ea0949f09f75622065e737fabeabe1)

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

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

    [docs] Fix, typo

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

    [docs] Elasticsearch dialect and dbapi

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

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

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

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

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

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

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

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

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

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

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

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

Fixes #4938.

This pull request is:

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

**Have a nice day!**

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

5 years agoRefactor dialect tests for combinations
Mike Bayer [Mon, 21 Oct 2019 21:32:04 +0000 (17:32 -0400)] 
Refactor dialect tests for combinations

Dialect tests tend to have a lot of lists of types,
SQL constructs etc, convert as many of these to @combinations
as possible.

This is exposing that we don't have per-combination
exclusion rules set up which is making things a little bit
cumbersome.

Also set up a fixture that does metadata + DDL.

Change-Id: Ief820e48c9202982b0b1e181b87862490cd7b0c3
(cherry picked from commit 240d9a60ccdb540543a72d9ff30a6f50d33acc5d)

5 years agoImplment encoding_errors for cx_oracle
Mike Bayer [Mon, 12 Aug 2019 19:09:37 +0000 (15:09 -0400)] 
Implment encoding_errors for cx_oracle

Added dialect-level flag ``encoding_errors`` to the cx_Oracle dialect,
which can be specified as part of :func:`.create_engine`.   This is passed
to SQLAlchemy's unicode decoding converter under Python 2, and to
cx_Oracle's ``cursor.var()`` object as the ``encodingErrors`` parameter
under Python 3, for the very unusual case that broken encodings are present
in the target database which cannot be fetched unless error handling is
relaxed.  The value is ultimately one of the Python "encoding errors"
parameters passed to ``decode()``.

Closes: #4801
Fixes: #4799
Change-Id: I1d542ba367bcd187347c54db1fee815f7890e71c
(cherry picked from commit d76cb7213557c24609a1a75d8c391aea0179562a)

5 years agoMerge "Ensure SQL Server default schema name not interpreted as dot-separated tokens...
mike bayer [Mon, 21 Oct 2019 14:56:10 +0000 (14:56 +0000)] 
Merge "Ensure SQL Server default schema name not interpreted as dot-separated tokens" into rel_1_3

5 years agoImplement facade for pytest parametrize, fixtures, classlevel
Mike Bayer [Thu, 17 Oct 2019 17:09:24 +0000 (13:09 -0400)] 
Implement facade for pytest parametrize, fixtures, classlevel

Add factilities to implement pytest.mark.parametrize and
pytest.fixtures patterns, which largely resemble things we are
already doing.

Ensure a facade is used, so that the test suite remains independent
of py.test, but also tailors the functions to the more limited
scope in which we are using them.

Additionally, create a class-based version that works from the
same facade.

Several old polymorphic tests as well as two of the sql test
are refactored to use the new features.

Change-Id: I6ef8af1dafff92534313016944d447f9439856cf
References: #4896
(cherry picked from commit 696ef9421da763a0ffcfd98083c0af78db3ea756)

5 years ago- fix typo
Heckad [Sat, 19 Oct 2019 13:12:58 +0000 (16:12 +0300)] 
- fix typo

(cherry picked from commit 82cf32a6cf265927de49d0f5220ad13e0131d95e)

5 years agoFix pydoc typo in sqlite dialect
Matt Livesey [Thu, 17 Oct 2019 07:36:30 +0000 (09:36 +0200)] 
Fix pydoc typo in sqlite dialect

(cherry picked from commit a727f250ccc55df8532f6498ad46dd747ce32250)

5 years ago- add plugins for flake8 pre-commit hook
Mike Bayer [Fri, 18 Oct 2019 14:27:25 +0000 (10:27 -0400)] 
- add plugins for flake8 pre-commit hook

Change-Id: I18111dfb9915ec6002cd0b66be5d256c2e33a37f
(cherry picked from commit abcd84155b9ce16c333845a05d8029fc13a22ccf)

5 years agoEnsure SQL Server default schema name not interpreted as dot-separated tokens
Mike Bayer [Fri, 18 Oct 2019 01:29:51 +0000 (21:29 -0400)] 
Ensure SQL Server default schema name not interpreted as dot-separated tokens

Fixed an issue in the :meth:`.Engine.table_names` method where it would
feed the dialect's default schema name back into the dialect level table
function, which in the case of SQL Server would interpret it as a
dot-tokenized schema name as viewed by the mssql dialect, which would
cause the method to fail in the case where the database username actually
had a dot inside of it.  In 1.3, this method is still used by the
:meth:`.MetaData.reflect` function so is a prominent codepath. In 1.4,
which is the current master development branch, this issue doesn't exist,
both because :meth:`.MetaData.reflect` isn't using this method nor does the
method pass the default schema name explicitly.  The fix nonetheless
guards against the default server name value returned by the dialect from
being interpreted as dot-tokenized name under any circumstances by
wrapping it in quoted_name().

Fixes: #4923
Change-Id: I821bd38ed89b767eaca0bdffee7f8ba3baf82560
(cherry picked from commit f50c6a04067acf2cd2fc5e42d5acaa9206d9a078)

5 years agoFix test failures from func doc fix
Mike Bayer [Fri, 18 Oct 2019 02:11:31 +0000 (22:11 -0400)] 
Fix test failures from func doc fix

The doc edits in e45878bf4f9cdfb714dce8b2a4d705178947674d
triggered a doctest and a pep8 failure.

Change-Id: I41c6cba9bab2d3721d9c6280be47eec32f4b4736
(cherry picked from commit d25c03310fd3523392d37b88c23c48cf26836248)

5 years agofix func docs
Mike Bayer [Thu, 17 Oct 2019 19:04:47 +0000 (15:04 -0400)] 
fix func docs

sphinx is not generating the docs for func.  cross-copy
__doc__ and also add more links.

Fixes: #4922
Change-Id: I5512111d726b6fcf9821be730c9e29adc73c95cb
(cherry picked from commit e45878bf4f9cdfb714dce8b2a4d705178947674d)

5 years agoUpgrade for python 3.8
Mike Bayer [Thu, 17 Oct 2019 12:45:03 +0000 (08:45 -0400)] 
Upgrade for python 3.8

- remove pymssql again, there are no py38 builds and the project
seems stalled again

- ideally we would have no pyenvs listed out for tox but for now
add py38

Change-Id: Iee2e3da96d2d0e4357aaf2ade735c4b8300c3c12
(cherry picked from commit f87570acaee8aeb0ae89be2b701fc7a9ce3a5a26)

5 years agoUse cx_Oracle.FIXED_NCHAR for sqltypes.NCHAR
Mike Bayer [Tue, 15 Oct 2019 01:53:44 +0000 (21:53 -0400)] 
Use cx_Oracle.FIXED_NCHAR for sqltypes.NCHAR

The :class:`.sqltypes.NCHAR` datatype will now bind to the
``cx_Oracle.FIXED_NCHAR`` DBAPI data bindings when used in a bound
parameter, which supplies proper comparison behavior against a
variable-length string.  Previously, the :class:`.sqltypes.NCHAR` datatype
would bind to ``cx_oracle.NCHAR`` which is not fixed length; the
:class:`.sqltypes.CHAR` datatype already binds to ``cx_Oracle.FIXED_CHAR``
so it is now consistent that :class:`.sqltypes.NCHAR` binds to
``cx_Oracle.FIXED_NCHAR``.

Fixes: #4913
Change-Id: I5bb111f2e06bbdd525bc5f716579baad31bbb3db
(cherry picked from commit e4a5da1c5a4ed038c1c28f236e2e963b27554549)

5 years agoClarify isolation_level documentation
Mike Bayer [Tue, 15 Oct 2019 15:27:51 +0000 (11:27 -0400)] 
Clarify isolation_level documentation

Fixes: #4909
Change-Id: I32114a8349c1d2d0a837610ccc74f9e789ed20f5
(cherry picked from commit 2ef87804e9b7d3048dcbd70d526282f727b48eb0)

5 years ago- add py38 to tox list
Mike Bayer [Mon, 14 Oct 2019 23:24:26 +0000 (19:24 -0400)] 
- add py38 to tox list

Change-Id: I1488d7954b95d62e9ecd5e85747123eb7460d9cd

5 years agoMerge "Use separate label generator for column_label naming convention" into rel_1_3
mike bayer [Mon, 14 Oct 2019 19:25:52 +0000 (19:25 +0000)] 
Merge "Use separate label generator for column_label naming convention" into rel_1_3

5 years agolink to Google BigQuery dialect
Aidan Feldman [Sat, 12 Oct 2019 02:52:28 +0000 (22:52 -0400)] 
link to Google BigQuery dialect

(cherry picked from commit 0d93a7b8fb40b334a4a1ea67274aaa47f7598ad7)

5 years agoUse separate label generator for column_label naming convention
Mike Bayer [Mon, 14 Oct 2019 00:33:24 +0000 (20:33 -0400)] 
Use separate label generator for column_label naming convention

Fixed bug where a table that would have a column label overlap with a plain
column name, such as "foo.id AS foo_id" vs. "foo.foo_id", would prematurely
generate the ``._label`` attribute for a column before this overlap could
be detected due to the use of the ``index=True`` or ``unique=True`` flag on
the column in conjunction with the default naming convention of
``"column_0_label"``.  This would then lead to failures when ``._label``
were used later to generate a bound parameter name, in particular those
used by the ORM when generating the WHERE clause for an UPDATE statement.
The issue has been fixed by using an alternate ``._label`` accessor for DDL
generation that does not affect the state of the :class:`.Column`.   The
accessor also bypasses the key-deduplication step as it is not necessary
for DDL, the naming is now consistently ``"<tablename>_<columnname>"``
without any subsequent numeric symbols when used in DDL.

Fixes: #4911
Change-Id: Iabf5fd3250738d800d6e41a2a3a27a7ce2405e7d
(cherry picked from commit 41dc71ad2fc1963a44e5f308f53aed6b8d7d662a)

5 years ago- add flake8 as a pre commit hook
Mike Bayer [Sun, 13 Oct 2019 22:56:25 +0000 (18:56 -0400)] 
- add flake8 as a pre commit hook

Change-Id: Ie9187b9aac636b198df39428cdcb4bcf6f819879
(cherry picked from commit 6b2875eba531a0b879ec345ec85fae00f522ff03)

5 years agoMerge "added additional error message to is_disconnect() for Firebird dialects" into...
mike bayer [Fri, 11 Oct 2019 17:30:33 +0000 (17:30 +0000)] 
Merge "added additional error message to is_disconnect() for Firebird dialects" into rel_1_3

5 years agopass executemany context to _repr_params
Mike Bayer [Wed, 9 Oct 2019 17:55:19 +0000 (13:55 -0400)] 
pass executemany context to _repr_params

Fixed bug where parameter repr as used in logging and error reporting needs
additional context in order to distinguish between a list of parameters for
a single statement and a list of parameter lists, as the "list of lists"
structure could also indicate a single parameter list where the first
parameter itself is a list, such as for an array parameter.   The
engine/connection now passes in an additional boolean indicating how the
parameters should be considered.  The only SQLAlchemy backend that expects
arrays as parameters is that of  psycopg2 which uses pyformat parameters,
so this issue has not been too apparent, however as other drivers that use
positional gain more features it is important that this be supported. It
also eliminates the need for the parameter repr function to guess based on
the parameter structure passed.

Fixes: #4902
Change-Id: I086246ee0eb51484adbefd83e07295fa56576c5f
(cherry picked from commit 9488480abea15298ded6996aa13b42edf134e467)

5 years agoadded additional error message to is_disconnect() for Firebird dialects
lukens [Thu, 10 Oct 2019 16:06:15 +0000 (12:06 -0400)] 
added additional error message to is_disconnect() for Firebird dialects

Added additional "disconnect" message "Error writing data to the
connection" to Firebird disconnection detection.  Pull request courtesy
lukens.

Fixes: #4903
Closes: #4904
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4904
Pull-request-sha: c56d7c4abf6b6c8263efaf070b4e7a319e12a875

Change-Id: Ib70c20c616e7519b933fee587a3b3e8dbb4c2f81
(cherry picked from commit 31e3fc94ad268cf762f564209113d66221b04b42)

5 years agoVersion 1.3.11 placeholder
Mike Bayer [Thu, 10 Oct 2019 00:34:13 +0000 (20:34 -0400)] 
Version 1.3.11 placeholder

5 years ago- 1.3.10 rel_1_3_10
Mike Bayer [Wed, 9 Oct 2019 22:31:36 +0000 (18:31 -0400)] 
- 1.3.10

5 years agoRepair Oracle compat version check; dont warn if failed
Mike Bayer [Wed, 9 Oct 2019 20:05:34 +0000 (16:05 -0400)] 
Repair Oracle compat version check; dont warn if failed

Fixed regression in Oracle dialect that was inadvertently using max
identifier length of 128 characters on Oracle server 12.2 and greater even
though the stated contract for the remainder of the 1.3 series is  that
this value stays at 30 until version SQLAlchemy 1.4.  Also repaired issues
with the retrieval of the "compatibility" version, and removed the warning
emitted when the "v$parameter" view was not accessible as this was  causing
user confusion.

Fixes: #4898
Change-Id: Ieb7b3e093610896c5aa12d0789b63262e0ecf9d8

5 years agoBackport pysqlite dialect modernizations
Mike Bayer [Tue, 8 Oct 2019 19:53:38 +0000 (15:53 -0400)] 
Backport pysqlite dialect modernizations

Backporting the doc update, module import and the
removal of the old pysqlite version warning from
a0d94763f8369939ae6b731d6b599b5edb05d37e.

Change-Id: I989cc9c1128cc5f8c83ba57944d1ee3a733b3036
References: #4895

5 years agofix error in test_round_trip for TimeTest with mysql+pyodbc
Gord Thompson [Thu, 3 Oct 2019 22:18:54 +0000 (18:18 -0400)] 
fix error in test_round_trip for TimeTest with mysql+pyodbc

Fixes: #4879
### Description
create mysql+pyodbc-specific `_pyodbcTIME` class to avoid error thrown by `result_processor` in the (more) generic mysql/types.py.

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

-->

This pull request is:

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

**Have a nice day!**

Closes: #4880
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4880
Pull-request-sha: 2e4c468c3ad685d6573e0d9755ba97a28df50b6c

Change-Id: Ib5c5b0971969c2a9870b7f43d06703618cfc56f7
(cherry picked from commit f94940e4d88b4011fd089bed37cebb76acb1a385)

5 years agolist sqlalchemy-access as external dialect
Gord Thompson [Tue, 8 Oct 2019 12:27:05 +0000 (06:27 -0600)] 
list sqlalchemy-access as external dialect

(cherry picked from commit 0089d4e3f6cbc9131f481895c9f8feb22454fa83)

5 years agoFix max_identifier_length for SQL server
Mike Bayer [Mon, 7 Oct 2019 20:12:30 +0000 (16:12 -0400)] 
Fix max_identifier_length for SQL server

Fixed bug in SQL Server dialect with new "max_identifier_length" feature
where the mssql dialect already featured this flag, and the implementation
did not accommodate for the new initialization hook correctly.

Fixes: #4857
Change-Id: I96a9c6ca9549d8f6fb167c0333f684e8d922a3bf
(cherry picked from commit 2ba70aba90c69152641b2cce838b3afa35c8586c)

5 years agoVersion 1.3.10 placeholder
Mike Bayer [Fri, 4 Oct 2019 20:17:22 +0000 (16:17 -0400)] 
Version 1.3.10 placeholder

5 years ago- 1.3.9 rel_1_3_9
Mike Bayer [Fri, 4 Oct 2019 20:07:01 +0000 (16:07 -0400)] 
- 1.3.9

5 years ago- fix typo
Mike Bayer [Fri, 4 Oct 2019 20:06:28 +0000 (16:06 -0400)] 
- fix typo

Change-Id: I8275a9cbb9a664badbaf759ec62399ac0ead9b20
(cherry picked from commit 0e42cdced4d6ce45517192774545f7aeb061cb9d)

5 years agoWarn for object replaced in identity map during flush
Mike Bayer [Fri, 4 Oct 2019 15:12:27 +0000 (11:12 -0400)] 
Warn for object replaced in identity map during flush

A warning is emitted for a condition in which the :class:`.Session` may
implicitly swap an object out of the identity map for another one with the
same primary key, detaching the old one, which can be an observed result of
load operations which occur within the :meth:`.SessionEvents.after_flush`
hook.  The warning is intended to notify the user that some special
condition has caused this to happen and that the previous object may not be
in the expected state.

Fixes: #4890
Change-Id: Ide11c6b9f21ca67ff5a96266c521d0c56fd6af8d
(cherry picked from commit 4aa43ecbd78e5a7dd3d983ca46a377af4e01877e)

5 years agoimport StringIO => import io
Matt Kohl [Fri, 4 Oct 2019 05:56:50 +0000 (06:56 +0100)] 
import StringIO => import io

(cherry picked from commit edf8e782cf5011cd43a0ee281b9e0b1d1becef1f)

5 years agoMerge "call setinputsizes for cx_Oracle.DATETIME" into rel_1_3
mike bayer [Thu, 3 Oct 2019 21:41:51 +0000 (21:41 +0000)] 
Merge "call setinputsizes for cx_Oracle.DATETIME" into rel_1_3

5 years agocall setinputsizes for cx_Oracle.DATETIME
Mike Bayer [Thu, 3 Oct 2019 18:09:54 +0000 (14:09 -0400)] 
call setinputsizes for cx_Oracle.DATETIME

Restored adding cx_Oracle.DATETIME to the setinputsizes() call when a
SQLAlchemy :class:`.Date`, :class:`.DateTime` or :class:`.Time` datatype is
used, so that in the case where a bound parameter is passed as NULL
in some complex queries (in particular this happens with some lazy load
situations), the type is still present.  This was removed
in the 1.2 series for arbitrary reasons.

Also adds a suite test for this generic situation.

What's not clear is that do we really need setinputsizes() for all
datatypes if we are supporting NULL in bound parameters.

Fixes: #4886
Change-Id: If99215c31861f9ea6f60a30d47f2f320adc4797f
(cherry picked from commit e21afbcd8c78e4e3f9400da1a2565472682de825)

5 years agoApply quoting to SQL Server _switch_db
Mike Bayer [Thu, 3 Oct 2019 15:18:06 +0000 (11:18 -0400)] 
Apply quoting to SQL Server _switch_db

Added identifier quoting to the schema name applied to the "use" statement
which is invoked when a SQL Server multipart schema name is used within  a
:class:`.Table` that is being reflected, as well as for :class:`.Inspector`
methods such as :meth:`.Inspector.get_table_names`; this accommodates for
special characters or spaces in the database name.  Additionally, the "use"
statement is not emitted if the current database matches the target owner
database name being passed.

Fixes: #4883
Change-Id: I84419730e94aac3a88d331ad8c24d10aabbc34af
(cherry picked from commit 66a7befa0c549b92d42afbb5be2b45da13793250)

5 years agoAdd max_identifier_length parameter; warn for Oracle
Mike Bayer [Wed, 2 Oct 2019 15:20:58 +0000 (11:20 -0400)] 
Add max_identifier_length parameter; warn for Oracle

Added new :func:`.create_engine` parameter
:paramref:`.create_engine.max_identifier_length`. This overrides the
dialect-coded "max identifier length" in order to accommodate for databases
that have recently changed this length and the SQLAlchemy dialect has
not yet been adjusted to detect for that version.  This parameter interacts
with the existing :paramref:`.create_engine.label_length` parameter in that
it establishes the maximum (and default) value for anonymously generated
labels.

The Oracle dialect now emits a warning if Oracle version 12.2 or greater is
used, and the :paramref:`.create_engine.max_identifier_length` parameter is
not set.   The version in this specific case defaults to that of the
"compatibility" version set in the Oracle server configuration, not the
actual server version.   In version 1.4, the default max_identifier_length
for 12.2 or greater will move to 128 characters.  In order to maintain
forwards compatibility, applications should set
:paramref:`.create_engine.max_identifier_length` to 30 in order to maintain
the same length behavior, or to 128 in order to test the upcoming behavior.
This length determines among other things how generated constraint names
are truncated for statements like ``CREATE CONSTRAINT`` and ``DROP
CONSTRAINT``, which means a the new length may produce a name-mismatch
against a name that was generated with the old length, impacting database
migrations.

Fixes: #4857
Change-Id: Ib62efb00c6180c375869029b57353d90385d7950
(cherry picked from commit 88761b8b0b0cfa67cdd6a4913e3a0ea5cba93cbb)

5 years agoMerge "Deprecate plain string passed to session.query()" into rel_1_3
mike bayer [Mon, 30 Sep 2019 17:08:31 +0000 (17:08 +0000)] 
Merge "Deprecate plain string passed to session.query()" into rel_1_3

5 years agoDeprecate plain string passed to session.query()
Mike Bayer [Mon, 30 Sep 2019 14:54:50 +0000 (10:54 -0400)] 
Deprecate plain string passed to session.query()

Passing a plain string expression to :meth:`.Session.query` is deprecated,
as all string coercions were removed in :ticket:`4481` and this one should
have been included.   The :func:`.literal_column` function may be used to
produce a textual column expression.

Note this changeset is in the 1.3 branch only.  The 1.4 (currently master)
branch will already have removed this behavior.

Fixes: #4873
Change-Id: I20067a6707c7e2f028c67b1fbf0e8e4d9d136233

5 years agoEnsure states with null m2o FK value are still populated by selectinloader
Mike Bayer [Mon, 30 Sep 2019 13:55:40 +0000 (09:55 -0400)] 
Ensure states with null m2o FK value are still populated by selectinloader

Fixed regression in selectinload loader strategy caused by #4775 (released
in version 1.3.6) where a many-to-one attribute of None would no longer be
populated by the loader.  While this was usually not noticeable due to the
lazyloader populating None upon get, it would lead to a detached instance
error if the object were detached.

Fixes: #4872
Change-Id: I18466841683111643810ebc4331376df38c4767b
(cherry picked from commit 9f3539b1745cbb287a1338812872d27cde4ebf24)

5 years agoSupport SQLite URIs
Mike Bayer [Fri, 20 Sep 2019 13:25:40 +0000 (09:25 -0400)] 
Support SQLite URIs

Added support for sqlite "URI" connections, which allow for sqlite-specific
flags to be passed in the query string such as "read only" for Python
sqlite3 drivers that support this.

Fixes: #4863
Change-Id: I7740b55ee8f2ede72a5c49ee94a7540e4d0250f2
(cherry picked from commit adb495503dab660f014cad0200491c854d2f6a50)

5 years agoAdd req for nullable booleans
Mike Bayer [Wed, 18 Sep 2019 13:56:33 +0000 (09:56 -0400)] 
Add req for nullable booleans

Access doesn't allow for Yes/No columns to store null, so add
a rule for this.

Change-Id: If9316cd05733e39fbd59a6f54024f6740b563041
(cherry picked from commit 6cfbd5fefef51374d3c60fb58e094db00643faa0)

5 years agoAdd missing suite_level requirements "independent_connections"
Mike Bayer [Wed, 18 Sep 2019 12:47:46 +0000 (08:47 -0400)] 
Add missing suite_level requirements "independent_connections"

In 14b1e6fe8e18d139846c1aba6761d4eea3dc25c3 we added
suite-level requirements but did not add them to the
base, causing failures in third party dialect test suites.

Change-Id: I7edf0be86b814b508071c5c752fc2dd744a3d9ad
(cherry picked from commit f79967441fd092ba9cc81f53b6a71e8cf0223b35)

5 years agoFix typo in docs (errors.rst)
Mikhail Burshteyn [Wed, 18 Sep 2019 11:00:26 +0000 (14:00 +0300)] 
Fix typo in docs (errors.rst)

(cherry picked from commit af94e639ae7b0e2ee3d8caf92b0f7e128f4199ab)

5 years agoAdd missing suite level requirements from 2efd89d02941
Mike Bayer [Wed, 18 Sep 2019 01:04:21 +0000 (21:04 -0400)] 
Add missing suite level requirements from 2efd89d02941

In 2efd89d02941ab4267d6e2842963fd38b1539f6c we added
suite-level requirements but did not add them to the
base, causing failures in third party dialect test suites.

Change-Id: Ic5f1a053f5c47166e1b12c613595823106c8736e
(cherry picked from commit 33648643f227929f083b67d817701f930078f901)

5 years agoAdd missing suite level requirements from #4234
Mike Bayer [Tue, 17 Sep 2019 16:49:46 +0000 (12:49 -0400)] 
Add missing suite level requirements from #4234

In 9d5e117f6fcc38d8773bc943c615888dc8a3a819 we added
suite-level requirements but did not add them to the
base, causing failures in third party dialect test suites.

Change-Id: I030b5d0fd957814dfce77a71b59babd9b5e3b1bc
References: #4234
(cherry picked from commit f92fa1b5dfceb5c079a46db598294db133cb0cac)

5 years agoAdd note on the use of tuple_() for the IN operator in the docs
Stepland [Mon, 16 Sep 2019 15:40:29 +0000 (11:40 -0400)] 
Add note on the use of tuple_() for the IN operator in the docs

Closes: #4861
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4861
Pull-request-sha: c7379d390752d0c10d6488872b163b06ee30d952

Change-Id: I223008f720fe64951e2a0bf95aab955ece22516b
(cherry picked from commit 6a60d7305bafc311115543e0c2cb5136a254edf2)

5 years agoDocument visitors module
Mike Bayer [Thu, 12 Sep 2019 16:37:38 +0000 (12:37 -0400)] 
Document visitors module

As we are going to be adding a lot of new features to the visitors
module which may impact end-user custom constructs, start documenting
the package for now.

Change-Id: Ibae471c2cb861f6280f601b7b2382d61968825cd
(cherry picked from commit ed02d924dd0bd1bce56b40bea74e1d382c352833)

5 years agoUse compat.raise_from_cause() for re-raise of schema item error
Mike Bayer [Sun, 8 Sep 2019 01:34:14 +0000 (21:34 -0400)] 
Use compat.raise_from_cause() for re-raise of schema item error

Fixes: #4847
Change-Id: I5bc8a87ccae1b49ea507d344b7933c248e04ee89
(cherry picked from commit 17b7b3027f0e994cf47bf5fa3e536d3971076dcd)

5 years agoCatch set_parent_w_dispatch missing
Mike Bayer [Fri, 6 Sep 2019 22:40:46 +0000 (18:40 -0400)] 
Catch set_parent_w_dispatch missing

Added an explicit error message for the case when objects passed to
:class:`.Table` are not :class:`.SchemaItem` objects, rather than resolving
to an attribute error.

Fixes: #4847
Change-Id: I4dcdcee86b64c85ccf12e2ddc3d638563d307991
(cherry picked from commit 7afcb39a962d383e5ba04179c1b13131fb08a787)