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.
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.
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.
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`.
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.
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`.
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.
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`.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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``.
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.
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.
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.
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.
Mike Bayer [Sat, 14 Jul 2018 16:26:29 +0000 (12:26 -0400)]
Don't apply no-traverse to query.statement
Fixed long-standing issue in :class:`.Query` where a scalar subquery such
as produced by :meth:`.Query.exists`, :meth:`.Query.as_scalar` and other
derivations from :attr:`.Query.statement` would not correctly be adapted
when used in a new :class:`.Query` that required entity adaptation, such as
when the query were turned into a union, or a from_self(), etc. The change
removes the "no adaptation" annotation from the :func:`.select` object
produced by the :attr:`.Query.statement` accessor.
Mike Bayer [Fri, 13 Jul 2018 16:58:21 +0000 (12:58 -0400)]
Use exprs for bundle __clause_element__
Fixed bug in :class:`.Bundle` construct where placing two columns of the
same name would be de-duplicated, when the :class:`.Bundle` were used as
part of the rendered SQL, such as in the ORDER BY or GROUP BY of the statement.
Mike Bayer [Wed, 28 Feb 2018 16:50:17 +0000 (11:50 -0500)]
Don't null FK for collection-removed item with passive_deletes='all'
Fixed issue regarding passive_deletes="all", where the foreign key
attribute of an object is maintained with its value even after the object
is removed from its parent collection. Previously, the unit of work would
set this to NULL even though passive_deletes indicated it should not be
modified.
Mike Bayer [Wed, 11 Jul 2018 03:47:05 +0000 (23:47 -0400)]
Add pyodbc fast_executemany
Added ``fast_executemany=True`` parameter to the SQL Server pyodbc dialect,
which enables use of pyodbc's new performance feature of the same name
when using Microsoft ODBC drivers.
Mike Bayer [Tue, 10 Jul 2018 13:41:21 +0000 (09:41 -0400)]
Drop default-related structures after the Table is dropped.
Fixed bug where a :class:`.Sequence` would be dropped explicitly before any
:class:`.Table` that refers to it, which breaks in the case when the
sequence is also involved in a server-side default for that table, when
using :meth:`.MetaData.drop_all`. The step which processes sequences
to be dropped via non server-side column default functions is now invoked
after the table itself is dropped.
Ilja Everilä [Thu, 15 Mar 2018 14:18:13 +0000 (10:18 -0400)]
Sqlite json
Added support for SQLite's json functionality via the new
SQLite implementation for :class:`.sqltypes.JSON`, :class:`.sqlite.JSON`.
The name used for the type is ``JSON``, following an example found at
SQLite's own documentation. Pull request courtesy Ilja Everilä.
Mike Bayer [Tue, 10 Jul 2018 21:00:21 +0000 (17:00 -0400)]
Add all "like", "between", "is" operators as comparison operators
Added "like" based operators as "comparison" operators, including
:meth:`.ColumnOperators.startswith` :meth:`.ColumnOperators.endswith`
:meth:`.ColumnOperators.ilike` :meth:`.ColumnOperators.notilike` among many
others, so that all of these operators can be the basis for an ORM
"primaryjoin" condition.
Mike Bayer [Mon, 9 Jul 2018 19:47:14 +0000 (15:47 -0400)]
support functions "as binary comparison"
Added new feature :meth:`.FunctionElement.as_comparison` which allows a SQL
function to act as a binary comparison operation that can work within the
ORM.
Mike Bayer [Mon, 9 Jul 2018 22:24:12 +0000 (18:24 -0400)]
Expire memoizations on setattr/delattr, check in delattr
Fixed bug where declarative would not update the state of the
:class:`.Mapper` as far as what attributes were present, when additional
attributes were added or removed after the mapper attribute collections had
already been called and memoized. Addtionally, a ``NotImplementedError``
is now raised if a fully mapped attribute (e.g. column, relationship, etc.)
is deleted from a class that is currently mapped, since the mapper will not
function correctly if the attribute has been removed.
Mike Bayer [Wed, 13 Jun 2018 20:19:23 +0000 (16:19 -0400)]
Refactor pool.py into a package
for better separation of concerns split out the
core pooling constructs from the implementations. also
makes more room for new pool classes should we decide to
add them. The DBProxy feature is never used so remove it
from documentation and split it out.
Mike Bayer [Sun, 8 Jul 2018 23:10:36 +0000 (19:10 -0400)]
Check tokens in chop path for inspectionattr before calling is_mapper
Fixed regression in 1.2.9 due to :ticket:`4287` where using a
:class::`.Load` option in conjunction with a string wildcard would result
in a TypeError.
Sean Dunn [Fri, 29 Jun 2018 14:26:57 +0000 (10:26 -0400)]
Add unique_constraint_name to MSSQL FK reflection
Fixed bug in MSSQL reflection where when two same-named tables in different
schemas had same-named primary key constraints, foreign key constraints
referring to one of the tables would have their columns doubled, causing
errors. Pull request courtesy Sean Dunn.
Mike Bayer [Thu, 28 Jun 2018 18:33:14 +0000 (14:33 -0400)]
Reflect ASC/DESC in MySQL index columns
Fixed bug in index reflection where on MySQL 8.0 an index that includes
ASC or DESC in an indexed column specfication would not be correctly
reflected, as MySQL 8.0 introduces support for returning this information
in a table definition string.
Mike Bayer [Thu, 28 Jun 2018 15:49:02 +0000 (11:49 -0400)]
Vendor python3 formatargspec
Replaced the usage of inspect.formatargspec() with a vendored version
copied from the Python standard library, as inspect.formatargspec()
is deprecated and as of Python 3.7.0 is emitting a warning.
Mike Bayer [Wed, 27 Jun 2018 20:08:23 +0000 (16:08 -0400)]
Try to get mysqlconnector somewhat working
Add CI support for MySQL connector and try to fix some of the
more obvious issues. CI tests will run against MySQL 5.7
only for starters as there appear to be issues with
MySQL 8.0
Mike Bayer [Tue, 26 Jun 2018 20:53:51 +0000 (16:53 -0400)]
Add do_setinputsizes event for cx_Oracle
Added a new event currently used only by the cx_Oracle dialect,
:meth:`.DialectEvents.setiputsizes`. The event passes a dictionary of
:class:`.BindParameter` objects to DBAPI-specific type objects that will be
passed, after conversion to parameter names, to the cx_Oracle
``cursor.setinputsizes()`` method. This allows both visibility into the
setinputsizes process as well as the ability to alter the behavior of what
datatypes are passed to this method.
Mike Bayer [Mon, 25 Jun 2018 02:50:06 +0000 (22:50 -0400)]
Ensure BakedQuery is cloned before we add options to it
Fixed bug in new polymorphic selectin loading where the BakedQuery used
internally would be mutated by the given loader options, which would both
inappropriately mutate the subclass query as well as carry over the effect
to subsequent queries.
Mike Bayer [Wed, 13 Jun 2018 22:13:21 +0000 (18:13 -0400)]
Look up adapter info for previous left side in chained query.join()
Fixed issue where chaining multiple join elements inside of
:meth:`.Query.join` might not correctly adapt to the previous left-hand
side, when chaining joined inheritance classes that share the same base
class.
Nils Philippsen [Sun, 24 Jun 2018 15:47:05 +0000 (11:47 -0400)]
fix TypeReflectionTest for sqlite 3.24
Fixed issue in test suite where SQLite 3.24 added a new reserved word that
conflicted with a usage in TypeReflectionTest. Pull request courtesy Nils
Philippsen.