]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
6 years agoDon't call rollback on DBAPI connection that's "closed"
Mike Bayer [Sun, 14 Oct 2018 19:55:46 +0000 (15:55 -0400)] 
Don't call rollback on DBAPI connection that's "closed"

Use the existence of ConnectionRecord.connection to estimate
that this connection is likely closed, and if so, don't
try to call "rollback" on it.  This rollback is normally harmless
but is causing segfaults in mysqlclient due to
https://github.com/PyMySQL/mysqlclient-python/issues/270.

Change-Id: I1d7c5f5a520527d8268b6334795c2051f7ceeea6

6 years ago- get the "now" date for this test in terms of the database to accommodate
Mike Bayer [Sat, 13 Oct 2018 03:02:12 +0000 (23:02 -0400)] 
- get the "now" date for this test in terms of the database to accommodate
for local timezone doesn't match that of the DB

Change-Id: I0899d9294e8a2bd8f7f2c3e66cf396e2e8bd4bcc

6 years agoselectinload omit join
Jayson Reis [Mon, 1 Oct 2018 16:58:46 +0000 (12:58 -0400)] 
selectinload omit join

The "selectin" loader strategy now omits the JOIN in the case of a
simple one-to-many load, where it instead relies upon the foreign key
columns of the related table in order to match up to primary keys in
the parent table.   This optimization can be disabled by setting
the :paramref:`.relationship.omit_join` flag to False.
Many thanks to Jayson Reis for the efforts on this.

As part of this change, horizontal shard no longer relies upon
the _mapper_zero() method to get the query-bound mapper, instead
using the more generalized _bind_mapper() (which will use mapper_zero
if no explicit FROM is present).  A short check for the particular
recursive condition is added to BundleEntity and it no longer assigns
itself as the "namespace" to its ColumnEntity objects which creates
a reference cycle.

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Fixes: #4340
Change-Id: I649587e1c07b684ecd63f7d10054cd165891baf4
Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/7

6 years agoMerge "Route bulk update/delete exec through new Query._execute_crud method"
mike bayer [Thu, 4 Oct 2018 19:53:51 +0000 (15:53 -0400)] 
Merge "Route bulk update/delete exec through new Query._execute_crud method"

6 years agoRoute bulk update/delete exec through new Query._execute_crud method
Mike Bayer [Wed, 7 Feb 2018 00:30:55 +0000 (19:30 -0500)] 
Route bulk update/delete exec through new Query._execute_crud method

Added support for bulk :meth:`.Query.update` and :meth:`.Query.delete`
to the :class:`.ShardedQuery` class within the horiziontal sharding
extension.  This also adds an additional expansion hook to the
bulk update/delete methods :meth:`.Query._execute_crud`.

Fixes: #4196
Change-Id: I65f56458176497a8cbdd368f41b879881f06348b

6 years agoMerge "Support tuples of heterogeneous types for empty expanding IN"
mike bayer [Thu, 4 Oct 2018 17:49:42 +0000 (13:49 -0400)] 
Merge "Support tuples of heterogeneous types for empty expanding IN"

6 years agoSupport tuples of heterogeneous types for empty expanding IN
Mike Bayer [Wed, 3 Oct 2018 14:40:38 +0000 (10:40 -0400)] 
Support tuples of heterogeneous types for empty expanding IN

Pass a list of all the types for the left side of an
IN expression to the visit_empty_set_expr() method, so that
the "empty expanding IN" can produce clauses for each element.

Fixes: #4271
Change-Id: I2738b9df2292ac01afda37f16d4fa56ae7bf9147

6 years agoPerform additional retrieval of correct column names
Mike Bayer [Tue, 2 Oct 2018 21:49:44 +0000 (17:49 -0400)] 
Perform additional retrieval of correct column names

Added a workaround for a MySQL bug #88718 introduced in the 8.0 series,
where the reflection of a foreign key constraint is not reporting the
correct case sensitivity for the referred column, leading to errors during
use of the reflected constraint such as when using the automap extension.
The workaround emits an additional query to the information_schema tables in
order to retrieve the correct case sensitive name.

Fixes: #4344
Change-Id: I08020d6eec43cbe8a56316660380d3739a0b45f7

6 years agoAdd additional documentation for ORM fetched defaults
Mike Bayer [Tue, 2 Oct 2018 17:54:00 +0000 (13:54 -0400)] 
Add additional documentation for ORM fetched defaults

Add additional examples to the section first added as part
of #4317 to cover the use cases requested in #3921.

Fixes: #3921
Change-Id: I6ec283aa0a6fbabedef40bb4320751ab4cd990ea

6 years agoMerge "Fix dependency_for final argument"
mike bayer [Tue, 2 Oct 2018 13:10:24 +0000 (09:10 -0400)] 
Merge "Fix dependency_for final argument"

6 years agoMerge "Add .info to InstanceState"
mike bayer [Tue, 2 Oct 2018 01:37:49 +0000 (21:37 -0400)] 
Merge "Add .info to InstanceState"

6 years agoMerge "Add reflection support for Postgresql partitioned tables"
mike bayer [Tue, 2 Oct 2018 01:36:47 +0000 (21:36 -0400)] 
Merge "Add reflection support for Postgresql partitioned tables"

6 years agoMerge "Strong reference parent object in association proxy"
mike bayer [Tue, 2 Oct 2018 01:34:05 +0000 (21:34 -0400)] 
Merge "Strong reference parent object in association proxy"

6 years agoFix dependency_for final argument
Joe Urciuoli [Wed, 19 Sep 2018 17:40:23 +0000 (13:40 -0400)] 
Fix dependency_for final argument

Fixed issue where part of the utility language helper internals was passing
the wrong kind of argument to the Python ``__import__`` builtin as the list
of modules to be imported.  The issue produced no symptoms within the core
library but could cause issues with external applications that redefine the
``__import__`` builtin or otherwise instrument it. Pull request courtesy Joe
Urciuoli.

Per the submitter: "The fourth argument provided to `__import__`  (which
`import_` feeds in to) is supposed to be a a list of strings, but this code is
passing a single string. This was causing the sqlalchemy `import_` function to
break the string (for example 'interfaces') into an array of single characters
['i', 'n', ...], which causes the actual `__import__` to not find the module
`sqlalchemy.orm.i` (since it's trying to import `sqlalchemy.orm.i` and
`sqlalchemy.orm.n` .. etc)"

No issue could be reproduced locally as it seems you can put anything non-
empty/None into that last argument, even a list like ``['X']``, and  all the
sub-modules seem to appear.  Omit it, and then the sub-modules aren't present.
Perhaps it just runs the module or not if this attribute is present.

Change-Id: Ia15c74620f24d24f0df4882f9b36a04e2c3725b8
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/473

6 years agoStrong reference parent object in association proxy
Mike Bayer [Fri, 1 Jun 2018 19:50:25 +0000 (14:50 -0500)] 
Strong reference parent object in association proxy

Considering the reversal of #597 as well as
84420a1d0fe09d7a45e878e853aa9f5258561f8b as I am unable to reproduce
the original issues from that release.

The long-standing behavior of the association proxy collection maintaining
only a weak reference to the parent object is reverted; the proxy will now
maintain a strong reference to the parent for as long as the proxy
collection itself is also in memory, eliminating the "stale association
proxy" error. This change is being made on an experimental basis to see if
any use cases arise where it causes side effects.

Change-Id: I051334be90a343dd0e8a1f35e072075eb14b14a7
Fixes: #4268
6 years agoAdd .info to InstanceState
Mike Bayer [Mon, 1 Oct 2018 20:34:50 +0000 (16:34 -0400)] 
Add .info to InstanceState

Added ``.info`` dictionary to the :class:`.InstanceState` class, the object
that comes from calling :func:`.inspect` on a mapped object.

Fixes: #4257
Change-Id: I32d043f369edb708a17eec2e0b8876db0c1891b4

6 years agoAdd reflection support for Postgresql partitioned tables
Mike Bayer [Mon, 1 Oct 2018 20:23:33 +0000 (16:23 -0400)] 
Add reflection support for Postgresql partitioned tables

Added rudimental support for reflection of Postgresql
partitioned tables, e.g. that relkind='p' is added to reflection
queries that return table information.

Fixes: #4237
Change-Id: I66fd10b002e4ed21ea13b13a7e35a85f66bdea75

6 years agoAdd test and retroactive changelog for issue 4040
Mike Bayer [Mon, 1 Oct 2018 18:00:39 +0000 (14:00 -0400)] 
Add test and retroactive changelog for issue 4040

Fixes: #4040
Change-Id: I707c1cd2708a37102ad8184bec21be35cb6242d7

6 years agoAdd link to Code of Conduct
Mike Bayer [Sat, 29 Sep 2018 23:12:40 +0000 (19:12 -0400)] 
Add link to Code of Conduct

Change-Id: Ib07db7c2fc97739a172e541a0681176a67f89a2f

6 years agoRemove unnecessary unicode and raw string prefix
Denis Kataev [Fri, 28 Sep 2018 07:40:30 +0000 (12:40 +0500)] 
Remove unnecessary unicode and raw string prefix

6 years agoMerge "Import from collections.abc"
mike bayer [Fri, 28 Sep 2018 01:55:01 +0000 (21:55 -0400)] 
Merge "Import from collections.abc"

6 years agoAdd non-primary mapper example illustrating a row-limited relationship
Mike Bayer [Fri, 28 Sep 2018 01:27:59 +0000 (21:27 -0400)] 
Add non-primary mapper example illustrating a row-limited relationship

Change-Id: Ifcb3baa6b220e375dc029794dd10c111660eac94

6 years agoMerge "Break association proxy into a descriptor + per-class accessor"
mike bayer [Thu, 27 Sep 2018 21:10:21 +0000 (17:10 -0400)] 
Merge "Break association proxy into a descriptor + per-class accessor"

6 years agoBreak association proxy into a descriptor + per-class accessor
Mike Bayer [Tue, 27 Feb 2018 18:15:10 +0000 (13:15 -0500)] 
Break association proxy into a descriptor + per-class accessor

Reworked :class:`.AssociationProxy` to store state that's specific to a
parent class in a separate object, so that a single
:class:`.AssocationProxy` can serve for multiple parent classes, as is
intrinsic to inheritance, without any ambiguity in the state returned by it.
A new method :meth:`.AssociationProxy.for_class` is added to allow
inspection of class-specific state.

Change-Id: I634f88aae6306ac5c5237a0e1acbe07d0481d6b6
Fixes: #3423
6 years agoImport from collections.abc
xtreak [Mon, 24 Sep 2018 16:23:54 +0000 (12:23 -0400)] 
Import from collections.abc

Fixed additional warnings generated by Python 3.7 due to changes in the
organization of the Python ``collections`` and ``collections.abc`` packages.
Previous ``collections`` warnings were fixed in version 1.2.11. Pull request
courtesy xtreak.

See I2d1c0ef97c8ecac7af152cc56263422a40faa6bb for the original collections.abc
fixes.

Fixes: #4339
Change-Id: Ia92d2461f20309fb33ea6c6f592f7d4e7e32ae7a
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/475

6 years agoMerge "Remove MappedCollection converter; deprecate @converter"
mike bayer [Thu, 27 Sep 2018 19:44:45 +0000 (15:44 -0400)] 
Merge "Remove MappedCollection converter; deprecate @converter"

6 years agoRemove MappedCollection converter; deprecate @converter
Mike Bayer [Wed, 26 Sep 2018 22:52:44 +0000 (18:52 -0400)] 
Remove MappedCollection converter; deprecate @converter

Removed the collection converter used by the :class:`.MappedCollection`
class. This converter was used only to assert that the incoming dictionary
keys matched that of their corresponding objects, and only during a bulk set
operation.  The converter can interfere with a custom validator or
:meth:`.AttributeEvents.bulk_replace` listener that wants to convert
incoming values further.  The ``TypeError`` which would be raised by this
converter when an incoming key didn't match the value is removed; incoming
values during a bulk assignment will be keyed to their value-generated key,
and not the key that's explicitly present in the dictionary.

Overall, @converter is superseded by the
:meth:`.AttributeEvents.bulk_replace` event handler added as part of
:ticket:`3896`.

Fixes: #3604
Change-Id: Id0f7bd2cec938f5975eb2ab94df9ba5754dd43c3

6 years agoMerge "Copy create_constraint flag for Enum"
mike bayer [Wed, 26 Sep 2018 00:16:33 +0000 (20:16 -0400)] 
Merge "Copy create_constraint flag for Enum"

6 years agoMerge "Accept multiple expressions for aggregate_order_by order_by"
mike bayer [Wed, 26 Sep 2018 00:15:54 +0000 (20:15 -0400)] 
Merge "Accept multiple expressions for aggregate_order_by order_by"

6 years agoMerge remote-tracking branch 'origin/pr/476' into pep-8-mxodbc
Mike Bayer [Tue, 25 Sep 2018 15:44:33 +0000 (11:44 -0400)] 
Merge remote-tracking branch 'origin/pr/476' into pep-8-mxodbc

Change-Id: I0aa585719737c03a6ebb99b8ccb9f4ffdfd3fed5

6 years agoAccept multiple expressions for aggregate_order_by order_by
Mike Bayer [Tue, 25 Sep 2018 15:11:41 +0000 (11:11 -0400)] 
Accept multiple expressions for aggregate_order_by order_by

Added support for the :class:`.aggregate_order_by` function to receive
multiple ORDER BY elements, previously only a single element was accepted.

Fixes: #4337
Change-Id: I411ac31697a0d65b568ad65ce5b5181717afbd65

6 years agoCopy create_constraint flag for Enum
Mike Bayer [Tue, 25 Sep 2018 14:38:40 +0000 (10:38 -0400)] 
Copy create_constraint flag for Enum

Fixed bug where the :paramref:`.Enum.create_constraint` flag on  the
:class:`.Enum` datatype would not be propagated to copies of the type, which
affects use cases such as declarative mixins and abstract bases.

Fixes: #4341
Change-Id: I978be65f33a616fe4d5f5de03fb3eaab6f6a2272

6 years agoPEP8 mxodbc.py
Agam Rafaeli [Mon, 24 Sep 2018 12:01:44 +0000 (15:01 +0300)] 
PEP8 mxodbc.py

6 years agoAdd use_nchar_for_unicode flag; don't use nchar types for generic unicode
Mike Bayer [Wed, 13 Jun 2018 21:48:51 +0000 (17:48 -0400)] 
Add use_nchar_for_unicode flag; don't use nchar types for generic unicode

The Oracle dialect will no longer use the NCHAR/NCLOB datatypes to
represent generic unicode strings or clob fields in conjunction with
:class:`.Unicode` and :class:`.UnicodeText` unless the flag
``use_nchar_for_unicode=True`` is passed to :func:`.create_engine`.
Additionally, string types under Oracle now coerce to unicode under Python
2 in all cases, however unlike in previous iterations, we use SQLAlchemy's
native unicode handlers which are very performant (when C extensions are
enabled; when they are not, we use cx_Oracle's handlers).

Change-Id: I3939012e9396520875bc52e69bf81f27393836ee
Fixes: #4242
6 years agomove callcounts up to python 3.7
Mike Bayer [Fri, 21 Sep 2018 17:53:59 +0000 (13:53 -0400)] 
move callcounts up to python 3.7

Change-Id: I1d17c2cd05b0dc3b787609925b6ebf2075752394

6 years agoMerge "Allow dialects to customize group by clause compilation"
mike bayer [Fri, 21 Sep 2018 01:54:25 +0000 (21:54 -0400)] 
Merge "Allow dialects to customize group by clause compilation"

6 years agoAllow dialects to customize group by clause compilation
Samuel Chou [Wed, 19 Sep 2018 17:30:24 +0000 (13:30 -0400)] 
Allow dialects to customize group by clause compilation

Refactored :class:`.SQLCompiler` to expose a
:meth:`.SQLCompiler.group_by_clause` method similar to the
:meth:`.SQLCompiler.order_by_clause` and :meth:`.SQLCompiler.limit_clause`
methods, which can be overridden by dialects to customize how GROUP BY
renders.  Pull request courtesy Samuel Chou.

Change-Id: I0a7238e55032558c27a0c56a72907c7b883456f1
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/474

6 years ago- forgot the colon
Mike Bayer [Wed, 19 Sep 2018 20:12:50 +0000 (16:12 -0400)] 
- forgot the colon

Change-Id: I954d939ace775b5e6d94b8b1a909a9eddb7f352f

6 years agoAllow pip opts to be specified in environment
Mike Bayer [Wed, 19 Sep 2018 18:55:09 +0000 (14:55 -0400)] 
Allow pip opts to be specified in environment

To allow a custom requirements file to be passed in,
add a generic passthrough to the tox install command.

Change-Id: Ic2e46a27914b76802dc26143e34ad507978af474

6 years agocherry-pick changelog update for 1.2.13
Mike Bayer [Wed, 19 Sep 2018 18:15:19 +0000 (14:15 -0400)] 
cherry-pick changelog update for 1.2.13

6 years agocherry-pick changelog from 1.2.12
Mike Bayer [Wed, 19 Sep 2018 18:15:18 +0000 (14:15 -0400)] 
cherry-pick changelog from 1.2.12

6 years agoMerge "Adapt right side in join if lateral detected"
mike bayer [Wed, 19 Sep 2018 13:30:34 +0000 (09:30 -0400)] 
Merge "Adapt right side in join if lateral detected"

6 years agoMerge "Add LIFO for connection pooling"
mike bayer [Wed, 19 Sep 2018 03:29:34 +0000 (23:29 -0400)] 
Merge "Add LIFO for connection pooling"

6 years agoAdd LIFO for connection pooling
Taem Park [Tue, 21 Aug 2018 14:54:45 +0000 (10:54 -0400)] 
Add LIFO for connection pooling

Added new "lifo" mode to :class:`.QueuePool`, typically enabled by setting
the flag :paramref:`.create_engine.pool_use_lifo` to True.   "lifo" mode
means the same connection just checked in will be the first to be checked
out again, allowing excess connections to be cleaned up from the server
side during periods of the pool being only partially utilized.  Pull request
courtesy Taem Park.

Change-Id: Idb5e299c5082b3e6b547bd03022acf65fdc34f35
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/467

6 years agoAdapt right side in join if lateral detected
Mike Bayer [Mon, 17 Sep 2018 15:38:52 +0000 (11:38 -0400)] 
Adapt right side in join if lateral detected

Fixed bug where use of :class:`.Lateral` construct in conjunction with
:meth:`.Query.join` as well as :meth:`.Query.select_entity_from` would not
apply clause adaption to the right side of the join.   "lateral" introduces
the use case of the right side of a join being correlatable.  Previously,
adaptation of this clause wasn't considered.

Fixes: #4334
Change-Id: I3631e562092769d30069a2aa5e50a580f4661a23

6 years agoLook for dict builtin in InstanceState cleanup
Romuald Brunet [Mon, 17 Sep 2018 15:44:50 +0000 (11:44 -0400)] 
Look for dict builtin in InstanceState cleanup

Added a check within the weakref cleanup for the :class:`.InstanceState`
object to check for the presence of the ``dict`` builtin, in an effort to
reduce error messages generated when these cleanups occur during interpreter
shutdown.  Pull request courtesy Romuald Brunet.

Change-Id: If27b94d50a32767de8b4147c09fa423f71596004
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/472

6 years agoUse cx_Oracle dml_ret_array_val
Mike Bayer [Mon, 17 Sep 2018 18:05:46 +0000 (14:05 -0400)] 
Use cx_Oracle dml_ret_array_val

Fixed issue for cx_Oracle 7.0 where the behavior of Oracle param.getvalue()
now returns a list, rather than a single scalar value, breaking
autoincrement logic throughout the Core and ORM. The dml_ret_array_val
compatibility flag is used for cx_Oracle 6.3 and 6.4 to establish compatible
behavior with 7.0 and forward, for cx_Oracle 6.2.1 and prior a version
number check falls back to the old logic.

Fixes: #4335
Change-Id: Ia60f5514803a505898c1ac9252355990c6203dda

6 years agoMerge remote-tracking branch 'origin/pr/471'
Mike Bayer [Mon, 17 Sep 2018 13:20:39 +0000 (09:20 -0400)] 
Merge remote-tracking branch 'origin/pr/471'

Change-Id: I1ddafb5d145c892d86fa130a6fed2402d3e388bb

6 years agoDon't list 1.2.x bugfixes as 1.3.0b1 bugfixes
Mike Bayer [Thu, 13 Sep 2018 23:43:12 +0000 (17:43 -0600)] 
Don't list 1.2.x bugfixes as 1.3.0b1 bugfixes

We will still list features in 1.3 as backported but
it is too verbose to have all of 1.2.x's bugfixes listed as part
of 1.3.0b1 also.

Change-Id: Icb09050734af86a66a72b3f92a6bd60ee3e2f6ee

6 years agoAdd explicit note about @hybrid_property mutators re: method name
Mike Bayer [Wed, 12 Sep 2018 15:44:57 +0000 (09:44 -0600)] 
Add explicit note about @hybrid_property mutators re: method name

Fixes: #4332
Change-Id: I7c52140d3a3055a71b192fea020c795a57356d90

6 years agoFix doc type
Wouter Overmeire [Tue, 11 Sep 2018 12:17:02 +0000 (14:17 +0200)] 
Fix doc type

6 years agominor spelling correction
Glyph [Thu, 6 Sep 2018 22:58:12 +0000 (15:58 -0700)] 
minor spelling correction

6 years agoClarify init_scalar event use case
Mike Bayer [Thu, 6 Sep 2018 14:44:09 +0000 (10:44 -0400)] 
Clarify init_scalar event use case

Since I didn't even realize what this was for when reading the docs,
make it clearer that this is to mirror a Column default and remove
the extra verbiage about the mechanics of INSERTs.

Change-Id: Id2c6a29800f7b723573610e4707aec7e6ea38f5f

6 years agoMariaDB 10.3 updates
Mike Bayer [Thu, 30 Aug 2018 21:12:58 +0000 (17:12 -0400)] 
MariaDB 10.3 updates

MariaDB seems to handle some additional UPDATE/DELETE FROM
syntaxes as well as some forms of INTERSECT and EXCEPT. Open
up tests that expect failure for MySQL to allow success for
MariaDB 10.3.

Change-Id: Ia9341a82485ef7201bb8130d8dbf4a9b6976035a

6 years agoFix links and update verbiage for reset_on_return
Mike Bayer [Tue, 28 Aug 2018 18:58:05 +0000 (14:58 -0400)] 
Fix links and update verbiage for reset_on_return

Change-Id: I642056b78570b44fdefe7f0874a8e4c720389f14

6 years agoMerge "Add option to sort into inserts/updates to bulk_save_objects"
mike bayer [Tue, 28 Aug 2018 13:26:11 +0000 (09:26 -0400)] 
Merge "Add option to sort into inserts/updates to bulk_save_objects"

6 years agoMerge "Add python_requires and update classifiers"
mike bayer [Tue, 28 Aug 2018 13:03:15 +0000 (09:03 -0400)] 
Merge "Add python_requires and update classifiers"

6 years agoAdd option to sort into inserts/updates to bulk_save_objects
Alessandro Cucci [Sat, 25 Aug 2018 13:14:22 +0000 (09:14 -0400)] 
Add option to sort into inserts/updates to bulk_save_objects

Added new flag :paramref:`.Session.bulk_save_objects.preserve_order` to the
:meth:`.Session.bulk_save_objects` method, which defaults to True. When set
to False, the given mappings will be grouped into inserts and updates per
each object type, to allow for greater opportunities to batch common
operations together.  Pull request courtesy Alessandro Cucci.

Change-Id: I0d041f7696cf733655a74beeceee3fa80640efd7
Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/6

6 years agoAdd BakedQuery.to_query() method
Mike Bayer [Mon, 27 Aug 2018 15:07:48 +0000 (11:07 -0400)] 
Add BakedQuery.to_query() method

Added new feature :meth:`.BakedQuery.to_query`, which allows for a
clean way of using one :class:`.BakedQuery` as a subquery inside of another
:class:`.BakedQuery` without needing to refer explicitly to a
:class:`.Session`.

Fixes: #4318
Change-Id: I528056c7d140036c27b95500d7a60dcd14784016

6 years agodocument expanding bound parameters, in_(), and baked query use cases
Mike Bayer [Mon, 27 Aug 2018 18:51:59 +0000 (14:51 -0400)] 
document expanding bound parameters, in_(), and baked query use cases

Change-Id: I09ccd73ebabbea4b5098ba5b170786ac065444c8

6 years ago- pep8 cleanup
Mike Bayer [Mon, 27 Aug 2018 15:11:04 +0000 (11:11 -0400)] 
- pep8 cleanup

Change-Id: I1d6eaf91c069bd5dd55a40ddd38e2f440b259fea

6 years agofix link typos
Mike Bayer [Mon, 27 Aug 2018 14:25:59 +0000 (10:25 -0400)] 
fix link typos

Change-Id: I49233bf67caadf5ba69aa3b686f0ef6e5df3f15b

6 years agoCorrect expanding docs to support empty lists
Mike Bayer [Mon, 27 Aug 2018 14:18:15 +0000 (10:18 -0400)] 
Correct expanding docs to support empty lists

Change-Id: I9375b2055602216f9f25d32b2f7c035ae4280bd0

6 years agoInclude Session._query_cls as part of the cache key
Mike Bayer [Sun, 26 Aug 2018 16:35:59 +0000 (12:35 -0400)] 
Include Session._query_cls as part of the cache key

Fixed issue where :class:`.BakedQuery` did not include the specific query
class used by the :class:`.Session` as part of the cache key, leading to
incompatibilities when using custom query classes, in particular the
:class:`.ShardedQuery` which has some different argument signatures.

Fixes: #4328
Change-Id: I829c2a8b09c91e91c8dc8ea5476c0d7aa47028bd

6 years agoAdd python_requires and update classifiers
Hugo [Sun, 26 Aug 2018 17:50:12 +0000 (13:50 -0400)] 
Add python_requires and update classifiers

- bump minimum Python 3 version to 3.4 in docs
- set up setup.py classifiers to cover 2.7, 3.4, 3.5, 3.6, 3.7 explicitly
- add python_requires

These are also the ones supported by the core Python team.
https://en.wikipedia.org/wiki/CPython#Version_history

Change-Id: I2ffa632c73c39bf38ba9d8b5dcc86d552b61aa68
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/468

6 years agoMerge "Unwrap Proxy objects when scanning declared_attr"
mike bayer [Thu, 23 Aug 2018 21:58:04 +0000 (17:58 -0400)] 
Merge "Unwrap Proxy objects when scanning declared_attr"

6 years agoUnwrap Proxy objects when scanning declared_attr
Mike Bayer [Thu, 23 Aug 2018 16:40:26 +0000 (12:40 -0400)] 
Unwrap Proxy objects when scanning declared_attr

Fixed bug where the declarative scan for attributes would receive the
expression proxy delivered by a hybrid attribute at the class level, and
not the hybrid attribute itself, when receiving the descriptor via the
``@declared_attr`` callable on a subclass of an already-mapped class. This
would lead to an attribute that did not report itself as a hybrid when
viewed within :attr:`.Mapper.all_orm_descriptors`.

Fixes: #4326
Change-Id: I582d03f05c3768b3344f93e3791240e9e69b9d1e

6 years agoDon't run postfetch_post_update for a DELETE
Mike Bayer [Thu, 23 Aug 2018 15:55:13 +0000 (11:55 -0400)] 
Don't run postfetch_post_update for a DELETE

Fixed 1.2 regression caused by :ticket:`3472` where the handling of an
"updated_at" style column within the context of a post-update operation
would also occur for a row that is to be deleted following the update,
meaning both that a column with a Python-side value generator would show
the now-deleted value that was emitted for the UPDATE before the DELETE
(which was not the previous behavor), as well as that a SQL- emitted value
generator would have the attribute expired, meaning the previous value
would be unreachable due to the row having been deleted and the object
detached from the session.The "postfetch" logic that was added as part of
:ticket:`3472` is now skipped entirely for an object that ultimately is to
be deleted.

Fixes: #4327
Change-Id: Ieac845348979df296bcf7e785c0353bdc6074220

6 years agoPropagate **kw in postgresql distinct on compilation
Mike Bayer [Wed, 22 Aug 2018 21:18:48 +0000 (17:18 -0400)] 
Propagate **kw in postgresql distinct on compilation

Fixed bug in PostgreSQL dialect where compiler keyword arguments such as
``literal_binds=True`` were not being propagated to a DISTINCT ON
expression.

Fixes: #4325
Change-Id: I9949387dceb7fabe889799f42e92423572368b29

6 years agoPass desired array type from pg.array_agg to functions.array_agg
Mike Bayer [Wed, 22 Aug 2018 15:13:54 +0000 (11:13 -0400)] 
Pass desired array type from pg.array_agg to functions.array_agg

Fixed the :func:`.postgresql.array_agg` function, which is a slightly
altered version of the usual :func:`.functions.array_agg` function, to also
accept an incoming "type" argument without forcing an ARRAY around it,
essentially the same thing that was fixed for the generic function in 1.1
in :ticket:`4107`.

Fixes: #4324
Change-Id: I399a29f59c945a217cdd22c65ff0325edea8ea65

6 years agoStrip quotes from format_type in addition to other characters
Mike Bayer [Wed, 22 Aug 2018 00:59:04 +0000 (20:59 -0400)] 
Strip quotes from format_type in addition to other characters

Fixed bug in PostgreSQL ENUM reflection where a case-sensitive, quoted name
would be reported by the query including quotes, which would not match a
target column during table reflection as the quotes needed to be stripped
off.

Fixes: #4323
Change-Id: I668f3acccc578e58f23b70c82d31d5c1ec194913

6 years agocherry-pick changelog update for 1.2.12
Mike Bayer [Mon, 20 Aug 2018 21:00:53 +0000 (17:00 -0400)] 
cherry-pick changelog update for 1.2.12

6 years agocherry-pick changelog from 1.2.11
Mike Bayer [Mon, 20 Aug 2018 21:00:53 +0000 (17:00 -0400)] 
cherry-pick changelog from 1.2.11

6 years agoAdd missing range_ / rows parameters to additional over() methods
Mike Bayer [Mon, 20 Aug 2018 02:19:59 +0000 (22:19 -0400)] 
Add missing range_ / rows parameters to additional over() methods

Added missing window function parameters
:paramref:`.WithinGroup.over.range_` and :paramref:`.WithinGroup.over.rows`
parameters to the :meth:`.WithinGroup.over` and
:meth:`.FunctionFilter.over` methods, to correspond to the range/rows
feature added to the "over" method of SQL functions as part of
:ticket:`3049` in version 1.1.

Fixes: #4322
Change-Id: I77dcdac65c699a4b52a3fc3ee09a100ffb4fc20e

6 years agoDocument binary_prefix for mysqlclient and PyMySQL
Mike Bayer [Fri, 17 Aug 2018 23:25:20 +0000 (19:25 -0400)] 
Document binary_prefix for mysqlclient and PyMySQL

Also, remove the section on "use_unicode=0", there is no reason
anyone should be using that now.

Fixes: #4216
Change-Id: I5b8b53e40903adf339af2934a4f2d8b068818ebf

6 years agoMerge "Accommodate for classically mapped base classes in declarative"
mike bayer [Fri, 17 Aug 2018 18:55:26 +0000 (14:55 -0400)] 
Merge "Accommodate for classically mapped base classes in declarative"

6 years agoMerge "Add concept of "implicit boolean", treat as native"
mike bayer [Fri, 17 Aug 2018 15:51:22 +0000 (11:51 -0400)] 
Merge "Add concept of "implicit boolean", treat as native"

6 years agoAccommodate for classically mapped base classes in declarative
Mike Bayer [Fri, 17 Aug 2018 15:37:30 +0000 (11:37 -0400)] 
Accommodate for classically mapped base classes in declarative

Fixed issue in previously untested use case, allowing a declarative mapped
class to inherit from a classically-mapped class outside of the declarative
base, including that it accommodates for unmapped intermediate classes. An
unmapped intermediate class may specify ``__abstract__``, which is now
interpreted correctly, or the intermediate class can remain unmarked, and
the classically mapped base class will be detected within the hierarchy
regardless. In order to anticipate existing scenarios which may be mixing
in classical mappings into existing declarative hierarchies, an error is
now raised if multiple mapped bases are detected for a given class.

Fixes: #4321
Change-Id: I8604ecfd170d2589d9d1b1c87ba303762071fc30

6 years agoAdd test support for #4036
Mike Bayer [Wed, 15 Aug 2018 20:36:30 +0000 (16:36 -0400)] 
Add test support for #4036

Add a test that asserts MySQL can't implicitly treat a decimal
bound parameter without context and everyone else can.

Change-Id: I40e24a463d6eb03fd677195895891e73624776c3

6 years agoAdd concept of "implicit boolean", treat as native
Mike Bayer [Wed, 15 Aug 2018 21:11:14 +0000 (17:11 -0400)] 
Add concept of "implicit boolean", treat as native

Fixed issue that is closely related to :ticket:`3639` where an expression
rendered in a boolean context on a non-native boolean backend would
be compared to 1/0 even though it is already an implcitly boolean
expression, when :meth:`.ColumnElement.self_group` were used.  While this
does not affect the user-friendly backends (MySQL, SQLite) it was not
handled by Oracle (and possibly SQL Server).   Whether or not the
expression is implicitly boolean on any database is now determined
up front as an additional check to not generate the integer comparison
within the compliation of the statement.

Fixes: #4320
Change-Id: Iae0a65e5c01bd576e64733c3651e1e1a1a1b240c

6 years agoAdd ability to preserve order in MySQL ON DUPLICATE KEY UPDATE.
Maxim Bublis [Wed, 18 Jul 2018 18:06:07 +0000 (14:06 -0400)] 
Add ability to preserve order in MySQL ON DUPLICATE KEY UPDATE.

Added support for the parameters in an ON DUPLICATE KEY UPDATE statement on
MySQL to be ordered, since parameter order in a MySQL UPDATE clause is
significant, in a similar manner as that described at
:ref:`updates_order_parameters`.  Pull request courtesy Maxim Bublis.

Pull-request: https://github.com/zzzeek/sqlalchemy/pull/462
Change-Id: If508d8e26dbd3c55ab1e83cf573fb4021e9d091e

6 years agoCorrect for the INSERT statement, typos
Mike Bayer [Thu, 9 Aug 2018 18:35:52 +0000 (14:35 -0400)] 
Correct for the INSERT statement, typos

Change-Id: I036f3eb9b5e591515920678bc9a76f707fda142c

6 years agoWrite a much better section about server defaults
Mike Bayer [Thu, 9 Aug 2018 17:34:03 +0000 (13:34 -0400)] 
Write a much better section about server defaults

Include information about eager_defaults etc.  These
docs were written before we had all the features
we do now.

Change-Id: Ie62e58c5986698824f717e9f8c802b07a27517d4
Fixes: #4317
6 years agoFixed issue with :meth:`.TypeEngine.bind_expression` and
Mike Bayer [Tue, 7 Aug 2018 22:59:05 +0000 (18:59 -0400)] 
Fixed issue with :meth:`.TypeEngine.bind_expression` and
:meth:`.TypeEngine.column_expression` methods where these methods would not
work if the target type were part of a :class:`.Variant`, or other target
type of a :class:`.TypeDecorator`.  Additionally, the SQL compiler now
calls upon the dialect-level implementation when it renders these methods
so that dialects can now provide for SQL-level processing for built-in
types.

Change-Id: Ic7b39575184db582e628e6ecee48dcda7d03a817
Fixes: #3981
6 years agoAdd support of empty list in exanding of bindparam
Nicolas Rolin [Fri, 25 May 2018 17:27:22 +0000 (13:27 -0400)] 
Add support of empty list in exanding of bindparam

Added new logic to the "expanding IN" bound parameter feature whereby if
the given list is empty, a special "empty set" expression that is specific
to different backends is generated, thus allowing IN expressions to be
fully dynamic including empty IN expressions.

Fixes: #4271
Change-Id: Icc3c73bbd6005206b9d06baaeb14a097af5edd36
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/432

6 years agoInclude UPDATE/DELETE extra_froms in correlation
Mike Bayer [Sat, 4 Aug 2018 17:45:07 +0000 (13:45 -0400)] 
Include UPDATE/DELETE extra_froms in correlation

Fixed bug where the multi-table support for UPDATE and DELETE statements
did not consider the additional FROM elements as targets for correlation,
when a correlated SELECT were also combined with the statement.  This
change now includes that a SELECT statement in the WHERE clause for such a
statement will try to auto-correlate back to these additional tables in the
parent UPDATE/DELETE or unconditionally correlate if
:meth:`.Select.correlate` is used.  Note that auto-correlation raises an
error if the SELECT statement would have no FROM clauses as a result, which
can now occur if the parent UPDATE/DELETE specifies the same tables in its
additional set of tables ; specify :meth:`.Select.correlate` explicitly to
resolve.

Change-Id: Ie11eaad7e49af3f59df11691b104d6359341bdae
Fixes: #4313
6 years agoMerge "Handle association proxy delete and provide for scalar delete cascade"
mike bayer [Thu, 2 Aug 2018 03:20:01 +0000 (23:20 -0400)] 
Merge "Handle association proxy delete and provide for scalar delete cascade"

6 years agoMerge "Bind Integers to int for cx_Oracle"
mike bayer [Thu, 2 Aug 2018 03:18:58 +0000 (23:18 -0400)] 
Merge "Bind Integers to int for cx_Oracle"

6 years agoBind Integers to int for cx_Oracle
Mike Bayer [Wed, 1 Aug 2018 18:12:49 +0000 (14:12 -0400)] 
Bind Integers to int for cx_Oracle

For cx_Oracle, Integer datatypes will now be bound to "int", per advice
from the cx_Oracle developers.  Previously, using cx_Oracle.NUMBER caused a
loss in precision within the cx_Oracle 6.x series.

Change-Id: I4c6b2cca490aff5b98b7ceff3414715202881c89
Fixes: #4309
6 years agoHandle association proxy delete and provide for scalar delete cascade
Mike Bayer [Wed, 1 Aug 2018 16:01:59 +0000 (12:01 -0400)] 
Handle association proxy delete and provide for scalar delete cascade

Fixed multiple issues regarding de-association of scalar objects with the
association proxy.  ``del`` now works, and additionally a new flag
:paramref:`.AssociationProxy.cascade_scalar_deletes` is added, which when
set to True indicates that setting a scalar attribute to ``None`` or
deleting via ``del`` will also set the source association to ``None``.

Change-Id: I1580d761571d63eb03a7e8df078cef97d265b85c
Fixes: #4308
6 years agoMerge "Fix collections ABC access before Python 3.8"
mike bayer [Wed, 1 Aug 2018 21:39:58 +0000 (17:39 -0400)] 
Merge "Fix collections ABC access before Python 3.8"

6 years agoMention Properties keys in __dir__
Korn, Uwe [Mon, 9 Jul 2018 15:54:38 +0000 (11:54 -0400)] 
Mention Properties keys in __dir__

The Python builtin ``dir()`` is now supported for a SQLAlchemy "properties"
object, such as that of a Core columns collection (e.g. ``.c``),
``mapper.attrs``, etc.  Allows iPython autocompletion to work as well.
Pull request courtesy Uwe Korn.

Change-Id: I8696729542d1b74a566642a3a63fd500f64588cd
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/458

Mention Properties keys in __dir__

Change-Id: I88939955857c8df5eed0b87bc27c45357780b17d

6 years agoFix collections ABC access before Python 3.8
Nathaniel Knight [Wed, 1 Aug 2018 01:59:47 +0000 (21:59 -0400)] 
Fix collections ABC access before Python 3.8

Started importing "collections" from "collections.abc" under Python 3.3 and
greater for Python 3.8 compatibility.  Pull request courtesy Nathaniel
Knight.

In Python 3.3, the abstract base classes (Iterable, Mapping, etc.)
were moved from the `collections` module and put in the
`collections.abc` module. They remain in the `collections` module for
backwards compatibility, and will until Python 3.8.

This commit adds a variable (`collections_abc`) to the `util/compat`
module, which will be the `collections` module for Python < 3.3 and
before, or the `collections.abc` module for Python >= 3.3. It also
uses the new variable, getting rid of some deprecation warnings that
were seen when running under Python 3.7.

Change-Id: I2d1c0ef97c8ecac7af152cc56263422a40faa6bb
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/464

6 years agoCorrect sharding tests for provisioned follower
Mike Bayer [Wed, 1 Aug 2018 16:27:22 +0000 (12:27 -0400)] 
Correct sharding tests for provisioned follower

The sharding tests created named sqlite databases that were
shared across test suites.  It is unknown why these suddenly
started failing and were not failing before.

Change-Id: If2044f914ddaea0db594aa18b9278e24e2c818ea

6 years agoDo some pep8 and other cruft removal around association proxy
Mike Bayer [Wed, 1 Aug 2018 16:13:33 +0000 (12:13 -0400)] 
Do some pep8 and other cruft removal around association proxy

Change-Id: I33130022a7e223318b65388620828d539f6dacfd

6 years agoMerge branch 'migration-12-typo-fix' of https://bitbucket.org/nbasu02/sqlalchemy
Mike Bayer [Wed, 1 Aug 2018 02:11:22 +0000 (22:11 -0400)] 
Merge branch 'migration-12-typo-fix' of https://bitbucket.org/nbasu02/sqlalchemy

Change-Id: I4682c1f7f94f25b813be686fdce0a2e0839412fe

6 years agoAdd comma in migration-12
Neil Basu [Tue, 31 Jul 2018 21:27:18 +0000 (14:27 -0700)] 
Add comma in migration-12

7 years agoReplace 'with' with 'which'
Kevin Horn [Fri, 27 Jul 2018 16:06:50 +0000 (11:06 -0500)] 
Replace 'with' with 'which'

7 years agoMerge "Fix quoting schemas in _get_table_sql for the SQLite backend"
mike bayer [Wed, 18 Jul 2018 18:00:33 +0000 (14:00 -0400)] 
Merge "Fix quoting schemas in _get_table_sql for the SQLite backend"

7 years agoFix quoting schemas in _get_table_sql for the SQLite backend
Phillip Cloud [Mon, 16 Jul 2018 14:10:55 +0000 (10:10 -0400)] 
Fix quoting schemas in _get_table_sql for the SQLite backend

Fixed issue where the "schema" name used for a SQLite database within table
reflection would not quote the schema name correctly.  Pull request
courtesy Phillip Cloud.

Change-Id: I2770788c1f094a7743209250ec26b5ef5fb2d9e8
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/463