Mike Bayer [Mon, 5 Mar 2018 16:33:30 +0000 (11:33 -0500)]
Only replace first occurrence for COLLATE/ARRAY syntax
Fixed bug in Postgresql COLLATE / ARRAY adjustment first introduced
in :ticket:`4006` where new behaviors in Python 3.7 regular expressions
caused the fix to fail.
Mike Bayer [Fri, 2 Mar 2018 20:08:08 +0000 (15:08 -0500)]
Get MySQL version info from @@version
MySQL dialects now query the server version using ``SELECT @@version``
explicitly to the server to ensure we are getting the correct version
information back. Proxy servers like MaxScale interfere with the value
that is passed to the DBAPI's connection.server_version value so this
is no longer reliable.
Mike Bayer [Tue, 20 Feb 2018 17:15:57 +0000 (12:15 -0500)]
Default to using current mapped class as owner if none found
Repaired regression caused in 1.2.3 and 1.1.16 regarding association proxy
objects, revising the approach to :ticket:`4185` when calculating the
"owning class" of an association proxy to default to choosing the current
class if the proxy object is not directly associated with a mapped class,
such as a mixin.
Mike Bayer [Mon, 19 Feb 2018 23:13:24 +0000 (18:13 -0500)]
Rewrite the "deleting from collections" section
This section documents an aspect of the ORM that is
more generalized than just collections as well as more general
than just using session.delete(), even though session.delete()
with collections is the most common use case. Try to expand
out the scope here to explain the situation from the perspective
of any kind of relationship, include example with delete cascade
with many-to-one as well.
André Cruz [Thu, 15 Feb 2018 16:09:47 +0000 (11:09 -0500)]
Add ssl "operation timed out" message for psycopg2
Added "SSL SYSCALL error: Operation timed out" to the list
of messages that trigger a "disconnect" scenario for the
psycopg2 driver. Pull request courtesy André Cruz.
Change-Id: Ie1a8fc97e74b6906ccacf53dad70fed973c42b7f
Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/3
(cherry picked from commit 2f03ec08b5a1c633133c0a38d82b05eb83708f69)
Mike Bayer [Mon, 12 Feb 2018 21:45:39 +0000 (16:45 -0500)]
Add dependency for parent_pre post updates to parent deletes
Fixed issue in post_update feature where an UPDATE is emitted
when the parent object has been deleted but the dependent object
is not. This issue has existed for a long time however
since 1.2 now asserts rows matched for post_update, this
was raising an error.
Mike Bayer [Fri, 9 Feb 2018 21:12:31 +0000 (16:12 -0500)]
Search through mapper superclass hierarchy for owner
Fixed regression caused by fix for issue :ticket:`4116` affecting versions
1.2.2 as well as 1.1.15, which had the effect of mis-calculation of the
"owning class" of an :class:`.AssociationProxy` as the ``NoneType`` class
in some declarative mixin/inheritance situations as well as if the
association proxy were accessed off of an un-mapped class. The "figure out
the owner" logic has been replaced by an in-depth routine that searches
through the complete mapper hierarchy assigned to the class or subclass to
determine the correct (we hope) match; will not assign the owner if no
match is found. An exception is now raised if the proxy is used
against an un-mapped instance.
Mike Bayer [Thu, 8 Feb 2018 19:52:29 +0000 (14:52 -0500)]
Ensure weakref finalize_fairy operates upon the current connection
Fixed a fairly serious connection pool bug where a connection that is
acquired after being refreshed as a result of a user-defined
:class:`.DisconnectionError` or due to the 1.2-released "pre_ping" feature
would not be correctly reset if the connection were returned to the pool by
weakref cleanup (e.g. the front-facing object is garbage collected); the
weakref would still refer to the previously invalidated DBAPI connection
which would have the reset operation erroneously called upon it instead.
This would lead to stack traces in the logs and a connection being checked
into the pool without being reset, which can cause locking issues.
Mike Bayer [Thu, 25 Jan 2018 21:11:29 +0000 (16:11 -0500)]
Add a new FAQ section explaining how to ensure parenthesis
with op().
Not sure if this can be further improved at some point, such
as if a BinaryExpression automatically applied self_group()
when op() is called, however for the moment op() behaves consistently
as with all other operators without any ad-hoc effects.
Mike Bayer [Wed, 24 Jan 2018 23:03:04 +0000 (18:03 -0500)]
Rework synonym, synonym_for documentation
The map_column example was incorrect, and overall the purpose
of this parameter as well as that of synonym_for was not explained;
examples added along with more encouragement to use hybrids.
Fixed bug in :meth:`.Insert.values` where using the "multi-values"
format in combination with :class:`.Column` objects as keys rather
than strings would fail. Pull request courtesy Aubrey Stark-Toller.
Mike Bayer [Thu, 4 Jan 2018 19:09:32 +0000 (14:09 -0500)]
Check for object was expunged before restoring after pk switch + rollback
Fixed bug where an object that is expunged during a rollback of
a nested or subtransaction which also had its primary key mutated
would not be correctly removed from the session, causing subsequent
issues in using the session.
Mike Bayer [Mon, 4 Dec 2017 21:40:20 +0000 (16:40 -0500)]
Add tests for ARRAY propagate events re. MutableList
Issue #4141 appears in version 1.2, however we are adding the
MutableList test for it to 1.1 as well. The metadata test
does not apply as in 1.1 ARRAY is not a SchemaEventTarget.
Mike Bayer [Mon, 13 Nov 2017 14:21:48 +0000 (09:21 -0500)]
Propagate kwargs for mysql concat, match
Fixed bug where the MySQL "concat" and "match" operators failed to
propagate kwargs to the left and right expressions, causing compiler
options such as "literal_binds" to fail.
Also adds non-interpreted **kw for visit_create_index, visit_typeclause
Mike Bayer [Sat, 28 Oct 2017 17:28:58 +0000 (13:28 -0400)]
Filter attributes we don't map during a load_scalar_attributes
Fixed bug where a descriptor that is elsewhere a mapped column
or relationship within a hierarchy based on :class:`.AbstractConcreteBase`
would be referred towards during a refresh operation, causing an error
as the attribute is not mapped as a mapper property.
A similar issue can arise for other attributes like the "type" column
added by :class:`.AbstractConcreteBase` if the class fails to include
"concrete=True" in its mapper, however the check here should also
prevent that scenario from causing a problem.
Mike Bayer [Fri, 20 Oct 2017 18:34:16 +0000 (14:34 -0400)]
Resolve AliasedClass when determining owning class of association proxy
Fixed bug where the association proxy would inadvertently link itself
to an :class:`.AliasedClass` object if it were called first with
the :class:`.AliasedClass` as a parent, causing errors upon subsequent
usage.
Daniel Thorell [Fri, 20 Oct 2017 16:59:55 +0000 (12:59 -0400)]
Remove deprecation warnings mysql5 7 20
MySQL 5.7.20 now warns for use of the @tx_isolation variable; a version
check is now performed and uses @transaction_isolation instead
to prevent this warning.
For 1.1, also backport our_warn() test fixture fix from 9f0fb6c601 1.2 branch.
(cherry picked from commit 41cfe44b5e5806b3d3b13949e41dbb347bfa29e1)
Co-authored by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #4120
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/391
Change-Id: I4d2e04df760c5351a71dde8b32145cdc69fa6115
Mike Bayer [Fri, 6 Oct 2017 15:14:29 +0000 (11:14 -0400)]
Fix array_agg to accommodate ARRAY arguments
Fixed bug in :func:`.array_agg` function where passing an argument
that is already of type :class:`.ARRAY`, such as a Postgresql
:obj:`.postgresql.array` construct, would produce a ``ValueError``, due
to the function attempting to nest the arrays.
Mike Bayer [Thu, 5 Oct 2017 15:25:10 +0000 (11:25 -0400)]
Don't include SelectBase when searching for surface column elements
Fixed bug where correlated select used against single-table inheritance
entity would fail to render correctly in the outer query, due to adjustment
for single inheritance discriminator criteria inappropriately re-applying
the criteria to the outer query.
Mike Bayer [Tue, 3 Oct 2017 00:50:56 +0000 (20:50 -0400)]
Improve check for overlapping FK targets on sibling classes
Fixed bug where ORM relationship would warn against conflicting sync
targets (e.g. two relationships would both write to the same column) for
sibling classes in an inheritance hierarchy, where the two relationships
would never actually conflict during writes.
Mike Bayer [Mon, 2 Oct 2017 15:50:05 +0000 (11:50 -0400)]
Support pg10
One test appears to use some awkward calling style
with the current_date function that isn't working in pg10
anymore, this looks like an extremely
old test that can be removed
Mike Bayer [Thu, 28 Sep 2017 20:47:28 +0000 (16:47 -0400)]
Take schema name into account when querying sqlite_master
Fixed bug where SQLite CHECK constraint reflection would fail
if the referenced table were in a remote schema, e.g. on SQLite a
remote database referred to by ATTACH.
Also add suite support for general CHECK constraint reflection.
Mike Bayer [Sat, 19 Aug 2017 22:39:08 +0000 (18:39 -0400)]
Support mariadb 10.2
Fixed issue where CURRENT_TIMESTAMP would not reflect correctly
in the MariaDB 10.2 series due to a syntax change, where the function
is now represented as ``current_timestamp()``.
Fixes: #4096
MariaDB 10.2 now supports CHECK constraints (warning: use version 10.2.9
or greater due to upstream issues noted in :ticket:`4097`). Reflection
now takes these CHECK constraints into account when they are present in
the ``SHOW CREATE TABLE`` output.
Mike Bayer [Thu, 28 Sep 2017 23:31:13 +0000 (19:31 -0400)]
Repair incorrectly merged mariadb logic
The changeset in c88d4d0 takes advantage of a
mariadb function that got randomly committed as part
of the SQL server fixup in 2efd89d02941ab4267d6e2842963, not
part of rel_1_1. The change here was not reviewed or tested
in gerrit and breaks the main branch.
Mike Bayer [Thu, 28 Sep 2017 16:31:54 +0000 (12:31 -0400)]
Warn for mariadb 10.2 < 9
There's a few CHECK constraint issues we managed
to get resolved as of MariaDB 10.2.8 then 10.2.9. They
are pretty severe so warn users for these particular mariadb
versions.
Mike Bayer [Wed, 27 Sep 2017 14:14:57 +0000 (10:14 -0400)]
Support method form of any_(), all_()
Fixed bug where the recently added :meth:`.ColumnOperators.any_`
and :meth:`.ColumnOperators.all_` methods didn't work when called
as methods, as opposed to using the standalone functions
:func:`~.expression.any_` and :func:`~.expression.all_`. Also
added documentation examples for these relatively unintuitive
SQL operators.
Mike Bayer [Wed, 27 Sep 2017 13:48:17 +0000 (09:48 -0400)]
Accomodate for multidimensional array in rewriting for COLLATE
Made further fixes to the :class:`.ARRAY` class in conjunction with
COLLATE, as the fix made in :ticket:`4006` failed to accommodate
for a multidimentional array.
Mike Bayer [Tue, 26 Sep 2017 00:00:20 +0000 (20:00 -0400)]
Document and test __table_cls__
A use case has been identified for __table_cls__, which was
added in 1.0 just for the purpose of test fixtures. Add this to
public API and ensure the target use case (conditional table generation)
stays supported.
Mike Bayer [Tue, 12 Sep 2017 16:57:40 +0000 (12:57 -0400)]
use the stack to get the insert statement in on conflict
Fixed bug in Postgresql :meth:`.postgresql.dml.Insert.on_conflict_do_update`
which would prevent the insert statement from being used as a CTE,
e.g. via :meth:`.Insert.cte`, within another statement.
Mike Bayer [Mon, 4 Sep 2017 16:11:19 +0000 (12:11 -0400)]
Guard against KeyError in session.merge after check for identity
Fixed bug in :meth:`.Session.merge` following along similar lines as that
of :ticket:`4030`, where an internal check for a target object in
the identity map could lead to an error if it were to be garbage collected
immediately before the merge routine actually retrieves the object.
Mike Bayer [Mon, 4 Sep 2017 20:21:14 +0000 (16:21 -0400)]
Check for non-mapped property in synonym
An :class:`.InvalidRequestError` is raised when a :func:`.synonym`
is used against an attribute that is not against a :class:`.MapperProperty`,
such as an association proxy. Previously, a recursion overflow would
occur trying to locate non-existent attributes.
Mike Bayer [Mon, 4 Sep 2017 19:53:34 +0000 (15:53 -0400)]
Always check that discarded state is the expected one
Fixed race condition in ORM identity map which would cause objects
to be inappropriately removed during a load operation, causing
duplicate object identities to occur, particularly under joined eager
loading which involves deduplication of objects. The issue is specific
to garbage collection of weak references and is observed only under the
Pypy interpreter.
Mike Bayer [Fri, 1 Sep 2017 16:31:38 +0000 (12:31 -0400)]
Add InternalError for mysqlclient disconnect
mysqlclient as of 1.3.11 changed the exception
class for a particular disconnect situation from
InterfaceError to InternalError; the disconnection
detection logic now accommodates this.
Mike Bayer [Thu, 31 Aug 2017 19:46:53 +0000 (15:46 -0400)]
Consider merge key with (None, ) as non-persistent
Fixed bug in :meth:`.Session.merge` where objects in a collection that had
the primary key attribute set to ``None`` for a key that is typically
autoincrementing would be considered to be a database-persisted key for
part of the internal deduplication process, causing only one object to
actually be inserted in the database.
Mike Bayer [Thu, 31 Aug 2017 20:22:52 +0000 (16:22 -0400)]
- pin on cx_Oracle 6.0.1 for the moment while we wait for
either https://github.com/oracle/python-cx_Oracle/issues/75
to be fixed or we can merge a workaround
Mike Bayer [Fri, 25 Aug 2017 13:41:18 +0000 (09:41 -0400)]
Allow for multiple FOLLOWING/PRECEDING in a window range
Altered the range specification for window functions to allow
for two of the same PRECEDING or FOLLOWING keywords in a range
by allowing for the left side of the range to be positive
and for the right to be negative, e.g. (1, 3) is
"1 FOLLOWING AND 3 FOLLOWING".
Mike Bayer [Wed, 23 Aug 2017 20:33:10 +0000 (16:33 -0400)]
Ensure col is not None when retrieving quick populators
Fixed bug where an :func:`.undefer_group` option would not be recognized
if it extended from a relationship that was loading using joined eager
loading.
In particular we need to double check the column both in terms of
the given "adapter" as well as without applying the "adapter"
when searching for the column in the result.
As we now avoid redoing the row processor step we also
improve on callcounts in joined eager loading.
Mike Bayer [Mon, 14 Aug 2017 13:32:08 +0000 (09:32 -0400)]
Restore original test names
The change in de1f8f8345ecd6af0ec1177703465e9471cfe862
modified how test classes are named, breaking logic that
extracts the class name for the profiling suite.
Add a new variable _sa_orig_cls_name if we've modified the
name so that the profiling logic doesn't need to guess
the original class name.
Mike Bayer [Fri, 4 Aug 2017 19:43:16 +0000 (15:43 -0400)]
Allow multiple versions of single backend
Improve screen output to illustrate which server version is
running for a particular database config, and additionally
allow full overriding for the backend-specific targets in
tox.ini via environment variables, so that CI can inject
multiple server urls for a particular database such as MySQL/MariaDB.