Commit Graph

5612 Commits

Author SHA1 Message Date
Mike Bayer b37f007732 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 🎫`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.

Change-Id: I87d0ac09f695dc285bd4bbe0a547f1d5ce23e068
Fixes: #4185
(cherry picked from commit 93881f7873048403b62cc3e179354712ba8e9282)
2018-02-20 16:42:24 -05:00
Mike Bayer f1125b79cc 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.

Change-Id: I31b1d22408e358962577435f0c4cb9a456ba0872
Fixes: #4187
(cherry picked from commit 8607ae51fc)
2018-02-12 17:06:03 -05:00
Mike Bayer cc6cef5184 Search through mapper superclass hierarchy for owner
Fixed regression caused by fix for issue 🎫`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.

Change-Id: I611b590df2babe077ce6c19bea89e84251d1a7f4
Fixes: #4185
(cherry picked from commit 650b9eddae)
2018-02-09 16:31:24 -05:00
Mike Bayer 6c6f865541 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.

Change-Id: Iabd9f3a63a1d0207d0de0054a6ced3560818cf9c
Fixes: #4184
(cherry picked from commit ab1f524c355c0bbac68485a60cb99e7a9d0f944a)
2018-02-08 14:56:19 -05:00
Aubrey Stark-Toller 8e112ad2cc ValuesBase.values inconsistency fix
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.

Change-Id: I9d3b40b5950df8f5bfdc8b1d22f9c3afb277f17f
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/412
Fixes: #4162
(cherry picked from commit ab2165e6d6)
2018-01-12 11:30:05 -05:00
Mike Bayer a71e1ea211 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.

Change-Id: I57e2888902015d67ee11857e44382818f1d2f8bc
Fixes: #4151
(cherry picked from commit 5811276bb7)
2018-01-04 14:11:00 -05:00
Jacob Hayes fe84543cc7 Add TRUNCATE to postgres autocommit regexp
Extends AUTOCOMMIT_REGEXP for the postgres dialect to include `TRUNCATE`.

Change-Id: I315e03674b89bb89aae669b8655481e4d890491e
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/407
(cherry picked from commit 756d578287)
2017-12-18 11:33:37 -05:00
Mike Bayer 0be865d7bd 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.

Change-Id: If8c57615860883837f6cf72661e46180a77778c1
(cherry picked from commit 14bb6eae364f41b6acbce782ebf5f984b9364af9)
2017-12-04 17:42:04 -05:00
Mike Bayer a616c0566d 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

Change-Id: Iaf54ac18949cc6a54f50678125f010b4f12c5673
Fixes: #4136
(cherry picked from commit 4f054550b7)
2017-11-13 09:24:02 -05:00
Nicolas CANIART d91edf2511 Accommodate tuples for ColumnDefault.__repr__
Fixed bug where ``__repr__`` of :class:`.ColumnDefault` would fail
if the argument were a tuple.  Pull request courtesy Nicolas Caniart.

Change-Id: I08aa2448ef91054c43d6068ac54cedbdf7a83d64
Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/1
Fixes: #4126
(cherry picked from commit 5acc9b149a)
2017-10-31 11:40:00 -04:00
Mike Bayer e06bf169e5 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.

Change-Id: I407b07a3a3e2c374da19fc86ed44b987d595dcfa
Fixes: #4124
(cherry picked from commit fd4289c582)
2017-10-28 13:30:18 -04:00
Mike Bayer e111940156 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.

Change-Id: I9161bab67766bb75d73ca54d712ad1cad6de40dc
Fixes: #4116
(cherry picked from commit f14a58dea4)
2017-10-23 20:36:18 -04:00
Mike Bayer b6479c33da Get MariaDB normalized version relative to "MariaDB" token
Fixed regression from 1.2.0b3 where "MariaDB" version comparison can
fail for some particular MariaDB version strings under Python 3.

For 1.1, this was merged as part of #4097

Change-Id: Iedf49f40c1614ccedf63e0fa26719dd704da104d
Fixes: #4115
(cherry picked from commit 57f7788ec2)
2017-10-23 18:51:53 -04:00
mike bayer 0071789de1 Merge "Don't include SelectBase when searching for surface column elements" into rel_1_1 2017-10-10 14:12:18 -04:00
Mike Bayer c5785037d8 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.

Change-Id: Ibe5f6275d90e4868e6ef8a733de05acd44c05d78
Fixes: #4107
(cherry picked from commit 4bb8397ae3)
2017-10-06 11:29:51 -04:00
Mike Bayer 71b6a13755 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.

Change-Id: I38df21f1392af1843e10119682fa0635d346e2a8
Fixes: #4103
(cherry picked from commit 1281e6e6c4)
2017-10-05 11:30:01 -04:00
Mike Bayer eb859dcd2c 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.

Change-Id: I9367a7978cadc59066e89fc4917d7eb6c78dedee
Fixes: #4078
(cherry picked from commit 8ba8dd23b7)
2017-10-03 14:42:49 -04:00
Mike Bayer 2a8167f241 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

Also cherry-picks f846a789b7 from master
to repair 'postgres'-deprecation warning test for multiple
calls within a single process

Change-Id: I5f8aee0f5ed423461be5a9060c812eb0acdc7df5
(cherry picked from commit 67ee56be69)
2017-10-03 13:01:58 -04:00
Mike Bayer 8948d961b2 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.

Change-Id: I073a72cb47dc4f8c5683000d708768523759332f
Fixes: #4099
(cherry picked from commit 68b52c48b7)
2017-09-29 18:45:36 -04:00
Mike Bayer 917a971764 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 🎫`4097`).  Reflection
now takes these CHECK constraints into account when they are present in
the ``SHOW CREATE TABLE`` output.

Fixes: #4098

Change-Id: I8666d61814e8145ca12cbecad94019b44af868e3
(cherry picked from commit 29b752f8b2)
2017-09-29 13:21:16 -04:00
Mike Bayer 865d915d0e Remove unused .cascading from unit test for __table_cls__ feature
Two independent gerrits for 04bbad660b
and ec1700ba29 produce a failure
when merged due to new warning.
will merge into rel_1_1 as well for completeness even though
warning is not there.

Change-Id: I1bd494d205107d8b2a30d475a22c61a59b70985b
(cherry picked from commit 21ff71b0eb)
2017-09-28 13:07:45 -04:00
Mike Bayer af70c3022f Add full list of pyodbc error codes for MSSQL
Moved the SQL server error codes out of connnectors/pyodbc.py
and into mssql/pyodbc.py.  Added complete list
of odbc-related disconnect codes.

Change-Id: Icd84a920dbfa1f188847f859654ff6f7a48170f1
Fixes: #4095
(cherry picked from commit 6a38697261)
2017-09-28 09:41:40 -04:00
mike bayer 171e6efd35 Merge "Support method form of any_(), all_()" into rel_1_1 2017-09-27 18:10:18 -04:00
Mike Bayer 3a8a8b9bc5 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.

Change-Id: I3e56b463e9fd146a077b9970624f50cba27f9811
Fixes: #4093
(cherry picked from commit 944c662d8a)
2017-09-27 15:50:07 -04:00
mike bayer 0c608ebec6 Merge "Accomodate for multidimensional array in rewriting for COLLATE" into rel_1_1 2017-09-27 15:48:02 -04:00
Mike Bayer f66a3dfc9c 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 🎫`4006` failed to accommodate
for a multidimentional array.

Change-Id: If3e438f8ce94ebae2196671c88a4914f3b743e60
Fixes: #4006
(cherry picked from commit 6652f72352)
2017-09-27 09:49:11 -04:00
Mike Bayer d1ca3a8d46 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.

Change-Id: I87be5bcb72205cab89871fa586663bf147450995
Fixes: #4082
(cherry picked from commit 04bbad660b)
2017-09-26 11:39:08 -04:00
Mike Bayer a14e5c42ca 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.

Change-Id: Ie20972a05e194290bc9d92819750845872949ecc
Fixes: #4074
(cherry picked from commit 7051653610)
2017-09-12 12:58:55 -04:00
mike bayer 04958bb7d7 Merge "Check for non-mapped property in synonym" into rel_1_1 2017-09-05 09:43:52 -04:00
Mike Bayer 8ec1369eb3 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.

Change-Id: If2ce38c429a69951df4c94b71b74edbd59d775e3
Fixes: #4067
(cherry picked from commit 130f31ca79)
2017-09-04 18:56:38 -04:00
Mike Bayer a3965ea5ff 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.

Change-Id: I9f6ae3fe5b078f26146af82b15d16f3a549a9032
Fixes: #4068
(cherry picked from commit 37c5ed2ed9)
2017-09-04 16:22:51 -04:00
Mike Bayer 5243341ed8 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.

Change-Id: I0a6e00043be0b2979cda33740e1be3b430ecf8c7
Fixes: #4056
2017-08-31 16:23:42 -04:00
Mike Bayer fb55270835 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".

Change-Id: I7d3a6c641151bb49219104968d18dac2266f3db8
Fixes: #4053
(cherry picked from commit 3a5bbe4cbe)
2017-08-25 09:43:38 -04:00
Mike Bayer 3b5840f16a 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.

Change-Id: I0f48766f12f7299f4626ff41a00bf1f5bfca5f3b
Fixes: #4048
(cherry picked from commit eee9dfd4514801f0c67f71632fc722731171479b)
2017-08-24 09:41:12 -04:00
Mike Bayer 186da1c122 - remove 3.4's
Change-Id: Ib2089e812d16d7792d7b3d5bfe103abe19221a00
2017-08-23 17:33:42 -04:00
Mike Bayer 53175850bf First level repair for cx_Oracle 6.0 test regressions
Fixed more regressions caused by cx_Oracle 6.0; at the moment, the only
behavioral change for users is disconnect detection now detects for
cx_Oracle.DatabaseError in addition to cx_Oracle.InterfaceError, as
this behavior seems to have changed.   Other issues regarding numeric
precision and uncloseable connections are pending with the upstream
cx_Oracle issue tracker.

Change-Id: Id61f1e33b21c155a598396340dfdecd28ff4066b
Fixes: #4045
(cherry picked from commit 03255a5a0f)
2017-08-22 14:44:39 -04:00
Mike Bayer d6018ef3a2 - ensure identifier re-use doesn't make this break
Change-Id: I9fe6c42c097d31b50a479250d39a3cd8ebcbffaf
(cherry picked from commit 41549de960)
2017-08-22 13:56:06 -04:00
Mike Bayer 42f11fe80b - this test doesn't work in strict mode, not that important
Change-Id: I3ed361af5c9f0c7acbeb8b534966828949f4958b
(cherry picked from commit 63d47c051d)
2017-08-21 12:10:41 -04:00
Mike Bayer cc3d1e057d - a few mysql fixes, more to come
Change-Id: Icdcc8ed03374251b8d3815ae58e2726ea27c14b4
(cherry picked from commit 64032a35ae)
2017-08-21 12:10:28 -04:00
Mike Bayer 34f468af19 - dont run sql mode config tests if we aren't on mysql
Change-Id: Ia5a491ec505afed1511a17a167cd1f7d8371acd4
(cherry picked from commit ed197d4c30)
2017-08-19 18:21:05 -04:00
Mike Bayer 9034fc2b48 - fix one test for STRICT, which may be turned on by default
in mariadb 10.2.   more mariadb fixes coming

Change-Id: I6e3a94ae7340772663677b1082506adbb2d84a38
(cherry picked from commit 54cdda032e)
2017-08-04 11:29:06 -04:00
mike bayer 0753f3940c Merge "Check for column object in eval_none, not propkey" into rel_1_1 2017-07-19 16:22:10 -04:00
Mike Bayer db3c58f9ee Check for column object in eval_none, not propkey
Fixed bug involving JSON NULL evaluation logic added in 1.1 as part
of 🎫`3514` where the logic would not accommodate ORM
mapped attributes named differently from the :class:`.Column`
that was mapped.

Change-Id: I1848afcfb63ad7f074f315d8d3097666069b42be
Fixes: #4031
(cherry picked from commit e2ede596adff3ce584f8c43ba024cafabc509a06)
2017-07-18 15:04:55 -04:00
Mike Bayer 23565166f1 Check for non-entity when inspecting for subqueryload
Fixed issue where adding additional non-entity columns to
a query that includes an entity with subqueryload relationships
would fail, due to an inspection added in 1.1.11 as a result of
🎫`4011`.

Change-Id: I8ef082be649125bdc07b428cb9b0a77a65d73671
Fixes: #4033
(cherry picked from commit 3d41ea09a8)
2017-07-18 15:04:10 -04:00
David Moore acabfc72ad Add support for CACHE and ORDER to sequences
Added new keywords :paramref:`.Sequence.cache` and
:paramref:`.Sequence.order` to :class:`.Sequence`, to allow rendering
of the CACHE parameter understood by Oracle and PostgreSQL, and the
ORDER parameter understood by Oracle.  Pull request
courtesy David Moore.

Change-Id: I082c3f8ef56ef89dbaad5da9d5695be5313b0614
Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/96
(cherry picked from commit faa6609dac)
2017-07-05 16:23:13 -04:00
mike bayer 0b9aa75c00 Merge "Handle SHOW VARIABLES returning no row" into rel_1_1 2017-06-16 18:39:59 -04:00
Mike Bayer 94a0ed697a Handle SHOW VARIABLES returning no row
MySQL 5.7 has introduced permission limiting for the "SHOW VARIABLES"
command; the MySQL dialect will now handle when SHOW returns no
row, in particular for the initial fetch of SQL_MODE, and will
emit a warning that user permissions should be modified to allow the
row to be present.

Change-Id: I98e7a69230da397b17eae07b7e9d024fa7aeeb26
Fixes: #4007
(cherry picked from commit 5650a0c306)
2017-06-16 15:54:47 -04:00
Mike Bayer 7a47c32bb0 Repair WithinGroup.get_children()
Fixed AttributeError which would occur in :class:`.WithinGroup`
construct during an iteration of the structure.

Change-Id: I563882d93c8c32292463a605b636aa60c77e9406
Fixes: #4012
(cherry picked from commit 3a314fcea8)
2017-06-16 13:03:58 -04:00
Mike Bayer d2131156de Set complete FROM list for subquery eagerload's orig query
Instead of checking that the "orig_entity" we receive applies
as a correct FROM element for the subquery we're building,
set the FROM clause of the query to exactly what it already
is based on column_descriptions (assuming there is no FROM
list already), thereby ensuring that the FROM list will remain
intact, regardless of what orig_entity turns out to be and
what the target_cols ultimately refer towards.

Fixed issue with subquery eagerloading which continues on from
the series of issues fixed in 🎫`2699`, 🎫`3106`,
🎫`3893` involving that the "subquery" contains the correct
FROM clause when beginning from a joined inheritance subclass
and then subquery eager loading onto a relationship from
the base class, while the query also includes criteria against
the subclass. The fix in the previous tickets did not accommodate
for additional subqueryload operations loading more deeply from
the first level, so the fix has been further generalized.

Change-Id: Ic909590814f71e577d8266b1dbc4c393dc48e019
Fixes: #4011
(cherry picked from commit 6d2a03c1ec21cc428c91476c170ad7dbe219926c)
2017-06-15 18:52:26 -04:00
Mike Bayer fa62a0af27 - fix the col length missing just like in master...
Change-Id: I172999198217b9a09f136664f5a7e38e7e099df6
2017-06-15 18:47:33 -04:00