1.3.0b2
Released: January 25, 2019
-
[bug] [ext] Fixed a regression in 1.3.0b1 caused by #3423 where association
proxy objects that access an attribute that's only present on a polymorphic
subclass would raise anAttributeError
even though the actual instance
being accessed was an instance of that subclass.References: #4401
-
[bug] [orm] Fixed long-standing issue where duplicate collection members would cause a
backref to delete the association between the member and its parent object
when one of the duplicates were removed, as occurs as a side effect of
swapping two objects in one statement.References: #1103
-
[bug] [mssql] The
literal_processor
for theUnicode
and
UnicodeText
datatypes now render anN
character in front of
the literal string expression as required by SQL Server for Unicode string
values rendered in SQL expressions.References: #4442
-
[feature] [orm] Implemented a new feature whereby the
AliasedClass
construct can
now be used as the target of arelationship()
. This allows the
concept of "non primary mappers" to no longer be necessary, as the
AliasedClass
is much easier to configure and automatically inherits
all the relationships of the mapped class, as well as preserves the
ability for loader options to work normally.References: #4423
-
[bug] [orm] Extended the fix first made as part of #3287, where a loader option
made against a subclass using a wildcard would extend itself to include
application of the wildcard to attributes on the super classes as well, to a
"bound" loader option as well, e.g. in an expression like
Load(SomeSubClass).load_only('foo')
. Columns that are part of the
parent class ofSomeSubClass
will also be excluded in the same way as if
the unbound optionload_only('foo')
were used.References: #4373
-
[bug] [orm] Improved error messages emitted by the ORM in the area of loader option
traversal. This includes early detection of mis-matched loader strategies
along with a clearer explanation why these strategies don't match.References: #4433
-
[change] [orm] Added a new function
close_all_sessions()
which takes
over the task of theSession.close_all()
method, which
is now deprecated as this is confusing as a classmethod.
Pull request courtesy Augustin Trancart.References: #4412
-
[feature] [orm] Added new
MapperEvents.before_mapper_configured()
event. This
event complements the other "configure" stage mapper events with a per
mapper event that receives eachMapper
right before its
configure step, and additionally may be used to prevent or delay the
configuration of specificMapper
objects using a new
return valueorm.interfaces.EXT_SKIP
. See the
documentation link for an example.References: #4397
-
[bug] [orm] The "remove" event for collections is now called before the item is removed
in the case of thecollection.remove()
method, as is consistent with the
behavior for most other forms of collection item removal (such as
__delitem__
, replacement under__setitem__
). Forpop()
methods,
the remove event still fires after the operation. -
[bug] [orm declarative] Added a
__clause_element__()
method toColumnProperty
which
can allow the usage of a not-fully-declared column or deferred attribute in
a declarative mapped class slightly more friendly when it's used in a
constraint or other column-oriented scenario within the class declaration,
though this still can't work in open-ended expressions; prefer to call the
ColumnProperty.expression
attribute if receivingTypeError
.References: #4372
-
[bug] [engine] [orm] Added accessors for execution options to Core and ORM, via
Query.get_execution_options()
,
Connection.get_execution_options()
,
Engine.get_execution_options()
, and
Executable.get_execution_options()
. PR courtesy Daniel Lister.References: #4464
-
[bug] [orm] Fixed issue in association proxy due to #3423 which caused the use
of customPropComparator
objects with hybrid attributes, such as
the one demonstrated in thedictlike-polymorphic
example to not
function within an association proxy. The strictness that was added in
#3423 has been relaxed, and additional logic to accommodate for
an association proxy that links to a custom hybrid have been added.References: #4446
-
[change] [general] A large change throughout the library has ensured that all objects,
parameters, and behaviors which have been noted as deprecated or legacy now
emitDeprecationWarning
warnings when invoked.As the Python 3
interpreter now defaults to displaying deprecation warnings, as well as that
modern test suites based on tools like tox and pytest tend to display
deprecation warnings, this change should make it easier to note what API
features are obsolete. A major rationale for this change is so that long-
deprecated features that nonetheless still see continue to see real world
use can finally be removed in the near future; the biggest example of this
are theSessionExtension
andMapperExtension
classes as
well as a handful of other pre-event extension hooks, which have been
deprecated since version 0.7 but still remain in the library. Another is
that several major longstanding behaviors are to be deprecated as well,
including the threadlocal engine strategy, the convert_unicode flag, and non
primary mappers.References: #4393
-
[change] [engine] The "threadlocal" engine strategy which has been a legacy feature of
SQLAlchemy since around version 0.2 is now deprecated, along with the
Pool.threadlocal
parameter ofPool
which has no
effect in most modern use cases.References: #4393
-
[change] [sql] The
create_engine.convert_unicode
and
String.convert_unicode
parameters have been deprecated. These
parameters were built back when most Python DBAPIs had little to no support
for Python Unicode objects, and SQLAlchemy needed to take on the very
complex task of marshalling data and SQL strings between Unicode and
bytestrings throughout the system in a performant way. Thanks to Python 3,
DBAPIs were compelled to adapt to Unicode-aware APIs and today all DBAPIs
supported by SQLAlchemy support Unicode natively, including on Python 2,
allowing this long-lived and very complicated feature to finally be (mostly)
removed. There are still of course a few Python 2 edge cases where
SQLAlchemy has to deal with Unicode however these are handled automatically;
in modern use, there should be no need for end-user interaction with these
flags.References: #4393
-
[bug] [orm] Implemented the
.get_history()
method, which also implies availability
ofAttributeState.history
, forsynonym()
attributes.
Previously, trying to access attribute history via a synonym would raise an
AttributeError
.References: #3777
-
[engine] [feature] Added public accessor
QueuePool.timeout()
that returns the configured
timeout for aQueuePool
object. Pull request courtesy Irina Delamare.References: #3689
-
[feature] [sql] Amended the
AnsiFunction
class, the base of common SQL
functions likeCURRENT_TIMESTAMP
, to accept positional arguments
like a regular ad-hoc function. This to suit the case that many of
these functions on specific backends accept arguments such as
"fractional seconds" precision and such. If the function is created
with arguments, it renders the parenthesis and the arguments. If
no arguments are present, the compiler generates the non-parenthesized form.References: #4386