Daniel Thorell [Fri, 20 Oct 2017 16:59:55 +0000 (12:59 -0400)]
Remove deprecation warnings mysql5 7 20
MySQL 5.7.20 now warns for use of the @tx_isolation variable; a version
check is now performed and uses @transaction_isolation instead
to prevent this warning.
Mike Bayer [Fri, 20 Oct 2017 18:34:16 +0000 (14:34 -0400)]
Resolve AliasedClass when determining owning class of association proxy
Fixed bug where the association proxy would inadvertently link itself
to an :class:`.AliasedClass` object if it were called first with
the :class:`.AliasedClass` as a parent, causing errors upon subsequent
usage.
Mike Bayer [Thu, 19 Oct 2017 01:17:00 +0000 (21:17 -0400)]
Don't commit failed transaction
The test here commits even though integrityerror
was raised due to the fixture. Postgresql seems to allow
this even though it's usually strict about this. remove
the requirement that a database needs to be able to
commit after an integrity error was raised.
Jan [Wed, 18 Oct 2017 01:23:19 +0000 (21:23 -0400)]
add order_by clause to make tests stable
I observed test runs that failed on 'test_bound_in_scalar' due to arbitrary ordering of the result set. The assertion not only tests for the elements to be present, but also for the correct ordering. Hence, the proposal to add an order_by clause to the select statements.
Mike Bayer [Wed, 11 Oct 2017 21:56:14 +0000 (17:56 -0400)]
Disallow all ambiguous boolean values for Boolean
In release 1.1, the :class:`.Boolean` type was broken in that
boolean coercion via ``bool()`` would occur for backends that did not
feature "native boolean", but would not occur for native boolean backends,
meaning the string ``"0"`` now behaved inconsistently. After a poll, a
consensus was reached that non-boolean values should be raising an error,
especially in the ambiguous case of string ``"0"``; so the :class:`.Boolean`
datatype will now raise ``ValueError`` if an incoming value is not
within the range ``None, True, False, 1, 0``.
Mike Bayer [Tue, 10 Oct 2017 17:33:59 +0000 (13:33 -0400)]
Add fast execution helper support.
Added a new flag ``use_batch_mode`` to the psycopg2 dialect. This flag
enables the use of psycopg2's ``psycopg2.extras.execute_batch``
extension when the :class:`.Engine` calls upon ``cursor.executemany()``.
This extension provides a critical performance increase by over an order of magnitude
when running INSERT statements in batch. The flag is False by default
as it is considered to be experimental for now.
Mike Bayer [Fri, 6 Oct 2017 15:14:29 +0000 (11:14 -0400)]
Fix array_agg to accommodate ARRAY arguments
Fixed bug in :func:`.array_agg` function where passing an argument
that is already of type :class:`.ARRAY`, such as a Postgresql
:obj:`.postgresql.array` construct, would produce a ``ValueError``, due
to the function attempting to nest the arrays.
Mike Bayer [Thu, 5 Oct 2017 15:25:10 +0000 (11:25 -0400)]
Don't include SelectBase when searching for surface column elements
Fixed bug where correlated select used against single-table inheritance
entity would fail to render correctly in the outer query, due to adjustment
for single inheritance discriminator criteria inappropriately re-applying
the criteria to the outer query.
Mike Bayer [Mon, 2 Oct 2017 19:52:46 +0000 (15:52 -0400)]
Add SQL Server TIMESTAMP / ROWVERSION datatypes
SQL Server has an entirely different use for the TIMESTAMP
datatype that is unrelated to the SQL standard's version of this
type. It is a read-only type that returns an incrementing
binary value. The ROWVERSION name will supersede the TIMESTAMP
name. Implement datatype objects for both, separate from the
base DateTime/TIMESTAMP class hierarchy, and also implement
an optional integer coercion feature.
Mike Bayer [Tue, 3 Oct 2017 00:50:56 +0000 (20:50 -0400)]
Improve check for overlapping FK targets on sibling classes
Fixed bug where ORM relationship would warn against conflicting sync
targets (e.g. two relationships would both write to the same column) for
sibling classes in an inheritance hierarchy, where the two relationships
would never actually conflict during writes.
Mike Bayer [Mon, 2 Oct 2017 15:50:05 +0000 (11:50 -0400)]
Support pg10
One test appears to use some awkward calling style
with the current_date function that isn't working in pg10
anymore, this looks like an extremely
old test that can be removed
Mike Bayer [Sat, 19 Aug 2017 22:39:08 +0000 (18:39 -0400)]
Support mariadb 10.2
Fixed issue where CURRENT_TIMESTAMP would not reflect correctly
in the MariaDB 10.2 series due to a syntax change, where the function
is now represented as ``current_timestamp()``.
Fixes: #4096
MariaDB 10.2 now supports CHECK constraints (warning: use version 10.2.9
or greater due to upstream issues noted in :ticket:`4097`). Reflection
now takes these CHECK constraints into account when they are present in
the ``SHOW CREATE TABLE`` output.
Mike Bayer [Thu, 28 Sep 2017 20:47:28 +0000 (16:47 -0400)]
Take schema name into account when querying sqlite_master
Fixed bug where SQLite CHECK constraint reflection would fail
if the referenced table were in a remote schema, e.g. on SQLite a
remote database referred to by ATTACH.
Also add suite support for general CHECK constraint reflection.
Mike Bayer [Thu, 28 Sep 2017 16:31:54 +0000 (12:31 -0400)]
Warn for mariadb 10.2 < 9
There's a few CHECK constraint issues we managed
to get resolved as of MariaDB 10.2.8 then 10.2.9. They
are pretty severe so warn users for these particular mariadb
versions.
Mike Bayer [Wed, 27 Sep 2017 14:14:57 +0000 (10:14 -0400)]
Support method form of any_(), all_()
Fixed bug where the recently added :meth:`.ColumnOperators.any_`
and :meth:`.ColumnOperators.all_` methods didn't work when called
as methods, as opposed to using the standalone functions
:func:`~.expression.any_` and :func:`~.expression.all_`. Also
added documentation examples for these relatively unintuitive
SQL operators.
Mike Bayer [Wed, 27 Sep 2017 13:48:17 +0000 (09:48 -0400)]
Accomodate for multidimensional array in rewriting for COLLATE
Made further fixes to the :class:`.ARRAY` class in conjunction with
COLLATE, as the fix made in :ticket:`4006` failed to accommodate
for a multidimentional array.
Mike Bayer [Tue, 26 Sep 2017 19:33:04 +0000 (15:33 -0400)]
Don't expire "deferred" attributes in make_transient_to_detached
Fixed issue where the :func:`.make_transient_to_detached` function
would expire all attributes on the target object, including "deferred"
attributes, which has the effect of the attribute being undeferred
for the next refesh, causing an unexpected load of the attribute.
Mike Bayer [Tue, 26 Sep 2017 00:00:20 +0000 (20:00 -0400)]
Document and test __table_cls__
A use case has been identified for __table_cls__, which was
added in 1.0 just for the purpose of test fixtures. Add this to
public API and ensure the target use case (conditional table generation)
stays supported.
Mike Bayer [Tue, 26 Sep 2017 15:03:07 +0000 (11:03 -0400)]
Warnings for @declared_attr.cascading
A warning is emitted if a subclass attempts to override an attribute
that was declared on a superclass using ``@declared_attr.cascading``
that the overridden attribute will be ignored. This use
case cannot be fully supported down to further subclasses without more
complex development efforts, so for consistency the "cascading" is
honored all the way down regardless of overriding attributes.
A warning is emitted if the ``@declared_attr.cascading`` attribute is
used with a special declarative name such as ``__tablename__``, as this
has no effect.
Ensure that documenation refers to the current inconsistency that
__tablename__ can be overridden by subclasses however
@declared_attr.cascading cannot.
Mike Bayer [Sat, 23 Sep 2017 16:19:56 +0000 (12:19 -0400)]
Make a common approach for "emulated" types
Internal refinements to the :class:`.Enum`, :class:`.Interval`, and
:class:`.Boolean` types, which now extend a common mixin
:class:`.Emulated` that indicates a type that provides Python-side
emulation of a DB native type, switching out to the DB native type when a
supporting backend is in use. The Postgresql :class:`.INTERVAL` type
when used directly will now include the correct type coercion rules for
SQL expressions that also take effect for :class:`.sqltypes.Interval`
(such as adding a date to an interval yields a datetime).
Mike Bayer [Wed, 13 Sep 2017 15:39:47 +0000 (11:39 -0400)]
Add multivalued insert context for defaults
Added a new method :class:`.DefaultExecutionContext.current_parameters`
which is used within a function-based default value generator in
order to retrieve the current parameters being passed to the statement.
The new function differs from the ``.current_parameters`` attribute in
that it also provides for optional grouping of parameters that
correspond to a multi-valued "insert" construct. Previously it was not
possible to identify the subset of parameters that were relevant to
the function call.
Mike Bayer [Fri, 15 Sep 2017 15:14:36 +0000 (11:14 -0400)]
Add __next__(), next() to ResultProxy
Added ``__next__()`` and ``next()`` methods to :class:`.ResultProxy`,
so that the ``next()`` builtin function works on the object directly.
:class:`.ResultProxy` has long had an ``__iter__()`` method which already
allows it to respond to the ``iter()`` builtin. The implementation
for ``__iter__()`` is unchanged, as performance testing has indicated
that iteration using a ``__next__()`` method with ``StopIteration``
is about 20% slower in both Python 2.7 and 3.6.
Mike Bayer [Wed, 13 Sep 2017 18:53:29 +0000 (14:53 -0400)]
Ensure (+) is rendered for all right-hand members
Fixed bug where Oracle 8 "non ansi" join mode would not add the
``(+)`` operator to expressions that used an operator other than the
``=`` operator. The ``(+)`` needs to be on all columns that are part
of the right-hand side.
Mike Bayer [Tue, 12 Sep 2017 16:57:40 +0000 (12:57 -0400)]
use the stack to get the insert statement in on conflict
Fixed bug in Postgresql :meth:`.postgresql.dml.Insert.on_conflict_do_update`
which would prevent the insert statement from being used as a CTE,
e.g. via :meth:`.Insert.cte`, within another statement.
Mike Bayer [Sun, 10 Sep 2017 04:01:18 +0000 (00:01 -0400)]
Warn instead of raise for unmapped column that matches on key
Modified the change made to the ORM update/delete evaluator in
:ticket:`3366` such that if an unmapped column expression is present
in the update or delete, if the evaluator can match its name to the
mapped columns of the target class, a warning is emitted, rather than
raising UnevaluatableError. This is essentially the pre-1.2 behavior,
and is to allow migration for applications that are currently relying
upon this pattern. However, if the given attribute name cannot be
matched to the columns of the mapper, the UnevaluatableError is
still raised, which is what was fixed in :ticket:`3366`.
Mike Bayer [Fri, 8 Sep 2017 00:38:00 +0000 (20:38 -0400)]
Remove LRU warnings
Removed the warnings that are emitted when the LRU caches employed
by the mapper as well as loader srtategies reach their threshold; the
purpose of this warning was at first a guard against excess cache keys
being generated but became basically a check on the "creating many
engines" antipattern. While this is still an antipattern, the presense
of test suites which both create an engine per test as well as raise
on all warnings will be an inconvenience; it should not be critical
that such test suites change their architecture just for this warning
(though engine-per-test suite is always better).
Mike Bayer [Sat, 9 Sep 2017 01:34:39 +0000 (21:34 -0400)]
Rename MySQL dml.insert().values to .inserted
Changed the name of the ``.values`` attribute of the new MySQL
INSERT..ON DUPLICATE KEY UPDATE construct to ``.inserted``, as
:class:`.Insert` already has a method called :meth:`.Insert.values`.
The ``.inserted`` attribute ultimately renders the MySQL ``VALUES()``
function.
Mike Bayer [Mon, 4 Sep 2017 16:11:19 +0000 (12:11 -0400)]
Guard against KeyError in session.merge after check for identity
Fixed bug in :meth:`.Session.merge` following along similar lines as that
of :ticket:`4030`, where an internal check for a target object in
the identity map could lead to an error if it were to be garbage collected
immediately before the merge routine actually retrieves the object.
Mike Bayer [Mon, 4 Sep 2017 20:21:14 +0000 (16:21 -0400)]
Check for non-mapped property in synonym
An :class:`.InvalidRequestError` is raised when a :func:`.synonym`
is used against an attribute that is not against a :class:`.MapperProperty`,
such as an association proxy. Previously, a recursion overflow would
occur trying to locate non-existent attributes.
Mike Bayer [Mon, 4 Sep 2017 19:53:34 +0000 (15:53 -0400)]
Always check that discarded state is the expected one
Fixed race condition in ORM identity map which would cause objects
to be inappropriately removed during a load operation, causing
duplicate object identities to occur, particularly under joined eager
loading which involves deduplication of objects. The issue is specific
to garbage collection of weak references and is observed only under the
Pypy interpreter.
Mike Bayer [Fri, 1 Sep 2017 14:35:30 +0000 (10:35 -0400)]
Ensure custom ops have consistent typing behavior, boolean support
Refined the behavior of :meth:`.Operators.op` such that in all cases,
if the :paramref:`.Operators.op.is_comparison` flag is set to True,
the return type of the resulting expression will be
:class:`.Boolean`, and if the flag is False, the return type of the
resulting expression will be the same type as that of the left-hand
expression, which is the typical default behavior of other operators.
Also added a new parameter :paramref:`.Operators.op.return_type` as well
as a helper method :meth:`.Operators.bool_op`.
Mike Bayer [Fri, 1 Sep 2017 16:31:38 +0000 (12:31 -0400)]
Add InternalError for mysqlclient disconnect
mysqlclient as of 1.3.11 changed the exception
class for a particular disconnect situation from
InterfaceError to InternalError; the disconnection
detection logic now accommodates this.
Mike Bayer [Thu, 31 Aug 2017 19:46:53 +0000 (15:46 -0400)]
Consider merge key with (None, ) as non-persistent
Fixed bug in :meth:`.Session.merge` where objects in a collection that had
the primary key attribute set to ``None`` for a key that is typically
autoincrementing would be considered to be a database-persisted key for
part of the internal deduplication process, causing only one object to
actually be inserted in the database.
Mike Bayer [Thu, 31 Aug 2017 20:22:52 +0000 (16:22 -0400)]
- pin on cx_Oracle 6.0.1 for the moment while we wait for
either https://github.com/oracle/python-cx_Oracle/issues/75
to be fixed or we can merge a workaround
Mike Bayer [Thu, 31 Aug 2017 17:12:50 +0000 (13:12 -0400)]
Add new sane_rowcount_w_returning flag
Added a new class of "rowcount support" for dialects that is specific to
when "RETURNING", which on SQL Server looks like "OUTPUT inserted", is in
use, as the PyODBC backend isn't able to give us rowcount on an UPDATE or
DELETE statement when OUTPUT is in effect. This primarily affects the ORM
when a flush is updating a row that contains server-calcluated values,
raising an error if the backend does not return the expected row count.
PyODBC now states that it supports rowcount except if OUTPUT.inserted is
present, which is taken into account by the ORM during a flush as to
whether it will look for a rowcount.
ORM tests are implicit in existing tests run against PyODBC
Mike Bayer [Wed, 30 Aug 2017 22:06:07 +0000 (18:06 -0400)]
Enable native boolean for SQL Server
SQL Server supports what SQLAlchemy calls "native boolean"
with its BIT type, as this type only accepts 0 or 1 and the
DBAPIs return its value as True/False. So the SQL Server
dialects now enable "native boolean" support, in that a
CHECK constraint is not generated for a :class:`.Boolean`
datatype. The only difference vs. other native boolean
is that there are no "true" / "false" constants so "1" and
"0" are still rendered here.
Mike Bayer [Wed, 30 Aug 2017 16:19:54 +0000 (12:19 -0400)]
Add preparer to pymssql that disables percent doubling
Fixed the pymssql dialect so that percent signs in SQL text, such
as used in modulus expressions or literal textual values, are
**not** doubled up, as seems to be what pymssql expects. This is
despite the fact that the pymssql DBAPI uses the "pyformat" parameter
style which itself considers the percent sign to be significant.
Tests are part of standard suite already (CI has been disabled)