:released: October 5, 2016
.. change::
:tags: bug, sql
:tickets: 3805
Execution options can now be propagated from within a
statement at compile time to the outermost statement, so that
if an embedded element wants to set "autocommit" to be True for example,
it can propagate this to the enclosing statement. Currently, this
feature is enabled for a DML-oriented CTE embedded inside of a SELECT
statement, e.g. INSERT/UPDATE/DELETE inside of SELECT.
.. change::
:tags: bug, orm
:tickets: 3802
ORM attributes can now be assigned any object that is has a
``__clause_element__()`` attribute, which will result in inline
SQL the way any :class:`_expression.ClauseElement` class does. This covers other
mapped attributes not otherwise transformed by further expression
constructs.
.. change::
:tags: feature, orm
:tickets: 3812
Enhanced the new "raise" lazy loader strategy to also include a
"raise_on_sql" variant, available both via :paramref:`.orm.relationship.lazy`
as well as :func:`_orm.raiseload`. This variant only raises if the
lazy load would actually emit SQL, vs. raising if the lazy loader
mechanism is invoked at all.
.. change::
:tags: bug, postgresql
:tickets: 3813
An adjustment to ON CONFLICT such that the "inserted_primary_key"
logic is able to accommodate the case where there's no INSERT or
UPDATE and there's no net change. The value comes out as None
in this case, rather than failing on an exception.
.. change::
:tags: bug, orm
:tickets: 3811
Made an adjustment to the bug fix first introduced in [ticket:3431]
that involves an object appearing in multiple contexts in a single
result set, such that an eager loader that would set the related
object value to be None will still fire off, thus satisfying the
load of that attribute. Previously, the adjustment only honored
a non-None value arriving for an eagerly loaded attribute in a
secondary row.
.. change::
:tags: bug, orm
:tickets: 3808
Fixed bug in new :meth:`.SessionEvents.persistent_to_deleted` event
where the target object could be garbage collected before the event
is fired off.
.. change::
:tags: bug, sql
:tickets: 3809
A string sent as a column default via the
:paramref:`_schema.Column.server_default` parameter is now escaped for quotes.
.. seealso::
:ref:`change_3809`
.. change::
:tags: bug, postgresql
:tickets: 3807
Fixed issue in new PG "on conflict" construct where columns including
those of the "excluded" namespace would not be table-qualified
in the WHERE clauses in the statement.
.. change::
:tags: bug, sql, postgresql
:tickets: 3806
Added compiler-level flags used by PostgreSQL to place additional
parenthesis than would normally be generated by precedence rules
around operations involving JSON, HSTORE indexing operators as well as
within their operands since it has been observed that PostgreSQL's
precedence rules for at least the HSTORE indexing operator is not
consistent between 9.4 and 9.5.
.. change::
:tags: bug, sql, mysql
:tickets: 3803
The ``BaseException`` exception class is now intercepted by the
exception-handling routines of :class:`_engine.Connection`, and includes
handling by the :meth:`_events.ConnectionEvents.handle_error`
event. The :class:`_engine.Connection` is now **invalidated** by default in
the case of a system level exception that is not a subclass of
``Exception``, including ``KeyboardInterrupt`` and the greenlet
``GreenletExit`` class, to prevent further operations from occurring
upon a database connection that is in an unknown and possibly
corrupted state. The MySQL drivers are most targeted by this change
however the change is across all DBAPIs.
.. seealso::
:ref:`change_3803`
.. change::
:tags: bug, sql
:tickets: 3799
The "eq" and "ne" operators are no longer part of the list of
"associative" operators, while they remain considered to be
"commutative". This allows an expression like ``(x == y) == z``
to be maintained at the SQL level with parenthesis. Pull request
courtesy John Passaro.
.. change::
:tags: bug, orm
:tickets: 3767
The primaryjoin of a :func:`_orm.relationship` construct can now include
a :func:`.bindparam` object that includes a callable function to
generate values. Previously, the lazy loader strategy would
be incompatible with this use, and additionally would fail to correctly
detect if the "use_get" criteria should be used if the primary key
were involved with the bound parameter.
.. change::
:tags: bug, orm
:tickets: 3801
An UPDATE emitted from the ORM flush process can now accommodate a
SQL expression element for a column within the primary key of an
object, if the target database supports RETURNING in order to provide
the new value, or if the PK value is set "to itself" for the purposes
of bumping some other trigger / onupdate on the column.
.. change::
:tags: bug, orm
:tickets: 3788
Fixed bug where the "simple many-to-one" condition that allows lazy
loading to use get() from identity map would fail to be invoked if the
primaryjoin of the relationship had multiple clauses separated by AND
which were not in the same order as that of the primary key columns
being compared in each clause. This ordering
difference occurs for a composite foreign key where the table-bound
columns on the referencing side were not in the same order in the .c
collection as the primary key columns on the referenced side....which
in turn occurs a lot if one is using declarative mixins and/or
declared_attr to set up columns.
.. change::
:tags: bug, sql
:tickets: 3789
Stringify of expression with unnamed :class:`_schema.Column` objects, as
occurs in lots of situations including ORM error reporting,
will now render the name in string context as "<name unknown>"
rather than raising a compile error.
.. change::
:tags: bug, sql
:tickets: 3786
Raise a more descriptive exception / message when ClauseElement
or non-SQLAlchemy objects that are not "executable" are erroneously
passed to ``.execute()``; a new exception ObjectNotExecutableError
is raised consistently in all cases.
.. change::
:tags: bug, orm
:tickets: 3776
An exception is raised when two ``validates`` decorators on a mapping
make use of the same name. Only one validator of a certain name
at a time is supported, there's no mechanism to chain these together,
as the order of the validators at the level of function decorator
can't be made deterministic.
.. seealso::
:ref:`change_3776`
.. change::
:tags: bug, orm
Mapper errors raised during :func:`.configure_mappers` now explicitly
include the name of the originating mapper in the exception message
to help in those situations where the wrapped exception does not
itself include the source mapper. Pull request courtesy
John Perkins.
.. change::
:tags: bug, mysql
:tickets: 3766
Fixed bug where the "literal_binds" flag would not be propagated
to a CAST expression under MySQL.
.. change::
:tags: bug, sql, postgresql, mysql
:tickets: 3765
Fixed regression in JSON datatypes where the "literal processor" for
a JSON index value would not be invoked. The native String and Integer
datatypes are now called upon from within the JSONIndexType
and JSONPathType. This is applied to the generic, PostgreSQL, and
MySQL JSON types and also has a dependency on :ticket:`3766`.
.. change::
:tags: change, orm
Passing False to :meth:`_query.Query.order_by` in order to cancel
all order by's is deprecated; there is no longer any difference
between calling this method with False or with None.
.. change::
:tags: feature, orm
The :meth:`_query.Query.group_by` method now resets the group by collection
if an argument of ``None`` is passed, in the same way that
:meth:`_query.Query.order_by` has worked for a long time. Pull request
courtesy Iuri Diniz.
.. change::
:tags: bug, sql
:tickets: 3763
Fixed bug where :class:`.Index` would fail to extract columns from
compound SQL expressions if those SQL expressions were wrapped inside
of an ORM-style ``__clause_element__()`` construct. This bug
exists in 1.0.x as well, however in 1.1 is more noticeable as
hybrid_property expression now returns a wrapped element.
.. change::
:tags: change, orm, declarative
Constructing a declarative base class that inherits from another class
will also inherit its docstring. This means
:func:`~.ext.declarative.as_declarative` acts more like a normal class
decorator.
.. changelog::