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 [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)
Mike Bayer [Wed, 30 Aug 2017 16:23:31 +0000 (12:23 -0400)]
Ignore SQL Server "heap" indexes
Added a rule to SQL Server index reflection to ignore the so-called
"heap" index that is implicitly present on a table that does not
specify a clustered index.
Tests are part of standard suite already (CI has been disabled)
Mike Bayer [Wed, 30 Aug 2017 16:25:57 +0000 (12:25 -0400)]
Join key_constraints on schema as well for SQL server get_fks
Fixed bug where the SQL Server dialect could pull columns from multiple
schemas when reflecting a self-referential foreign key constraint, if
multiple schemas contained a constraint of the same name against a
table of the same name.
Tests are part of standard suite already (CI has been disabled)
Mike Bayer [Fri, 25 Aug 2017 19:26:02 +0000 (15:26 -0400)]
Apply percent sign escaping to literal binds, comments
Fixed bug in new percent-sign support (e.g. :ticket:`3740`) where a bound
parameter rendered with literal_binds would fail to escape percent-signs
for relevant dialects. In addition, ensured new table / column comment
support feature also fully makes use of literal-rendered parameters so that
this percent sign support takes place with table / column comment DDL as
well, allowing percent sign support for the mysql / psycopg2 backends that
require escaping of percent signs.
Mike Bayer [Fri, 14 Jul 2017 22:06:48 +0000 (18:06 -0400)]
Don't do recovery operations under Empty/AttributeError
Made some adjustments to :class:`.Pool` and :class:`.Connection` such
that recovery logic is not run underneath exception catches for
``pool.Empty``, ``AttributeError``, since when the recovery operation
itself fails, Python 3 creates a misleading stack trace referring to the
``Empty`` / ``AttributeError`` as the cause, when in fact these exception
catches are part of control flow.
Mike Bayer [Fri, 25 Aug 2017 13:41:18 +0000 (09:41 -0400)]
Allow for multiple FOLLOWING/PRECEDING in a window range
Altered the range specification for window functions to allow
for two of the same PRECEDING or FOLLOWING keywords in a range
by allowing for the left side of the range to be positive
and for the right to be negative, e.g. (1, 3) is
"1 FOLLOWING AND 3 FOLLOWING".
Mike Bayer [Wed, 23 Aug 2017 20:33:10 +0000 (16:33 -0400)]
Ensure col is not None when retrieving quick populators
Fixed bug where an :func:`.undefer_group` option would not be recognized
if it extended from a relationship that was loading using joined eager
loading.
In particular we need to double check the column both in terms of
the given "adapter" as well as without applying the "adapter"
when searching for the column in the result.
As we now avoid redoing the row processor step we also
improve on callcounts in joined eager loading.
Mike Bayer [Tue, 22 Aug 2017 22:35:09 +0000 (18:35 -0400)]
Handle cache key for option that has no strategy
Fixed regression where the use of a :func:`.undefer_group` option
in conjunction with a lazy loaded relationship option would cause
an attribute error, due to a bug in the SQL cache key generation
added in 1.2 as part of :ticket:`3954`.
Mike Bayer [Mon, 21 Aug 2017 18:21:50 +0000 (14:21 -0400)]
Deactivate transaction if rollback fails
Fixed regression introduced in 1.2.0b1 due to :ticket:`3934` where the
:class:`.Session` would fail to "deactivate" the transaction, if a
rollback failed (the target issue is when MySQL loses track of a SAVEPOINT).
This would cause a subsequent call to :meth:`.Session.rollback` to raise
an error a second time, rather than completing and bringing the
:class:`.Session` back to ACTIVE.
Mike Bayer [Fri, 18 Aug 2017 17:04:14 +0000 (13:04 -0400)]
First level repair for cx_Oracle 6.0 test regressions
Fixed more regressions caused by cx_Oracle 6.0; at the moment, the only
behavioral change for users is disconnect detection now detects for
cx_Oracle.DatabaseError in addition to cx_Oracle.InterfaceError, as
this behavior seems to have changed. Other issues regarding numeric
precision and uncloseable connections are pending with the upstream
cx_Oracle issue tracker.
Mike Bayer [Mon, 14 Aug 2017 16:04:26 +0000 (12:04 -0400)]
Isolate memory tests in forks
Swing the biggest hammer, run multiprocessing.Process() for
each memusage test individually so that they are fully isolated
from the parent process and any side effects of pytest-xdist
Also add --nomemory as a shortcut to exclude_tags=memory-intensive
and add this to the setup.py test runner as the memory tests
should not be running for quick runs
Mike Bayer [Mon, 14 Aug 2017 13:32:08 +0000 (09:32 -0400)]
Restore original test names
The change in de1f8f8345ecd6af0ec1177703465e9471cfe862
modified how test classes are named, breaking logic that
extracts the class name for the profiling suite.
Add a new variable _sa_orig_cls_name if we've modified the
name so that the profiling logic doesn't need to guess
the original class name.
Mike Bayer [Fri, 11 Aug 2017 19:52:28 +0000 (15:52 -0400)]
Ensure Oracle index w/ col DESC etc. is reflected
Fixed bug where an index reflected under Oracle with an expression like
"column DESC" would not be returned, if the table also had no primary
key, as a result of logic that attempts to filter out the
index implicitly added by Oracle onto the primary key columns.
Reworked the "filter out the primary key index" logic in oracle
get_indexes() to be clearer.
This changeset also adds an internal check to ColumnCollection
to accomodate for the case of a column being added twice,
as well as adding a private _table argument to Index such that
reflection can specify the Table explicitly. The _table
argument can become part of public API in a later revision
or release if needed.
Mike Bayer [Thu, 10 Aug 2017 19:44:54 +0000 (15:44 -0400)]
- take more print statements out, maybe this is not
the issue
- unblock pytest-xdist now that the upstream issue is fixed,
maybe this old version is the issue
Mike Bayer [Tue, 8 Aug 2017 16:56:43 +0000 (12:56 -0400)]
Enable uuid for pg8000
Enabled UUID support for the pg8000 driver, which supports native Python
uuid round trips for this datatype. Arrays of UUID are still not supported,
however.
Mike Bayer [Tue, 8 Aug 2017 17:30:49 +0000 (13:30 -0400)]
Add quoted_name to pg8000 py_types
Fixed bug where the pg8000 driver would fail if using
:meth:`.MetaData.reflect` with a schema name, since the schema name would
be sent as a "quoted_name" object that's a string subclass, which pg8000
doesn't recognize. The quoted_name type is added to pg8000's
py_types collection on connect.