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.
Mike Bayer [Fri, 4 Aug 2017 19:43:16 +0000 (15:43 -0400)]
Allow multiple versions of single backend
Improve screen output to illustrate which server version is
running for a particular database config, and additionally
allow full overriding for the backend-specific targets in
tox.ini via environment variables, so that CI can inject
multiple server urls for a particular database such as MySQL/MariaDB.
Mike Bayer [Fri, 28 Jul 2017 19:05:25 +0000 (15:05 -0400)]
Revert cx_Oracle WITH_UNICODE change under > 5.0
Fixed performance regression caused by the fix for :ticket:`3937` where
cx_Oracle as of version 5.3 dropped the ``.UNICODE`` symbol from its
namespace, which was interpreted as cx_Oracle's "WITH_UNICODE" mode being
turned on unconditionally, which invokes functions on the SQLAlchemy
side which convert all strings to unicode unconditionally and causing
a performance impact. In fact, per cx_Oracle's author the
"WITH_UNICODE" mode has been removed entirely as of 5.1, so the expensive unicode
conversion functions are no longer necessary and are disabled if
cx_Oracle 5.1 or greater is detected under Python 2. The warning against
"WITH_UNICODE" mode that was removed under :ticket:`3937` is also restored.
Mike Bayer [Mon, 17 Jul 2017 15:06:22 +0000 (11:06 -0400)]
Guard all indexed access in WeakInstanceDict
Added ``KeyError`` checks to all methods within
:class:`.WeakInstanceDict` where a check for ``key in dict`` is
followed by indexed access to that key, to guard against a race against
garbage collection that under load can remove the key from the dict
after the code assumes its present, leading to very infrequent
``KeyError`` raises.
Mike Bayer [Sat, 22 Jul 2017 20:32:01 +0000 (16:32 -0400)]
- move to file-per-changelog for unreleased change notes,
so that we no longer have to rely upon merges within
the changelog files. because gerrit doesn't allow us
to use custom merge engines unlike git, we have no ability
to merge multiple changes into the changelog files without
going through conflicts. new version of changelog
in git supports these new patterns.
Mike Bayer [Tue, 18 Jul 2017 15:41:12 +0000 (11:41 -0400)]
Check for column object in eval_none, not propkey
Fixed bug involving JSON NULL evaluation logic added in 1.1 as part
of :ticket:`3514` where the logic would not accommodate ORM
mapped attributes named differently from the :class:`.Column`
that was mapped.
Mike Bayer [Tue, 18 Jul 2017 18:58:26 +0000 (14:58 -0400)]
Check for non-entity when inspecting for subqueryload
Fixed issue where adding additional non-entity columns to
a query that includes an entity with subqueryload relationships
would fail, due to an inspection added in 1.1.11 as a result of
:ticket:`4011`.
David Moore [Wed, 5 Jul 2017 19:06:49 +0000 (15:06 -0400)]
Add support for CACHE and ORDER to sequences
Added new keywords :paramref:`.Sequence.cache` and
:paramref:`.Sequence.order` to :class:`.Sequence`, to allow rendering
of the CACHE parameter understood by Oracle and PostgreSQL, and the
ORDER parameter understood by Oracle. Pull request
courtesy David Moore.
Ben Fagin [Fri, 30 Jun 2017 20:36:33 +0000 (16:36 -0400)]
Add .autocommit to scoped_session
Added ``.autocommit`` attribute to :class:`.scoped_session`, proxying
the ``.autocommit`` attribute of the underling :class:`.Session`
currently assigned to the thread. Pull request courtesy
Ben Fagin.
Mike Bayer [Mon, 26 Jun 2017 20:50:24 +0000 (16:50 -0400)]
Coerce to float for Float with all native decimal backends
The result processor for the :class:`.Float` type now unconditionally
runs values through the ``float()`` processor if the dialect
specifies that it also supports "native decimal" mode. While most
backends will deliver Python ``float`` objects for a floating point
datatype, the MySQL backends in some cases lack the typing information
in order to provide this and return ``Decimal`` unless the float
conversion is done.
Mike Bayer [Mon, 26 Jun 2017 17:24:22 +0000 (13:24 -0400)]
Support state expiration for with_expression(); rename deferred_expression
The attributeimpl for a deferred_expression does not
support a scalar loader, add new configurability so that
the impl can have this flag turned off. Document
that the with_expression() system currently does not
offer any deferred loading.
To eliminate confusion over "deferred", which refers to
lazy loading of column attributes, and "with_expression",
which refers to an attribute that is explicitly at
query time only, rename deferred_expression to query_expression.
Mike Bayer [Mon, 26 Jun 2017 16:44:15 +0000 (12:44 -0400)]
Return given type when it matches the adaptation
The rules for type coercion between :class:`.Numeric`, :class:`.Integer`,
and date-related types now include additional logic that will attempt
to preserve the settings of the incoming type on the "resolved" type.
Currently the target for this is the ``asdecimal`` flag, so that
a math operation between :class:`.Numeric` or :class:`.Float` and
:class:`.Integer` will preserve the "asdecimal" flag as well as
if the type should be the :class:`.Float` subclass.
Mike Bayer [Fri, 23 Jun 2017 03:51:52 +0000 (23:51 -0400)]
Coerce float Python type to Float; ensure Python float coming back
Added some extra strictness to the handling of Python "float" values
passed to SQL statements. A "float" value will be associated with the
:class:`.Float` datatype and not the Decimal-coercing :class:`.Numeric`
datatype as was the case before, eliminating a confusing warning
emitted on SQLite as well as unecessary coercion to Decimal.
Mike Bayer [Mon, 19 Jun 2017 20:35:53 +0000 (16:35 -0400)]
Add ad-hoc mapped expressions
Added a new feature :func:`.orm.with_expression` that allows an ad-hoc
SQL expression to be added to a specific entity in a query at result
time. This is an alternative to the SQL expression being delivered as
a separate element in the result tuple.
Mike Bayer [Fri, 16 Jun 2017 17:30:25 +0000 (13:30 -0400)]
Handle SHOW VARIABLES returning no row
MySQL 5.7 has introduced permission limiting for the "SHOW VARIABLES"
command; the MySQL dialect will now handle when SHOW returns no
row, in particular for the initial fetch of SQL_MODE, and will
emit a warning that user permissions should be modified to allow the
row to be present.
Mike Bayer [Thu, 15 Jun 2017 17:12:16 +0000 (13:12 -0400)]
Set complete FROM list for subquery eagerload's orig query
Instead of checking that the "orig_entity" we receive applies
as a correct FROM element for the subquery we're building,
set the FROM clause of the query to exactly what it already
is based on column_descriptions (assuming there is no FROM
list already), thereby ensuring that the FROM list will remain
intact, regardless of what orig_entity turns out to be and
what the target_cols ultimately refer towards.
Fixed issue with subquery eagerloading which continues on from
the series of issues fixed in :ticket:`2699`, :ticket:`3106`,
:ticket:`3893` involving that the "subquery" contains the correct
FROM clause when beginning from a joined inheritance subclass
and then subquery eager loading onto a relationship from
the base class, while the query also includes criteria against
the subclass. The fix in the previous tickets did not accommodate
for additional subqueryload operations loading more deeply from
the first level, so the fix has been further generalized.
Mike Bayer [Tue, 12 Apr 2016 19:57:20 +0000 (15:57 -0400)]
Add all versioning logic to _post_update()
An UPDATE emitted as a result of the
:paramref:`.relationship.post_update` feature will now integrate with
the versioning feature to both bump the version id of the row as well
as assert that the existing version number was matched.
Mike Bayer [Thu, 15 Jun 2017 16:03:22 +0000 (12:03 -0400)]
Repair regression to pathing for subclasses
Issue #3963's initial commit narrowed the "current path"
match rules too much such that a path that matches current
path on subclass would no longer match.
Mike Bayer [Wed, 14 Jun 2017 16:53:00 +0000 (12:53 -0400)]
Refinements for unitofwork internals
* remove "mapper" argument from SaveUpdateState, DeleteState
* use __slots__ for all uow action classes
* rename ".delete" to ".isdelete"
* rename issue_post_update to register_post_update since this
doesn't actually issue the UPDATE
* rename IssuePostUpdate to PostUpdateAll
Mike Bayer [Mon, 12 Jun 2017 16:56:04 +0000 (12:56 -0400)]
Support AssociationProxy any() / has() / contains() to another AssociationProxy
The :meth:`.AssociationProxy.any`, :meth:`.AssociationProxy.has`
and :meth:`.AssociationProxy.contains`
comparison methods now support linkage to an attribute that
is itself also an :class:`.AssociationProxy`, recursively.
After some initial attempts it's clear that the any() / has()
of AssociationProxy needed to be reworked into a generic
_criterion_exists() to allow this to work recursively without
excess complexity. For the case of the multi-linked associationproxy,
the usual checks of "any()" / "has()" correctness simply don't
take place; for a single-link association proxy the error
checking logic that takes place in relationship() has been
ported to the local any() / has() methods.
Mike Bayer [Thu, 8 Jun 2017 16:55:23 +0000 (12:55 -0400)]
Render ARRAY index embedded between type and COLLATE
Fixed bug where using :class:`.ARRAY` with a string type that
features a collation would fail to produce the correct syntax
within CREATE TABLE.
The "COLLATE" must appear to the right of the array dimensions,
so we are using regexp substitution to insert the brackets in the
appropriate place. A more heavyweight solution would be that datatypes
know how to split up their base type vs. modifiers, but as this is
so specific to Postgresql ARRAY it's better to handle these cases
more locally.
Mike Bayer [Wed, 7 Jun 2017 16:30:22 +0000 (12:30 -0400)]
Parse for Postgresql version w/ "beta"
Continuing with the fix that correctly handles Postgresql
version string "10devel" released in 1.1.8, an additional regexp
bump to handle version strings of the form "10beta1". While
Postgresql now offers better ways to get this information, we
are sticking w/ the regexp at least through 1.1.x for the least
amount of risk to compatibility w/ older or alternate Postgresql
databases.
Mike Bayer [Tue, 6 Jun 2017 22:53:03 +0000 (18:53 -0400)]
- assert passive_deletes='all' does not affect collection/scalar
membership removal
in issue #3844 we hypotheized that passive_deletes='all' was broken
because it sets to NULL a foreign key attribute when the child
object is removed or replaced. However, not doing the NULL
set means that nothing happens at all and the operation silently
fails.
Mike Bayer [Tue, 6 Jun 2017 21:13:54 +0000 (17:13 -0400)]
Warn when declared_attr.cascading detected on mapped class
A warning is emitted if the :attr:`.declared_attr.cascading` modifier
is used with a declarative attribute that is itself declared on
a class that is to be mapped, as opposed to a declarative mixin
class or ``__abstract__`` class. The :attr:`.declared_attr.cascading`
modifier currently only applies to mixin/abstract classes.
Also add a test for @declared_attr.cascading when used on an attribute
on __abstract__.
Mike Bayer [Tue, 6 Jun 2017 17:54:33 +0000 (13:54 -0400)]
Re-send column value w/ onupdate default during post-update
Adjusted the behavior of post_update such that if a column with
an "onupdate" default has received an explicit value for
INSERT, re-send the same data during a post-update UPDATE so
that the value remains in effect, rather than an onupdate
overwriting it.
Mike Bayer [Tue, 12 Apr 2016 19:56:02 +0000 (15:56 -0400)]
Implement _postfetch_post_update to expire/refresh onupdates in post_update
Fixed bug involving the :paramref:`.relationship.post_update` feature
where a column "onupdate" value would not result in expiration or
refresh of the corresponding object attribute, if the UPDATE for the
row were a result of the "post update" feature. Additionally, the
:meth:`.SessionEvents.refresh_flush` event is now emitted for these
attributes when refreshed within the flush.
Mike Bayer [Mon, 5 Jun 2017 19:49:04 +0000 (15:49 -0400)]
Implement in-place mutation operators for MutableSet, MutableList
Implemented in-place mutation operators ``__ior__``, ``__iand__``,
``__ixor__`` and ``__isub__`` for :class:`.mutable.MutableSet`
and ``__iadd__`` for :class:`.mutable.MutableList` so that change
events are fired off when these mutator methods are used to alter the
collection.
Mike Bayer [Tue, 28 Mar 2017 15:00:37 +0000 (11:00 -0400)]
selectin polymorphic loading
Added a new style of mapper-level inheritance loading
"polymorphic selectin". This style of loading
emits queries for each subclass in an inheritance
hierarchy subsequent to the load of the base
object type, using IN to specify the desired
primary key values.
Mike Bayer [Fri, 26 May 2017 17:26:40 +0000 (13:26 -0400)]
Don't hard-evaluate non-ORM @declared_attr for AbstractConcreteBase
Fixed bug where using :class:`.declared_attr` on an
:class:`.AbstractConcreteBase` where a particular return value were some
non-mapped symbol, including ``None``, would cause the attribute
to hard-evaluate just once and store the value to the object
dictionary, not allowing it to invoke for subclasses. This behavior
is normal when :class:`.declared_attr` is on a mapped class, and
does not occur on a mixin or abstract class. Since
:class:`.AbstractConcreteBase` is both "abstract" and actually
"mapped", a special exception case is made here so that the
"abstract" behavior takes precedence for :class:`.declared_attr`.
Mike Bayer [Fri, 26 May 2017 15:24:25 +0000 (11:24 -0400)]
Add placeholder XML support
Added a placeholder type :class:`.mssql.XML` to the SQL Server
dialect, so that a reflected table which includes this type can
be re-rendered as a CREATE TABLE. The type has no special round-trip
behavior nor does it currently support additional qualifying
arguments.
Michael Birtwell [Thu, 25 May 2017 15:11:21 +0000 (11:11 -0400)]
Flatten operator precedence for comparison operators
The operator precedence for all comparison operators such as LIKE, IS,
IN, MATCH, equals, greater than, less than, etc. has all been merged
into one level, so that expressions which make use of these against
each other will produce parentheses between them. This suits the
stated operator precedence of databases like Oracle, MySQL and others
which place all of these operators as equal precedence, as well as
Postgresql as of 9.5 which has also flattened its operator precendence.
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com> Fixes: #3999
Change-Id: I3f3d5124a64af0d376361cdf15a97e2e703be56f
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/367
Mike Bayer [Thu, 25 May 2017 14:17:11 +0000 (10:17 -0400)]
Raise if ForeignKeyConstraint created with different numbers of
local and remote columns.
An :class:`.ArgumentError` is now raised if a
:class:`.ForeignKeyConstraint` object is created with a mismatched
number of "local" and "remote" columns, which otherwise causes the
internal state of the constraint to be incorrect. Note that this
also impacts the condition where a dialect's reflection process
produces a mismatched set of columns for a foreign key constraint.
Downstream DB2 dialect has been reported as potentially causing this
scenario.