]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/log
thirdparty/sqlalchemy/sqlalchemy.git
5 years agoUpdate link to sqlalchemy-access 4842/head
Gord Thompson [Thu, 5 Sep 2019 13:53:41 +0000 (07:53 -0600)] 
Update link to sqlalchemy-access

5 years agoMerge "Label simple column transformations as the column name"
mike bayer [Fri, 30 Aug 2019 15:21:08 +0000 (15:21 +0000)] 
Merge "Label simple column transformations as the column name"

5 years agoLabel simple column transformations as the column name
Mike Bayer [Tue, 27 Aug 2019 21:08:11 +0000 (17:08 -0400)] 
Label simple column transformations as the column name

Additional logic has been added such that certain SQL expressions which
typically wrap a single database column will use the name of that column as
their "anonymous label" name within a SELECT statement, potentially making
key-based lookups in result tuples more intutive.   The primary example of
this is that of a CAST expression, e.g. ``CAST(table.colname AS INTEGER)``,
which will export its default name as "colname", rather than the usual
"anon_1" label, that is, ``CAST(table.colname AS INTEGER) AS colname``.
If the inner expression doesn't have a name, then the previous "anonymous
label" logic is used.  When using SELECT statements that make use of
:meth:`.Select.apply_labels`, such as those emitted by the ORM, the
labeling logic will produce ``<tablename>_<inner column name>`` in the same
was as if the column were named alone.   The logic applies right now to the
:func:`.cast` and :func:`.type_coerce` constructs as well as some
single-element boolean expressions.

Fixes: #4449
Change-Id: Ie3b73470e3bea53f2386cd86514cdc556491564e

5 years agocherry-pick changelog update for 1.3.9
Mike Bayer [Tue, 27 Aug 2019 23:30:04 +0000 (19:30 -0400)] 
cherry-pick changelog update for 1.3.9

5 years agocherry-pick changelog from 1.3.8
Mike Bayer [Tue, 27 Aug 2019 23:30:04 +0000 (19:30 -0400)] 
cherry-pick changelog from 1.3.8

5 years agoMerge "Implement type-level sorting for Enum; apply to ORM primary keys"
mike bayer [Tue, 27 Aug 2019 19:29:21 +0000 (19:29 +0000)] 
Merge "Implement type-level sorting for Enum; apply to ORM primary keys"

5 years agoImplement type-level sorting for Enum; apply to ORM primary keys
Nicolas CANIART [Thu, 22 Aug 2019 18:16:29 +0000 (14:16 -0400)] 
Implement type-level sorting for Enum; apply to ORM primary keys

Added support for the use of an :class:`.Enum` datatype using Python
pep-435 enumeration objects as values for use as a primary key column
mapped by the ORM.  As these values are not inherently sortable, as
required by the ORM for primary keys, a new
:attr:`.TypeEngine.sort_key_function` attribute is added to the typing
system which allows any SQL type to  implement a sorting for Python objects
of its type which is consulted by the unit of work.   The :class:`.Enum`
type then defines this using the  database value of a given enumeration.
The sorting scheme can be  also be redefined by passing a callable to the
:paramref:`.Enum.sort_key_function` parameter.  Pull request courtesy
Nicolas Caniart.

Fixes: #4285
Closes: #4816
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4816
Pull-request-sha: 42266b766c1e462d5b8a409cda05d33dea13bd34

Change-Id: Iadcc16173c1ba26ffac5830db57743a4cb987c55

5 years agoPGDialect.get_check_constraints: Handle "NOT VALID"
Bill Finn [Tue, 27 Aug 2019 16:21:57 +0000 (12:21 -0400)] 
PGDialect.get_check_constraints: Handle "NOT VALID"

Added support for reflection of CHECK constraints that include the special
PostgreSQL qualifier "NOT VALID", which can be present for CHECK
constraints that were added to an exsiting table with the directive that
they not be applied to existing data in the table. The PostgreSQL
dictionary for CHECK constraints as returned by
:meth:`.Inspector.get_check_constraints` may include an additional entry
``dialect_options`` which within will contain an entry ``"not_valid":
True`` if this symbol is detected.   Pull request courtesy Bill Finn.

Fixes: #4824
Closes: #4825
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4825
Pull-request-sha: a0e1ab133c2d46521a74e55423ac2ba866682dae

Change-Id: I78365f50055c95474c92124b85df66c5c80c00c8

5 years agoMerge "Serialize the context dictionary in Load objects"
mike bayer [Mon, 26 Aug 2019 20:50:56 +0000 (20:50 +0000)] 
Merge "Serialize the context dictionary in Load objects"

5 years agoSerialize the context dictionary in Load objects
Mike Bayer [Mon, 26 Aug 2019 15:44:09 +0000 (11:44 -0400)] 
Serialize the context dictionary in Load objects

Fixed bug where :class:`.Load` objects were not pickleable due to
mapper/relationship state in the internal context dictionary.  These
objects are now converted to picklable using similar techniques as that of
other elements within the loader option system that have long been
serializable.

Fixes: #4823
Change-Id: Id2a0d8b640ac475c86d6416ad540671e66d410e5

5 years agoMerge "Remove erroneous assertion from array._bind_param"
mike bayer [Mon, 26 Aug 2019 17:40:14 +0000 (17:40 +0000)] 
Merge "Remove erroneous assertion from array._bind_param"

5 years agoRemove erroneous assertion from array._bind_param
Mike Bayer [Mon, 26 Aug 2019 13:45:06 +0000 (09:45 -0400)] 
Remove erroneous assertion from array._bind_param

Fixed bug where Postgresql operators such as
:meth:`.postgresql.ARRAY.Comparator.contains` and
:meth:`.postgresql.ARRAY.Comparator.contained_by` would fail to function
correctly for non-integer values when used against a
:class:`.postgresql.array` object, due to an erroneous assert statement.

Fixes: #4822
Change-Id: I886aca4c86dc7d64e9d0dfc1d910a0ae64d775a1

5 years agoRun eager loaders on unexpire
Mike Bayer [Wed, 26 Apr 2017 22:50:05 +0000 (18:50 -0400)] 
Run eager loaders on unexpire

Eager loaders, such as joined loading, SELECT IN loading, etc., when
configured on a mapper or via query options will now be invoked during
the refresh on an expired object; in the case of selectinload and
subqueryload, since the additional load is for a single object only,
the "immediateload" scheme is used in these cases which resembles the
single-parent query emitted by lazy loading.

Change-Id: I7ca2c77bff58dc21015d60093a88c387937376b2
Fixes: #1763
5 years agobump variance on test_merge_load
Mike Bayer [Fri, 23 Aug 2019 14:55:33 +0000 (10:55 -0400)] 
bump variance on test_merge_load

This test is very sensitive and fluctuates a lot, failing builds,
bump the variance to try and resolve.

Change-Id: Ia19bb8871b432059cb3917ca0050a68f75c0a0f2

5 years agoMerge "Add hide_parameters flag to create_engine"
mike bayer [Thu, 22 Aug 2019 22:02:48 +0000 (22:02 +0000)] 
Merge "Add hide_parameters flag to create_engine"

5 years agoMerge "Ensure discarded collection removed from empty collections"
mike bayer [Thu, 22 Aug 2019 22:01:38 +0000 (22:01 +0000)] 
Merge "Ensure discarded collection removed from empty collections"

5 years agoEnsure discarded collection removed from empty collections
Mike Bayer [Thu, 22 Aug 2019 00:19:43 +0000 (20:19 -0400)] 
Ensure discarded collection removed from empty collections

A bulk replace operation was not attending to the previous
list still present in the "_empty_collections" dictionary
which was added as part of #4519.

Fixes: #4519
Change-Id: I3f99f8647c0fb8140b3dfb03686a5d3b90da633f

5 years agoRemove mock dependency
Mike Bayer [Thu, 22 Aug 2019 18:11:18 +0000 (14:11 -0400)] 
Remove mock dependency

Mock is not needed over python 3.3, we need this tox
requirement only for Python 2.7 right now.

Change-Id: I06ae31f9fe6eaece0ec508e9431e4f8166a59684

5 years agoAdd hide_parameters flag to create_engine
Mike Bayer [Wed, 21 Aug 2019 21:29:55 +0000 (17:29 -0400)] 
Add hide_parameters flag to create_engine

Added new parameter :paramref:`.create_engine.hide_parameters` which when
set to True will cause SQL parameters to no longer be logged, nor rendered
in the string representation of a :class:`.StatementError` object.

Fixes: #4815
Change-Id: Ib87f868b6936cf6b42b192644e9d732ec24266c2

5 years agoFix rst typo
Mike Bayer [Wed, 21 Aug 2019 20:55:32 +0000 (16:55 -0400)] 
Fix rst typo

The changelog for #4793 has a typo in the RST and didn't show up
in the changelog, causing confusion as seen in #4814

Change-Id: I5833097c1576120fbc2ea27c54bbca685ae89f88
References: #4793
References: #4814

5 years agoDocument how to work with reflection and custom datatypes
Mike Bayer [Tue, 20 Aug 2019 13:42:36 +0000 (09:42 -0400)] 
Document how to work with reflection and custom datatypes

Describe the link between table reflection, datatype lookups,
and what approaches are needed in the case where in-Python datatypes
are needed in the reflected table metadata.

Fixes: #4812
Change-Id: I68bef2bf472811797d4f5d9a625c6b9bca902f78

5 years agoMerge "Reflect PK of referred table if referred columns not present"
mike bayer [Mon, 19 Aug 2019 04:41:28 +0000 (04:41 +0000)] 
Merge "Reflect PK of referred table if referred columns not present"

5 years agoMerge "Revise psycopg2 execute_values approach"
mike bayer [Sun, 18 Aug 2019 20:36:48 +0000 (20:36 +0000)] 
Merge "Revise psycopg2 execute_values approach"

5 years agoReflect PK of referred table if referred columns not present
Mike Bayer [Sun, 18 Aug 2019 17:03:49 +0000 (13:03 -0400)] 
Reflect PK of referred table if referred columns not present

Fixed bug where a FOREIGN KEY that was set up to refer to the parent table
by table name only without the column names would not correctly be
reflected as far as setting up the "referred columns", since SQLite's
PRAGMA does not report on these columns if they weren't given explicitly.
For some reason this was harcoded to assume the name of the local column,
which might work for some cases but is not correct. The new approach
reflects the primary key of the referred table and uses the constraint
columns list as the referred columns list, if the remote column(s) aren't
present in the reflected pragma directly.

Fixes: #4810
Change-Id: I7789f83d68845ae197a782080af8ec64a7bf48cc

5 years agoRevise psycopg2 execute_values approach
Mike Bayer [Sat, 17 Aug 2019 02:38:51 +0000 (22:38 -0400)] 
Revise psycopg2 execute_values approach

Revised the approach for the just added support for the psycopg2
"execute_values()" feature added in 1.3.7 for :ticket:`4623`.  The approach
relied upon a regular expression that would fail to match for a more
complex INSERT statement such as one which had subqueries involved.   The
new approach matches exactly the string that was rendered as the VALUES
clause.

Fixes: #4623
Change-Id: Icaae0f7b6bcf87a2cf5c6290a839c8429dd5fac3

5 years agoAdd new "exec_once_unless_exception" system; apply to dialect.initialize
Mike Bayer [Fri, 16 Aug 2019 22:07:06 +0000 (18:07 -0400)] 
Add new "exec_once_unless_exception" system; apply to dialect.initialize

Fixed an issue whereby if the dialect "initialize" process which occurs on
first connect would encounter an unexpected exception, the initialize
process would fail to complete and then no longer attempt on subsequent
connection attempts, leaving the dialect in an un-initialized, or partially
initialized state, within the scope of parameters that need to be
established based on inspection of a live connection.   The "invoke once"
logic in the event system has been reworked to accommodate for this
occurrence using new, private API features that establish an "exec once"
hook that will continue to allow the initializer to fire off on subsequent
connections, until it completes without raising an exception. This does not
impact the behavior of the existing ``once=True`` flag within the event
system.

Fixes: #4807
Change-Id: Iec32999b61b6af4b38b6719e0c2651454619078c

5 years agocherry-pick changelog update for 1.3.8
Mike Bayer [Wed, 14 Aug 2019 17:54:28 +0000 (13:54 -0400)] 
cherry-pick changelog update for 1.3.8

5 years agocherry-pick changelog from 1.3.7
Mike Bayer [Wed, 14 Aug 2019 17:54:27 +0000 (13:54 -0400)] 
cherry-pick changelog from 1.3.7

5 years agoTurn on backend for new tests added for #4803
Mike Bayer [Wed, 14 Aug 2019 14:34:38 +0000 (10:34 -0400)] 
Turn on backend for new tests added for #4803

New tests added are failing on SQL Server which doesn't support
expressions in LIMIT, need better gerrit coverage

Fixes: #4803
Change-Id: I56bc44474d448a1faa1dfccff0b55763329e712d

5 years agoMerge "Add new executemany_mode, support for psycopg2.extras.execute_values()"
mike bayer [Wed, 14 Aug 2019 02:57:46 +0000 (02:57 +0000)] 
Merge "Add new executemany_mode, support for psycopg2.extras.execute_values()"

5 years agoAdd support for try_cast function on sqlalchemy.dialects.mssql
Leonel Atencio [Fri, 9 Aug 2019 21:16:13 +0000 (17:16 -0400)] 
Add support for try_cast  function on sqlalchemy.dialects.mssql

Added new :func:`.mssql.try_cast` construct for SQL Server which emits
"TRY_CAST" syntax.  Pull request courtesy Leonel Atencio.

Fixes: #4782
Closes: #4785
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4785
Pull-request-sha: cf13303a9d1c0cc0233a82a5d2ca01f438b6fb9b

Change-Id: I74a71ff5e587353f67472534aabe0d54ae8039ae

5 years ago- remove explicit doc for unique_connection as this has been removed
Mike Bayer [Mon, 12 Aug 2019 20:53:15 +0000 (16:53 -0400)] 
- remove explicit doc for unique_connection as this has been removed

Change-Id: I2febfd5fbe1e466adaff1e741652e3d1be78ecea

5 years agoAdd new executemany_mode, support for psycopg2.extras.execute_values()
Yuval Dinari [Mon, 12 Aug 2019 14:44:59 +0000 (10:44 -0400)] 
Add new executemany_mode, support for psycopg2.extras.execute_values()

Added new dialect flag for the psycopg2 dialect, ``executemany_mode`` which
supersedes the previous experimental ``use_batch_mode`` flag.
``executemany_mode`` supports both the "execute batch" and "execute values"
functions provided by psycopg2, the latter which is used for compiled
:func:`.insert` constructs.   Pull request courtesy Yuval Dinari.

.. seealso::

    :ref:`executemany_mode`

Fixes: #4623
Closes: #4764
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4764
Pull-request-sha: c3d3a36f7eb66c86d14ed9c1c31b4b48bd204855

Change-Id: I77e26ca729f9317af1488a6c054c23fa1a6b622b

5 years agoMerge "Use compat.string_types to check for visit name string"
mike bayer [Mon, 12 Aug 2019 14:42:52 +0000 (14:42 +0000)] 
Merge "Use compat.string_types to check for visit name string"

5 years agoMerge "Rewrite pool reset_on_return parsing using a util function"
mike bayer [Mon, 12 Aug 2019 14:42:25 +0000 (14:42 +0000)] 
Merge "Rewrite pool reset_on_return parsing using a util function"

5 years agoRewrite pool reset_on_return parsing using a util function
Mike Bayer [Sun, 11 Aug 2019 19:24:13 +0000 (15:24 -0400)] 
Rewrite pool reset_on_return parsing using a util function

Choosing a util.symbol() based on a user parameter is about to have
another use case added as part of #4623, so add a generalized solution
ahead of it.

Change-Id: I420631f81af2ffc655995b9cce9ff2ac618c16d7

5 years agoUse compat.string_types to check for visit name string
Mike Bayer [Mon, 12 Aug 2019 00:44:42 +0000 (20:44 -0400)] 
Use compat.string_types to check for visit name string

Th visitor optimization looking for plain string needs to
accommodate for u"" in Python 2 due to the unicode_literals
future.

Fixes: #4800
Change-Id: I5e3136f2f2cbd5f24d89186b599f59ea2e7f1550

5 years agoUse ternary when running conditional with Query._offset
Mike Bayer [Sun, 11 Aug 2019 14:54:49 +0000 (10:54 -0400)] 
Use ternary when running conditional with Query._offset

Fixed bug where using :meth:`.Query.first` or a slice expression in
conjunction with a query that has an expression based "offset" applied
would raise TypeError, due to an "or" conditional against "offset" that did
not expect it to be a SQL expression as opposed to an integer or None.

Fixes: #4803
Change-Id: I56b97a5d23cb45427a27a90ab557fa1ac5c6739e

5 years agoEmit SET NAMES for all MySQL connections w charset
Mike Bayer [Sun, 11 Aug 2019 21:42:59 +0000 (17:42 -0400)] 
Emit SET NAMES for all MySQL connections w charset

The MySQL dialects will emit "SET NAMES" at the start of a connection when
charset is given to the MySQL driver, to appease an apparent behavior
observed in MySQL 8.0 that raises a collation error when a UNION includes
string columns unioned against columns of the form CAST(NULL AS CHAR(..)),
which is what SQLAlchemy's polymorphic_union function does.   The issue
seems to have affected PyMySQL for at least a year, however has recently
appeared as of mysqlclient 1.4.4 based on changes in how this DBAPI creates
a connection.  As the presence of this directive impacts three separate
MySQL charset settings which each have intricate effects based on their
presense,  SQLAlchemy will now emit the directive on new connections to
ensure correct behavior.

Fixes: #4804
Change-Id: If9d7ee00d0ccaf773972b564fe455e8e9edf6627

5 years ago- shore up TypeDecorator docs a bit to not render tons of
Mike Bayer [Sun, 11 Aug 2019 02:20:31 +0000 (22:20 -0400)] 
- shore up TypeDecorator docs a bit to not render tons of
comparator methods

Change-Id: I8f434b18b2bd632a0db0db1376262944272d2198

5 years agoClarify INSERT/UPDATE defaults vs. data marshalling
Mike Bayer [Sat, 10 Aug 2019 22:17:59 +0000 (18:17 -0400)] 
Clarify INSERT/UPDATE defaults vs. data marshalling

- Add a full introductory paragraph to INSERT/UPDATE defaults
stating what we mean when we talk about this concept.  Add a note
differentiating what a default does, vs. a rule that intercepts
data as it moves into the database, providing links

- Add a quick section referring to TypeDecorator in the ORM
section on modifying attribute behavior

- Add an "ORM tip", a new thing that we can use in Core to link
to ORM concepts when useful, in the TypeDecorator section which
mentions that for more open ended conversion of arbitrary user
data based on business rules, @validates might be useful
(although this still does not suit the case of full blown form
validation).

- add glossary entries for DML, data marshalling since we already
use these terms and I'd like to refer to them more often.

Fixes: #4796
Change-Id: Ic4cd5c1595fd51c00a9bf24c021d2e56d457d346

5 years agoCorrect name for json_serializer / json_deserializer, document and test
Mike Bayer [Fri, 9 Aug 2019 03:34:20 +0000 (23:34 -0400)] 
Correct name for json_serializer / json_deserializer, document and test

The dialects that support json are supposed to take arguments
``json_serializer`` and ``json_deserializer`` at the create_engine() level,
however the SQLite dialect calls them ``_json_serilizer`` and
``_json_deserilalizer``.  The names have been corrected, the old names are
accepted with a change warning, and these parameters are now documented as
:paramref:`.create_engine.json_serializer` and
:paramref:`.create_engine.json_deserializer`.

Fixes: #4798
Change-Id: I1dbfe439b421fe9bb7ff3594ef455af8156f8851

5 years agoImplement checkfirst for Index.create(), Index.drop()
Mike Bayer [Tue, 6 Aug 2019 20:10:09 +0000 (16:10 -0400)] 
Implement checkfirst for Index.create(), Index.drop()

The :meth:`.Index.create` and :meth:`.Index.drop` methods now have a
parameter :paramref:`.Index.create.checkfirst`, in the same way as that of
:class:`.Table` and :class:`.Sequence`, which when enabled will cause the
operation to detect if the index exists (or not) before performing a create
or drop operation.

Fixes: #527
Change-Id: Idf994bc016359d0ae86cc64ccb20378115cb66d6

5 years agoMerge "Modernize internal reflection"
mike bayer [Wed, 7 Aug 2019 03:09:30 +0000 (03:09 +0000)] 
Merge "Modernize internal reflection"

5 years agoModernize internal reflection
Mike Bayer [Fri, 2 Aug 2019 16:34:16 +0000 (12:34 -0400)] 
Modernize internal reflection

- Deprecated remaining engine-level introspection and utility methods
including :meth:`.Engine.run_callable`, :meth:`.Engine.transaction`,
:meth:`.Engine.table_names`, :meth:`.Engine.has_table`.   The utility
methods are superseded by modern context-manager patterns, and the table
introspection tasks are suited by the :class:`.Inspector` object.

- The internal dialect method ``Dialect.reflecttable`` has been removed.  A
review of third party dialects has not found any making use of this method,
as it was already documented as one that should not be used by external
dialects.  Additionally, the private ``Engine._run_visitor`` method
is also removed.

- The long-deprecated ``Inspector.get_table_names.order_by`` parameter has
been removed.

- The :paramref:`.Table.autoload_with` parameter now accepts an :class:`.Inspector` object
directly, as well as any :class:`.Engine` or :class:`.Connection` as was the case before.

Fixes: #4755
Change-Id: Iec3a8b0f3e298ba87d532b16fac1e1132f464e21

5 years agoRemove threadlocal strategy docs, remaining contextual_connect
Mike Bayer [Mon, 5 Aug 2019 17:43:06 +0000 (13:43 -0400)] 
Remove threadlocal strategy docs, remaining contextual_connect

in dfb20f07d8, we merged the removal of the threadlocal strategy
from the 1.4 branch.   We forgot to take the docs out :).

Also, there seems to be an uncovered _contextual_connect call
in horizontal shard.  Cover that and repair.

Fixes: #4632
Closes: #4795
Change-Id: Id05cbbebe34a8f547c9c84369a929a2926c7d093

5 years agoMerge branch 'master--changelog13-typo' of https://github.com/nphilipp/sqlalchemy...
Mike Bayer [Mon, 5 Aug 2019 14:22:58 +0000 (10:22 -0400)] 
Merge branch 'master--changelog13-typo' of https://github.com/nphilipp/sqlalchemy into nphilipp-master--changelog13-typo

Change-Id: I5708624686ec752468038364cb2bdb5b1080c98c

5 years agoMerge "Strong reference listen function wrapped by "once""
mike bayer [Mon, 5 Aug 2019 02:51:40 +0000 (02:51 +0000)] 
Merge "Strong reference listen function wrapped by "once""

5 years agoStrong reference listen function wrapped by "once"
Mike Bayer [Sat, 3 Aug 2019 03:20:06 +0000 (23:20 -0400)] 
Strong reference listen function wrapped by "once"

Fixed issue in event system where using the ``once=True`` flag with
dynamically generated listener functions would cause event registration of
future events to fail if those listener functions were garbage collected
after they were used, due to an assumption that a listened function is
strongly referenced.  The "once" wrapped is now modified to strongly
reference the inner function persistently, and documentation is updated
that using "once" does not imply automatic de-registration of listener
functions.

Fixes: #4794
Change-Id: I06388083d1633dcc89e8919eb1e51270f966df38

5 years agoAlways include a schema name in SQLite PRAGMA
Mike Bayer [Fri, 2 Aug 2019 17:03:29 +0000 (13:03 -0400)] 
Always include a schema name in SQLite PRAGMA

Fixed bug where usage of "PRAGMA table_info" in SQLite dialect meant that
reflection features to detect for table existence, list of table columns,
and list of foreign keys, would default to any table in any attached
database, when no schema name was given and the table did not exist in the
base schema.  The fix explicitly runs PRAGMA for the 'main' schema and then
the 'temp' schema if the 'main' returned no rows, to maintain the behavior
of tables + temp tables in the "no schema" namespace, attached tables only
in the "schema" namespace.

Fixes: #4793
Change-Id: I75bc03ef42581c46b98987510d2d2e701df07412

5 years agoMerge "Add additional tests to verify _is_clone_of proxy level link"
mike bayer [Fri, 2 Aug 2019 14:35:08 +0000 (14:35 +0000)] 
Merge "Add additional tests to verify _is_clone_of proxy level link"

5 years agoAdd additional tests to verify _is_clone_of proxy level link
Mike Bayer [Thu, 1 Aug 2019 17:27:43 +0000 (13:27 -0400)] 
Add additional tests to verify _is_clone_of proxy level link

The commit message in 896d47f318c5c27620fd6da is not accurate,
we do in fact still need _is_clone_of when a clone of a column is
created so that we can implement _cloned_set().  Additionally,
the linkage of _is_clone_of within make_proxy() also suits
an additional use case that seems to be related to [ticket:2419].
Adjust one of the tests which likely got changed within 1.4's
refactoring of Select to test this correctly.

Change-Id: I124c7c6b02498e2dfad9797816df42a5b6f91901

5 years agoMerge "Remove threadlocal engine strategy, engine strategies pool threadlocal"
mike bayer [Thu, 1 Aug 2019 17:48:44 +0000 (17:48 +0000)] 
Merge "Remove threadlocal engine strategy, engine strategies pool threadlocal"

5 years agoDon't assume key when matching cloned columns in _make_proxy
Mike Bayer [Thu, 1 Aug 2019 15:45:34 +0000 (11:45 -0400)] 
Don't assume key when matching cloned columns in _make_proxy

Fixed issue where internal cloning of SELECT constructs could lead to a key
error if the copy of the SELECT changed its state such that its list of
columns changed.  This was observed to be occurring in some ORM scenarios
which may be unique to 1.3 and above, so is partially a regression fix.

For 1.4, the _is_clone_of key will be removed entirely as it seems to
have no purpose.  This commit is the initial backport to 1.3 which
includes tests.

Fixes: #4780
Change-Id: I0c64962a2eba3763bea3107fc7c7d7aed8244430

5 years agoMerge "Invoke column_expression() for subsequent SELECTs in CompoundSelect"
mike bayer [Tue, 30 Jul 2019 01:56:52 +0000 (01:56 +0000)] 
Merge "Invoke column_expression() for subsequent SELECTs in CompoundSelect"

5 years agoInvoke column_expression() for subsequent SELECTs in CompoundSelect
Mike Bayer [Mon, 29 Jul 2019 18:49:22 +0000 (14:49 -0400)] 
Invoke column_expression() for subsequent SELECTs in CompoundSelect

Fixed bug where :meth:`.TypeEngine.column_expression` method would not be
applied to subsequent SELECT statements inside of a UNION or other
:class:`.CompoundSelect`, even though the SELECT statements are rendered at
the topmost level of the statement.   New logic now differentiates between
rendering the column expression, which is needed for all SELECTs in the
list, vs. gathering the returned data type for the result row, which is
needed only for the first SELECT.

Fixes: #4787
Change-Id: Iceb63e430e76d2365649aa25ead09c4e2a062e10

5 years agoCorrect for MySQL 8.0 table and schema names in FK reflection
Mike Bayer [Mon, 29 Jul 2019 18:07:21 +0000 (14:07 -0400)] 
Correct for MySQL 8.0 table and schema names in FK reflection

Added another fix for an upstream MySQL 8 issue where a case sensitive
table name is reported incorrectly in foreign key constraint reflection,
this is an extension of the fix first added for :ticket:`4344` which
affects a case sensitive column name.  The new issue occurs through MySQL
8.0.17, so the general logic of the 88718 fix remains in place.

.. seealso::

    https://bugs.mysql.com/bug.php?id=96365 - upstream bug

Fixes: #4751
Change-Id: I391903565db919b85b6b3c62c28f4b90ee596135

6 years agoFix typo
Nils Philippsen [Sat, 27 Jul 2019 21:13:03 +0000 (23:13 +0200)] 
Fix typo

6 years agoMerge "Add ARRAY and MEMBER to MySQL reserved words"
mike bayer [Sat, 27 Jul 2019 17:56:39 +0000 (17:56 +0000)] 
Merge "Add ARRAY and MEMBER to MySQL reserved words"

6 years agoAdd ARRAY and MEMBER to MySQL reserved words
Mike Bayer [Sat, 27 Jul 2019 14:43:59 +0000 (10:43 -0400)] 
Add ARRAY and MEMBER to MySQL reserved words

Also sort the listing of reserved words.

Fixes: #4783
Change-Id: I8a7370a424d7c78efb4916d3307600b8e85f98ac

6 years agoEnsure all Index arguments are counted when matching expr/columns
Mike Bayer [Tue, 23 Jul 2019 22:38:48 +0000 (18:38 -0400)] 
Ensure all Index arguments are counted when matching expr/columns

Fixed issue where :class:`.Index` object which contained a mixture of
functional expressions which were not resolvable to a particular column,
in combination with string-based column names, would fail to initialize
its internal state correctly leading to failures during DDL compilation.

Fixes: #4778
Change-Id: I0fa9c627a1fde92ba8b9ed10af167c156012bd5d

6 years agoDon't assume m2o key is present in the dictionary
Mike Bayer [Tue, 23 Jul 2019 13:24:32 +0000 (09:24 -0400)] 
Don't assume m2o key is present in the dictionary

Fixed regression caused by new selectinload for many-to-one logic where
a primaryjoin condition not based on real foreign keys would cause
KeyError if a related object did not exist for a given key value on the
parent object.

Fixes: #4777
Change-Id: I4ba96318302be68abe0e8c3611684087a04a2322

6 years agocherry-pick changelog update for 1.3.7
Mike Bayer [Sun, 21 Jul 2019 21:10:02 +0000 (17:10 -0400)] 
cherry-pick changelog update for 1.3.7

6 years agocherry-pick changelog from 1.3.6
Mike Bayer [Sun, 21 Jul 2019 21:10:01 +0000 (17:10 -0400)] 
cherry-pick changelog from 1.3.6

6 years agoFix typos 4776/head
Min ho Kim [Sun, 21 Jul 2019 00:51:29 +0000 (10:51 +1000)] 
Fix typos

6 years agoMerge "Optimize out JOIN for selectinload with many to one"
mike bayer [Sat, 20 Jul 2019 01:46:42 +0000 (01:46 +0000)] 
Merge "Optimize out JOIN for selectinload with many to one"

6 years agoOptimize out JOIN for selectinload with many to one
Mike Bayer [Fri, 19 Jul 2019 17:05:06 +0000 (13:05 -0400)] 
Optimize out JOIN for selectinload with many to one

The optimzation applied to selectin loading in :ticket:`4340` where a JOIN
is not needed to eagerly load related items is now applied to many-to-one
relationships as well, so that only the related table is queried for a
simple join condition.   In this case, the related items are queried
based on the value of a foreign key column on the parent; if these columns
are deferred or otherwise not loaded on any of the parent objects in
the collection, the loader falls back to the JOIN method.

Fixes: #4775
Change-Id: I398e0d276789ce6e0019d213a37bdf99d24ec290

6 years agoMerge "Include 'p' for get_indexes() query"
mike bayer [Fri, 19 Jul 2019 20:24:23 +0000 (20:24 +0000)] 
Merge "Include 'p' for get_indexes() query"

6 years agoMerge "Support tuple IN VALUES for SQLite, others"
mike bayer [Fri, 19 Jul 2019 20:22:33 +0000 (20:22 +0000)] 
Merge "Support tuple IN VALUES for SQLite, others"

6 years agoInclude 'p' for get_indexes() query
Mike Bayer [Fri, 19 Jul 2019 14:40:27 +0000 (10:40 -0400)] 
Include 'p' for get_indexes() query

Added support for reflection of indexes on PostgreSQL partitioned tables,
which was added to PostgreSQL as of version 11.

Fixes: #4771
Change-Id: I9e8e75c4d8a667b4d52d12afbd384e0a8db00466

6 years agoSupport tuple IN VALUES for SQLite, others
Mike Bayer [Tue, 16 Jul 2019 16:41:09 +0000 (12:41 -0400)] 
Support tuple IN VALUES for SQLite, others

Added support for composite (tuple) IN operators with SQLite, by rendering
the VALUES keyword for this backend.  As other backends such as DB2 are
known to use the same syntax, the syntax is enabled in the base compiler
using a dialect-level flag ``tuple_in_values``.   The change also includes
support for "empty IN tuple" expressions for SQLite when using "in_()"
between a tuple value and an empty set.

Fixes: #4766
Change-Id: I416e1af29b31d78f9ae06ec3c3a48ef6d6e813f5

6 years agoMerge "Fixes for uselist=True with m2o relationships"
mike bayer [Thu, 18 Jul 2019 16:55:22 +0000 (16:55 +0000)] 
Merge "Fixes for uselist=True with m2o relationships"

6 years agoFix regression for self-ref join to self error message
Mike Bayer [Thu, 18 Jul 2019 15:12:49 +0000 (11:12 -0400)] 
Fix regression for self-ref join to self error message

Fixed regression caused by :ticket:`4365` where a join from an entity to
itself without using aliases no longer raises an informative error message,
instead failing on an assertion.  The informative error condition has been
restored.

Fixes: #4773
Change-Id: Iabeb56f3f0c2a40e350fd7c69f07c02dc9804c2c

6 years agoFixes for uselist=True with m2o relationships
Mike Bayer [Thu, 18 Jul 2019 14:58:24 +0000 (10:58 -0400)] 
Fixes for uselist=True with m2o relationships

Fixed bug where a many-to-one relationship that specified ``uselist=True``
would fail to update correctly during a primary key change where a related
column needs to change.

Fixed bug where the detection for many-to-one or one-to-one use with a
"dynamic" relationship, which is an invalid configuration, would fail to
raise if the relationship were configured with ``uselist=True``.  The
current fix is that it warns, instead of raises, as this would otherwise be
backwards incompatible, however in a future release it will be a raise.

Fixes: #4772
Change-Id: Ibd5d2f7329ff245c88118e2533fc8ef42a09fef3

6 years agoMerge remote-tracking branch 'origin/pr/4769'
Mike Bayer [Thu, 18 Jul 2019 00:50:24 +0000 (20:50 -0400)] 
Merge remote-tracking branch 'origin/pr/4769'

Change-Id: I7cf3c4c175c0f616cb167c6a89b1591be8210aec

6 years agoMerge remote-tracking branch 'origin/pr/4770'
Mike Bayer [Thu, 18 Jul 2019 00:47:17 +0000 (20:47 -0400)] 
Merge remote-tracking branch 'origin/pr/4770'

Change-Id: Id0c21bc54fb370fc2e0fc01da211f2d3455af2fc

6 years agoFix doc for #4765 4770/head
Denis Kataev [Wed, 17 Jul 2019 16:02:53 +0000 (21:02 +0500)] 
Fix doc for #4765

6 years agoIntercept unresolveable comparator attrbute error for attr access
Mike Bayer [Tue, 16 Jul 2019 17:02:16 +0000 (13:02 -0400)] 
Intercept unresolveable comparator attrbute error for attr access

Fixed bug where a synonym created against a mapped attribute that does not
exist yet, as is the case when it refers to backref before mappers are
configured, would raise recursion errors when trying to test for attributes
on it which ultimately don't exist (as occurs when the classes are run
through Sphinx autodoc), as the unconfigured state of the synonym would put
it into an attribute not found loop.

Fixes: #4767
Change-Id: I9aade8628349fbf538181a0049416cec0a17179c

6 years agoPin pycodestyle
Mike Bayer [Wed, 17 Jul 2019 14:40:03 +0000 (10:40 -0400)] 
Pin pycodestyle

PyCQA/pydocstyle#375

Change-Id: Ifc7ead440010e89474300407fea5770956ff1aaf

6 years agoRemove threadlocal engine strategy, engine strategies pool threadlocal
Mike Bayer [Thu, 11 Apr 2019 18:21:13 +0000 (14:21 -0400)] 
Remove threadlocal engine strategy, engine strategies pool threadlocal

The "threadlocal" execution strategy, deprecated in 1.3, has been
removed for 1.4, as well as the concept of "engine strategies" and the
``Engine.contextual_connect`` method.  The "strategy='mock'" keyword
argument is still accepted for now with a deprecation warning; use
:func:`.create_mock_engine` instead for this use case.

Fixes: #4632
Change-Id: I8a351f9fa1f7dfa2a56eec1cd2d1a4b9d65765a2
(cherry picked from commit b368c49b44c5716d93c7428ab22b6761c6ca7cf5)

6 years agoSyntaxError in on_duplicate_key_update() example. 4761/head
Peter Schutt [Mon, 15 Jul 2019 03:51:28 +0000 (13:51 +1000)] 
SyntaxError in on_duplicate_key_update() example.

6 years agoAdd profile sort option to test suite
Mike Bayer [Sun, 14 Jul 2019 15:43:29 +0000 (11:43 -0400)] 
Add profile sort option to test suite

I use the nfl sort a lot to see what calling changes are happening
between two versions in order to identify the offending code, so
add it as a command line option.

Change-Id: Ia1ab6dd98012a78298b325bb5c7c050fa9b767c2

6 years agoself_group() for FunctionFilter
Mike Bayer [Sat, 13 Jul 2019 02:43:31 +0000 (22:43 -0400)] 
self_group() for FunctionFilter

Fixed issue where the :class:`.array_agg` construct in combination with
:meth:`.FunctionElement.filter` would not produce the correct operator
precedence between the FILTER keyword and the array index operator.

Fixes: #4760
Change-Id: Ic662cd3da3330554ec673bafd80495b3f1506098

6 years agoAllow duplicate columns in from clauses and selectables
Mike Bayer [Sun, 7 Jul 2019 15:12:31 +0000 (11:12 -0400)] 
Allow duplicate columns in from clauses and selectables

The :func:`.select` construct and related constructs now allow for
duplication of column labels and columns themselves in the columns clause,
mirroring exactly how column expressions were passed in.   This allows
the tuples returned by an executed result to match what was SELECTed
for in the first place, which is how the ORM :class:`.Query` works, so
this establishes better cross-compatibility between the two constructs.
Additionally, it allows column-positioning-sensitive structures such as
UNIONs (i.e. :class:`.CompoundSelect`) to be more intuitively constructed
in those cases where a particular column might appear in more than one
place.   To support this change, the :class:`.ColumnCollection` has been
revised to support duplicate columns as well as to allow integer index
access.

Fixes: #4753
Change-Id: Ie09a8116f05c367995c1e43623c51e07971d3bf0

6 years agoMerge "profiling plugin fixes"
mike bayer [Thu, 11 Jul 2019 16:56:54 +0000 (16:56 +0000)] 
Merge "profiling plugin fixes"

6 years agoMerge "Add performance improvement for Enum w/ Python 2 enum library"
mike bayer [Thu, 11 Jul 2019 16:20:17 +0000 (16:20 +0000)] 
Merge "Add performance improvement for Enum w/ Python 2 enum library"

6 years agoprofiling plugin fixes
Mike Bayer [Thu, 11 Jul 2019 15:56:54 +0000 (11:56 -0400)] 
profiling plugin fixes

support that we have pytest-xdist arguments now,
as well as allow force-write to reset the list of callcounts which
seem to accumulate commas for some reason

Change-Id: I54dd164c21ffbb9139937d5c3ffb1df7e9598594

6 years agoAdd performance improvement for Enum w/ Python 2 enum library
Mike Bayer [Wed, 10 Jul 2019 20:12:48 +0000 (16:12 -0400)] 
Add performance improvement for Enum w/ Python 2 enum library

Adjusted the initialization for :class:`.Enum` to minimize how often it
invokes the ``.__members__`` attribute of a given PEP-435 enumeration
object, to suit the case where this attribute is expensive to invoke, as is
the case for some popular third party enumeration libraries.

Fixes: #4758
Change-Id: Iffeb854c67393bdcb288944fc357a074e20e1325

6 years agoMerge "Support multidimensional array literals in Postgresql"
mike bayer [Mon, 8 Jul 2019 21:38:11 +0000 (21:38 +0000)] 
Merge "Support multidimensional array literals in Postgresql"

6 years agoSupport multidimensional array literals in Postgresql
Mike Bayer [Mon, 8 Jul 2019 19:46:35 +0000 (15:46 -0400)] 
Support multidimensional array literals in Postgresql

Added support for multidimensional Postgresql array literals via nesting
the :class:`.postgresql.array` object within another one.  The
multidimensional array type is detected automatically.

Fixes: #4756
Change-Id: Ie2107ad3cf291112f6ca330dc90dc15a0a940cee

6 years agoSmall text error in json field doc 4769/head
Denis Kataev [Mon, 8 Jul 2019 16:32:20 +0000 (21:32 +0500)] 
Small text error in json field doc

Small fix json field doc

6 years agoEnsure .engine is part of Connectable interface, implement as descriptor
Mike Bayer [Mon, 8 Jul 2019 14:42:20 +0000 (10:42 -0400)] 
Ensure .engine is part of Connectable interface, implement as descriptor

Fixed bug where using reflection function such as :meth:`.MetaData.reflect`
with an :class:`.Engine` object that had execution options applied to it
would fail, as the resulting :class:`.OptionEngine` proxy object failed to
include a ``.engine`` attribute used within the reflection routines.

Fixes: #4754
Change-Id: I6c342af5c6db6fe362b9d25f3f26d6859f62f87a

6 years agoclass level docstring for Subquery
Mike Bayer [Sat, 6 Jul 2019 19:47:16 +0000 (15:47 -0400)] 
class level docstring for Subquery

Remove inherited member doc from most selectables, it's too verbose

Change-Id: I1b6635fe73342705846c0fab635b46557e560734

6 years agoMerge "SelectBase no longer a FromClause"
mike bayer [Sat, 6 Jul 2019 19:24:49 +0000 (19:24 +0000)] 
Merge "SelectBase no longer a FromClause"

6 years agoSelectBase no longer a FromClause
Mike Bayer [Thu, 13 Jun 2019 16:37:22 +0000 (12:37 -0400)] 
SelectBase no longer a FromClause

As part of the SQLAlchemy 2.0 migration project, a conceptual change has
been made to the role of the :class:`.SelectBase` class hierarchy,
which is the root of all "SELECT" statement constructs, in that they no
longer serve directly as FROM clauses, that is, they no longer subclass
:class:`.FromClause`.  For end users, the change mostly means that any
placement of a :func:`.select` construct in the FROM clause of another
:func:`.select` requires first that it be wrapped in a subquery first,
which historically is through the use of the :meth:`.SelectBase.alias`
method, and is now also available through the use of
:meth:`.SelectBase.subquery`.    This was usually a requirement in any
case since several databases don't accept unnamed SELECT subqueries
in their FROM clause in any case.

See the documentation in this change for lots more detail.

Fixes: #4617
Change-Id: I0f6174ee24b9a1a4529168e52e855e12abd60667

6 years agotarget issue #4336 at 1.4 release
Mike Bayer [Sat, 6 Jul 2019 13:57:58 +0000 (09:57 -0400)] 
target issue #4336 at 1.4 release

Change-Id: I96acdf2285ebec067ca6128b03d47776533caac0

6 years agoRepair json example in tutorial to suit non-present sqlite support
Mike Bayer [Fri, 5 Jul 2019 22:11:31 +0000 (18:11 -0400)] 
Repair json example in tutorial to suit non-present sqlite support

SQLite on CI doesn't have json functions (centos) so even
though SQLAlchemy supports it in this version, use the MySQL
compiler for the example.

Change-Id: If896273adbab2e3fdb995272f6e55de420aee220

6 years agoAdjust JSON verbiage about "implied" datatype
Mike Bayer [Fri, 5 Jul 2019 20:16:22 +0000 (16:16 -0400)] 
Adjust JSON verbiage about "implied" datatype

SQLite and MariaDB (not MySQL) has an "implied" JSON,
MySQL has it directly

Change-Id: I2e1744de96ac4e241dc647ae2214b63cdad33428

6 years agoRename tutorial section to "Using Aliases and Subqueries"
Mike Bayer [Fri, 5 Jul 2019 19:55:20 +0000 (15:55 -0400)] 
Rename tutorial section to "Using Aliases and Subqueries"

add some verbiage to start differentiating a subquery from
an alias.

Also, get rid of a very strange note to use ``.correlate(None)``
on a non-scalar subquery; this is unnecessary and confusing.

Change-Id: I83b2fd1275c719a32bb74060756d61bc51b52892

6 years agoNote DBAPIs and dialects that we don't support
Mike Bayer [Fri, 5 Jul 2019 16:19:55 +0000 (12:19 -0400)] 
Note DBAPIs and dialects that we don't support

Since we have strong CI for the DBAPIs and dialects that are actively
supported, this indicates that those DBAPIs that aren't in CI are
continuing to fall behind in support, to the point where we can
not address issues that may arise. As such, the Sybase and Firebird
dialects overall are moving into an explicit "not supported" zone
where we would like to eventually remove them.   Additionally,
a pass is made through legacy MySQL and PostgreSQL DBAPI dialects
as well as those which we aren't able to include in CI to note
that these DBAPIs aren't actively supported by the project.

Change-Id: I61f1515b97b741b7534b54e434e3e47065df7b5d