]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
6 years agoFix typo in documentation examples 4734/head
Emile Caron [Mon, 17 Jun 2019 14:25:21 +0000 (16:25 +0200)] 
Fix typo in documentation examples

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

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

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

Fixes: #4730
Change-Id: I300941f27872fc4298c74a1d1ed65aef1a5cdd82

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

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

Fixes: #4729
Change-Id: Ia02388cc25d004e32d337140b62a587f3e5a0b7b

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

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

Change-Id: I27605d7cf16ce79f9d577dbc84e3bd51b7c9b4ae

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

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

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

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

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

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

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

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

Also fix DetectKeySwitch for intermediary class relationship

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

Fixes: #4723
Change-Id: Idc408ead67702068e64d583a15149dd4beeefc24

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

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

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

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

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

Change-Id: Ia8831cc171d131bf3824be8db4fd1d231231bba3

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

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

Fixes: #4712
Change-Id: Ibc6c8d981cff31594a5d26dd5203fd9cfcea1c74

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

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

Change-Id: I7291e647c177d338e0ad673f3106b4d503e4b3ea

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

Change-Id: I4f59cd69dc2319732acf64cb000946c09124ceff

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

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

Change-Id: Ib96838ce8169e989e1c8ad3a4819b4ebd3ffdc39

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

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

Change-Id: I557872aff255b07e14dd843aa024e027a017afb8

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

6 years agoAdd "usecase" changelog tag
Mike Bayer [Mon, 3 Jun 2019 16:48:14 +0000 (12:48 -0400)] 
Add "usecase" changelog tag

"usecase" indicates the library now supports something a user
was trying to do.  It's not quite a "feature" since it's something
that seems like it should have worked, it's not a "bug" because
no mistake was made, it's just something that wasn't considered before.
The advantage of "usecase" is that it inherently suggests a different
style of prioritization vs. something that is preventing the library
from working as designed.

This change also adds docs/build/conf.py under the pep8 formatting
test coverage.

Change-Id: I790ccb799864fec48e4695aedeed2814ab9d493e

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

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

Fixes: #4704
Change-Id: I69f76c97b11157100854d552b5a0ce0103642ec4

6 years ago- formatting
Mike Bayer [Fri, 31 May 2019 15:24:30 +0000 (11:24 -0400)] 
- formatting

Change-Id: Ic08044c65a15989839f4d6f92ccf9d1a8a8da8dc

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

6 years agoMerge "Rework AliasedClass __getattr__ to use top-level getattr()"
mike bayer [Fri, 31 May 2019 00:50:20 +0000 (00:50 +0000)] 
Merge "Rework AliasedClass __getattr__ to use top-level getattr()"

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

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

Fixes: #4701
Change-Id: I202bab19728862cbc64deae211d5ba6a103b8317

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

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

Fixes: #4674
Change-Id: I1ab8729c4072634db80c79bb7bc44197dc5e7114

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

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

Fixes: #4694
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: I28901e2472d3c21e881fe5cafa3b1d3af704fad8

6 years agoMerge "Use roles for ORM alias() conversion"
mike bayer [Wed, 29 May 2019 03:07:28 +0000 (03:07 +0000)] 
Merge "Use roles for ORM alias() conversion"

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

Change-Id: I9ee75862924cd8f95ea8d812ab2e2a0ff4e48a66

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

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

Change-Id: Ife51bbc74d6c1b8ab9a736024818fbba35316e17

6 years agocherry-pick changelog update for 1.3.5
Mike Bayer [Tue, 28 May 2019 02:11:35 +0000 (22:11 -0400)] 
cherry-pick changelog update for 1.3.5

6 years agocherry-pick changelog from 1.3.4
Mike Bayer [Tue, 28 May 2019 02:11:35 +0000 (22:11 -0400)] 
cherry-pick changelog from 1.3.4

6 years agoCreate FUNDING.yml
mike bayer [Tue, 28 May 2019 01:36:16 +0000 (21:36 -0400)] 
Create FUNDING.yml

6 years agoUse roles for ORM alias() conversion
Mike Bayer [Sun, 19 May 2019 00:35:01 +0000 (20:35 -0400)] 
Use roles for ORM alias() conversion

as SELECT statements will have subquery() and not alias(),
start getting ready for the places where the ORM coerces SELECTs
into subqueries and be ready to warn about it

Change-Id: I90d4b6cae2c72816c6b192016ce074589caf4731

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

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

Change-Id: I4c5791223e7fd21e04dcd095daa7d868e77dbd97

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

6 years agoMerge "Hold implicitly created collections in a pending area"
mike bayer [Mon, 27 May 2019 22:36:27 +0000 (22:36 +0000)] 
Merge "Hold implicitly created collections in a pending area"

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

Change-Id: I379b3d9e59ff8cda17c2d738fde794249f105510

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

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

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

Change-Id: I967710f890722f11cf1f40406adbb17464d16194

6 years agoHold implicitly created collections in a pending area
Mike Bayer [Sat, 25 May 2019 22:04:58 +0000 (18:04 -0400)] 
Hold implicitly created collections in a pending area

Accessing a collection-oriented attribute on a newly created object no
longer mutates ``__dict__``, but still returns an empty collection as has
always been the case.   This allows collection-oriented attributes to work
consistently in comparison to scalar attributes which return ``None``, but
also don't mutate ``__dict__``.  In order to accommodate for the collection
being mutated, the same empty collection is returned each time once
initially created, and when it is mutated (e.g. an item appended, added,
etc.) it is then moved into ``__dict__``.  This removes the last of
mutating side-effects on read-only attribute access within the ORM.

Fixes: #4519
Change-Id: I06a058d24e6eb24b5c6b6092d3f8b31cf9c244ae

6 years agoStill more things we forgot for setting up 1.4
Mike Bayer [Mon, 27 May 2019 15:09:44 +0000 (11:09 -0400)] 
Still more things we forgot for setting up 1.4

- main version number in __init__.py
- changelog index page

Fixes: #4631
Change-Id: I7ccdec1b60053e1a29542b94143b01b341193d00

6 years agoMerge "Unify NO_VALUE and NEVER_SET"
mike bayer [Sat, 25 May 2019 14:28:27 +0000 (14:28 +0000)] 
Merge "Unify NO_VALUE and NEVER_SET"

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

Fixes: #4697
Change-Id: I46d395d3b6642acd9317e27d6a5723ae5201e877

6 years agoUnify NO_VALUE and NEVER_SET
Mike Bayer [Thu, 23 May 2019 22:01:07 +0000 (18:01 -0400)] 
Unify NO_VALUE and NEVER_SET

There's no real difference between these two constants
except they are used in different places and therefore allow
various codepaths to work largely by accident.   These
codepaths should be explicit.   Assign NO_VALUE and NEVER_SET
to the same constant and work towards having just one constant
for "we have no value to return right now".

Fixes: #4696
Change-Id: I7c324967952c1886bf202074d627323a2ad013cc

6 years agoMerge remote-tracking branch 'origin/pr/4565'
Mike Bayer [Thu, 23 May 2019 18:31:00 +0000 (14:31 -0400)] 
Merge remote-tracking branch 'origin/pr/4565'

Change-Id: I6804057ea38d4994fae1a65381457fb9d3c002b6

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

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

Change-Id: I39593d2414ee9ec5e5ed1a9e2b00cbf9fe743b79

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

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

Fixes: #4695
Change-Id: Ie384f4847f37c267d94b6d56e7538438efc1a54c

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

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

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

Fixes: #4691
Change-Id: I137bd74e5d93971bbd04758c7a022a026e13b423

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

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

Fixes: #4690
Change-Id: I5b5300661291c94a23de53bcf92d747701720aa1

6 years agoImplement new ClauseElement role and coercion system
Mike Bayer [Tue, 30 Apr 2019 03:26:36 +0000 (23:26 -0400)] 
Implement new ClauseElement role and coercion system

A major refactoring of all the functions handle all detection of
Core argument types as well as perform coercions into a new class hierarchy
based on "roles", each of which identify a syntactical location within a
SQL statement.  In contrast to the ClauseElement hierarchy that identifies
"what" each object is syntactically, the SQLRole hierarchy identifies
the "where does it go" of each object syntactically.   From this we define
a consistent type checking and coercion system that establishes well
defined behviors.

This is a breakout of the patch that is reorganizing select()
constructs to no longer be in the FromClause hierarchy.

Also includes a rename of as_scalar() into scalar_subquery(); deprecates
automatic coercion to scalar_subquery().

Partially-fixes: #4617
Change-Id: I26f1e78898693c6b99ef7ea2f4e7dfd0e8e1a1bd

6 years agoRepair anonymous label comparison
Mike Bayer [Sat, 18 May 2019 21:39:22 +0000 (17:39 -0400)] 
Repair anonymous label comparison

Add a test for comparison of named labels vs. anonymous

Change-Id: I57ada3cf79d982ff32a298cf73a748d353b63dac

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

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

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

Change-Id: I4bbb49747e9f7fb52251dc61ecda98361cd036fd

6 years agoMerge "Mutex the declarative scan/map process against configure_mappers()"
mike bayer [Fri, 17 May 2019 17:06:02 +0000 (17:06 +0000)] 
Merge "Mutex the declarative scan/map process against configure_mappers()"

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

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

Fixes: #4686
Change-Id: I0349036b8078bd42265ab40862cfbfe5bf9d5b44

6 years agoMerge "Turn FlushError for identity already exists into a warning."
mike bayer [Thu, 16 May 2019 02:09:05 +0000 (02:09 +0000)] 
Merge "Turn FlushError for identity already exists into a warning."

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

Change-Id: I2a694bcf24b06806dc98651015e7c7a8b090ff65

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

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

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

Change-Id: Ifc7ffc4c933b08a34fad537dc48e05d2cfa66d42

6 years agoMerge "Continue to assume None for un-accessed attribute on persistent object during...
mike bayer [Tue, 14 May 2019 14:49:32 +0000 (14:49 +0000)] 
Merge "Continue to assume None for un-accessed attribute on persistent object during m2o fetch"

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

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

Fixes: #4676
Change-Id: I17160c30131187c735f025a785ff0276a246f6bb

6 years agoMerge "Resolve RST306 issues"
mike bayer [Mon, 13 May 2019 22:41:33 +0000 (22:41 +0000)] 
Merge "Resolve RST306 issues"

6 years agoMerge remote-tracking branch 'origin/pr/4626'
Mike Bayer [Mon, 13 May 2019 22:38:46 +0000 (18:38 -0400)] 
Merge remote-tracking branch 'origin/pr/4626'

Change-Id: I2bf9e1bb44f11acd0d29bd1ab5e35b4c7b77c8dd

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

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

Change-Id: I8045309aa2ad29978ba7e99c45f75bc1457dff3d

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

Fixes: #4675
Change-Id: I593c3a891462818e7095a30bf6cd7795ca143ad1

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

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

Fixes: #4661
Change-Id: Ie57f765ff31bf806206837c5fbfe449b02ebf4be

6 years agoMove initialize do_rollback() outside of the dialect
Matthew Wilkes [Thu, 9 May 2019 22:04:35 +0000 (18:04 -0400)] 
Move initialize do_rollback() outside of the dialect

Moved the "rollback" which occurs during dialect initialization so that it
occurs after additional dialect-specific initialize steps, in particular
those of the psycopg2 dialect which would inadvertently leave transactional
state on the first new connection, which could interfere with some
psycopg2-specific APIs which require that no transaction is started.  Pull
request courtesy Matthew Wilkes.

Fixes: #4663
Closes: #4664
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4664
Pull-request-sha: e544fe671d443ed06b210ba1cd1d7ba9c5653831

Change-Id: If40a15a1679b4eec0b8b8222f678697728009c30

6 years ago- fix long line
Mike Bayer [Fri, 10 May 2019 00:32:04 +0000 (20:32 -0400)] 
- fix long line

Change-Id: If44d364ae02da447169a3dc51b6514225578cf82

6 years ago- remove references to nose
Mike Bayer [Thu, 9 May 2019 15:57:12 +0000 (11:57 -0400)] 
- remove references to nose

Change-Id: I970cc257dfb1c69413fa1c5593ba523ffc5070d4

6 years agoAdd documentation for MySQL optimizer hints using prefix_with
Mike Bayer [Wed, 8 May 2019 15:40:12 +0000 (11:40 -0400)] 
Add documentation for MySQL optimizer hints using prefix_with

Fixes: #4667
Change-Id: Iac3345319dc7c5a20bc7a6520492d2f341b64807

6 years agoTurn FlushError for identity already exists into a warning.
Mike Bayer [Tue, 7 May 2019 15:38:48 +0000 (11:38 -0400)] 
Turn FlushError for identity already exists into a warning.

The condition where a pending object being flushed with an identity that
already exists in the identity map has been adjusted to emit a warning,
rather than throw a :class:`.FlushError`. The rationale is so that the
flush will proceed and raise a :class:`.IntegrityError` instead, in the
same way as if the existing object were not present in the identity map
already.   This helps with schemes that are uinsg the
:class:`.IntegrityError` as a means of catching whether or not a row
already exists in the table.

Fixes: #4662
Change-Id: I9314550b7b03d7f376ef35518da7542e0f2f7cb6

6 years agoMerge "Don't warn on multi delete rowcount if supports_sane_multi is False"
mike bayer [Tue, 7 May 2019 13:59:09 +0000 (13:59 +0000)] 
Merge "Don't warn on multi delete rowcount if supports_sane_multi is False"

6 years agoMerge "Do not register the GenericFunction in sql.functions._registry"
mike bayer [Tue, 7 May 2019 13:58:19 +0000 (13:58 +0000)] 
Merge "Do not register the GenericFunction in sql.functions._registry"

6 years agoAdd support for filtered indexes for mssql dialect
mollardthomas [Fri, 3 May 2019 15:31:57 +0000 (11:31 -0400)] 
Add support for filtered indexes for mssql dialect

Added support for SQL Server filtered indexes, via the ``mssql_where``
parameter which works similarly to that of the ``postgresql_where`` index
function in the PostgreSQL dialect.

Fixes: #4657
Closes: #4658
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4658
Pull-request-sha: cf609c19bccc74c0dba38d2fc4976df3a205f3f6

Change-Id: I9c61b97d0b0cb6f6d417da7b1875b40f8f918a3c

6 years agoDo not register the GenericFunction in sql.functions._registry
Adrien Berchet [Fri, 3 May 2019 16:02:17 +0000 (12:02 -0400)] 
Do not register the GenericFunction in sql.functions._registry

Fixed that the :class:`.GenericFunction` class was inadvertently
registering itself as one of the named functions.  Pull request courtesy
Adrien Berchet.

Fixes: #4653
Closes: #4654
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4654
Pull-request-sha: 1112b89f0d5af8cd5ba88cef744698a79dbdb963

Change-Id: Ia0d366d3bff44a763aa496287814278dff732a19

6 years agoDon't warn on multi delete rowcount if supports_sane_multi is False
Mike Bayer [Fri, 3 May 2019 22:07:06 +0000 (18:07 -0400)] 
Don't warn on multi delete rowcount if supports_sane_multi is False

Fixed an issue where the "number of rows matched" warning would emit even if
the dialect reported "supports_sane_multi_rowcount=False", as is the case
for psycogp2 with ``use_batch_mode=True`` and others.

Fixes: #4661
Change-Id: I93aaf7f597b6083e860ab3cbcd620ba5621c57a8

6 years agoOpen up mysql CHECK constraint detection to include new versions
Mike Bayer [Sat, 4 May 2019 17:19:10 +0000 (13:19 -0400)] 
Open up mysql CHECK constraint detection to include new versions

MySQL 8.0.16 introduces real CHECK constraints and MariaDB has also
added them into the 10.2 series sometime before 10.2.22.

Change-Id: Ia0f1be69f99df935aae069f63381bcc994f73cc7

6 years agoInclude GenericTypeCompiler in docs
Bjørnar Myrheim [Wed, 1 May 2019 07:39:26 +0000 (09:39 +0200)] 
Include GenericTypeCompiler in docs

Fixes: #4411
Change-Id: Ic60e78555651d05ff0492650bd7647685b867671
Closes: #4651
6 years agoMake the GenericFunction registry fully case insensitive
Mike Bayer [Mon, 29 Apr 2019 21:31:12 +0000 (17:31 -0400)] 
Make the GenericFunction registry fully case insensitive

Registered function names based on :class:`.GenericFunction` are now
retrieved in a case-insensitive fashion in all cases, removing the
deprecation logic from 1.3 which temporarily allowed multiple
:class:`.GenericFunction` objects to exist with differing cases.   A
:class:`.GenericFunction` that replaces another on the same name whether or
not it's case sensitive emits a warning before replacing the object.

Fixes: #4649
Change-Id: I265ae19833132db07ed5b5ae40c4d24f659b1ab3

6 years agoAdd case insensitivity feature to GenericFunction.
Adrien Berchet [Mon, 15 Apr 2019 17:59:18 +0000 (13:59 -0400)] 
Add case insensitivity feature to GenericFunction.

The :class:`.GenericFunction` namespace is being migrated so that function
names are looked up in a case-insensitive manner, as SQL  functions do not
collide on case sensitive differences nor is this something which would
occur with user-defined functions or stored procedures.   Lookups for
functions declared with :class:`.GenericFunction` now use a case
insensitive scheme,  however a deprecation case is supported which allows
two or more :class:`.GenericFunction` objects with the same name of
different cases to exist, which will cause case sensitive lookups to occur
for that particular name, while emitting a warning at function registration
time.  Thanks to Adrien Berchet for a lot of work on this complicated
feature.

Fixes: #4569
Closes: #4570
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4570
Pull-request-sha: 37d4f3322b6bace88c99b959cb1916dbbc57610e

Change-Id: Ief07c6eb55bf398f6aad85b60ef13ee6d1173109

6 years agoMerge "Add _cache_key implementation."
mike bayer [Mon, 29 Apr 2019 18:53:43 +0000 (18:53 +0000)] 
Merge "Add _cache_key implementation."

6 years agoMerge "Reimplement .compare() in terms of a visitor"
mike bayer [Mon, 29 Apr 2019 18:52:03 +0000 (18:52 +0000)] 
Merge "Reimplement .compare() in terms of a visitor"

6 years agoAdd _cache_key implementation.
Mike Bayer [Wed, 17 Apr 2019 17:37:39 +0000 (13:37 -0400)] 
Add _cache_key implementation.

This leverages the work started in #4336 to allow ClauseElement
structures to be cachable based on structure, not just identity.

Change-Id: Ia99ddeb5353496dd7d61243245685f02b98d8100

6 years agoReimplement .compare() in terms of a visitor
Mike Bayer [Wed, 17 Apr 2019 17:37:39 +0000 (13:37 -0400)] 
Reimplement .compare() in terms of a visitor

Reworked the :meth:`.ClauseElement.compare` methods in terms of a new
visitor-based approach, and additionally added test coverage ensuring that
all :class:`.ClauseElement` subclasses can be accurately compared
against each other in terms of structure.   Structural comparison
capability is used to a small degree within the ORM currently, however
it also may form the basis for new caching features.

Fixes: #4336
Change-Id: I581b667d8e1642a6c27165cc9f4aded1c66effc6

6 years agoMerge "Warn on merge of already-pending object"
mike bayer [Sun, 28 Apr 2019 18:43:37 +0000 (18:43 +0000)] 
Merge "Warn on merge of already-pending object"

6 years agoWarn on merge of already-pending object
Mike Bayer [Sun, 28 Apr 2019 16:40:31 +0000 (12:40 -0400)] 
Warn on merge of already-pending object

A warning is now emitted for the case where a transient object is being
merged into the session with :meth:`.Session.merge` when that object is
already transient in the :class:`.Session`.   This warns for the case where
the object would normally be double-inserted.

Fixes: #4647
Change-Id: Ie5223a59a2856664bf283017e962caf8c4230536

6 years agoMerge "Add additional parsing to extract the "MariaDB" keyword from version string"
mike bayer [Sun, 28 Apr 2019 03:16:51 +0000 (03:16 +0000)] 
Merge "Add additional parsing to extract the "MariaDB" keyword from version string"

6 years ago- continued 1.4 setup, somehow the commit didn't work
Mike Bayer [Sat, 27 Apr 2019 21:19:31 +0000 (17:19 -0400)] 
- continued 1.4 setup, somehow the commit didn't work

Fixes: #4631
Change-Id: I400e388a704aa6ee7722a89687a033083ce22550

6 years ago- initial 1.4 setup
Mike Bayer [Sat, 27 Apr 2019 21:18:08 +0000 (17:18 -0400)] 
- initial 1.4 setup

Fixes: #4631
Change-Id: I7ff2ae98be6db571c9dacc75e912488b8a9bbdbb

6 years agofix RST link format
Mike Bayer [Thu, 25 Apr 2019 22:26:57 +0000 (17:26 -0500)] 
fix RST link format

Change-Id: I52122759a92d2fa4bab93ac75c21a77f79eace5a

6 years agoremote_attr and local_attr refer to class bound attributes, not
Mike Bayer [Thu, 25 Apr 2019 22:23:12 +0000 (17:23 -0500)] 
remote_attr and local_attr refer to class bound attributes, not
MapperProperty

Change-Id: If5fee69474f295e8c4bef891f5360f6b54080bbf

6 years ago- formatting typo
Mike Bayer [Thu, 25 Apr 2019 22:16:43 +0000 (17:16 -0500)] 
- formatting typo

Change-Id: Ia34c2f9a6c3db83bbe0f0a06f82aa04c603cb521

6 years agoAdd ORM documentation for as_comparison()
Mike Bayer [Thu, 25 Apr 2019 15:46:31 +0000 (10:46 -0500)] 
Add ORM documentation for as_comparison()

In #3831 we added the ability for SQL functions to be used in
primaryjoin conditions as the source of comparison, however we
didn't add documentation from the main relationship docs so
nobody could find it unless they read the migration notes.
Since the two use cases that have come up for this are
materialized path with string functions, and geometry functions,
add the example based on the use case requested in
https://github.com/geoalchemy/geoalchemy2/issues/220#issuecomment-486709055

This example hasn't been tested yet and is subject to
revision.

Change-Id: I410d8ffade3f17cf616fc5056f27d7d32092207b

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

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

Fixes: #4624
Change-Id: Iba4b56535855629a974b1e24e012b07383d24199

6 years agoMerge "negate True/False separately from other elements"
mike bayer [Tue, 23 Apr 2019 22:37:19 +0000 (22:37 +0000)] 
Merge "negate True/False separately from other elements"

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

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

6 years agoRemove sqla_nose.py from MANIFEST.in
Mike Bayer [Tue, 23 Apr 2019 19:47:40 +0000 (14:47 -0500)] 
Remove sqla_nose.py from MANIFEST.in

Removed errant "sqla_nose.py" symbol from MANIFEST.in which created an
undesirable warning message.

Fixes: #4625
Change-Id: I3784e82847d2ebfdd967dd9e2ab628d0ae5f415f

6 years ago- black -l79 update
Mike Bayer [Sun, 21 Apr 2019 01:23:55 +0000 (21:23 -0400)] 
- black -l79 update

Change-Id: I8e6211af91a322b3c212f16e77a0c0f6e9a5e019

6 years agonegate True/False separately from other elements
Mike Bayer [Thu, 18 Apr 2019 13:40:03 +0000 (09:40 -0400)] 
negate True/False separately from other elements

Fixed issue where double negation of a boolean column wouldn't reset
the "NOT" operator.

Fixes: #4618
Change-Id: Ica280a0d6b5b0870aa2d05c4d059a1e559e6b12a
(cherry picked from commit 18f25f50353d9736e6638266585b2cb3ef7b0ea4)

6 years agoUse "parent object" instead of "primary object" 4619/head
vpsx [Wed, 17 Apr 2019 23:48:40 +0000 (18:48 -0500)] 
Use "parent object" instead of "primary object"

6 years agocherry-pick changelog update for 1.2.20
Mike Bayer [Mon, 15 Apr 2019 16:29:31 +0000 (12:29 -0400)] 
cherry-pick changelog update for 1.2.20