NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
PyPI, #86 most downloaded on PyPI
Database Abstraction Library
Latest stable
2.1.9
Last release 3 days ago
16 Nov 2026
Ships fairly regularly
a new release about every 2 weeks
Nearly every release is documented
notes for 60 of the last 60 stable releases
3 versions withdrawn
withdrawn after publishing
21 years old
344 releases · first in 2006
Drag across the ruler to compare, or tap a release to open it.
In addition, removed unused parameters that were deprecated in version 1.2, and additionally we are now defaulting "threaded" to False.
Released: November 16, 2018
[feature] [sql] Refactored SQLCompiler to expose a
SQLCompiler.group_by_clause() method similar to the
SQLCompiler.order_by_clause() and SQLCompiler.limit_clause()
methods, which can be overridden by dialects to customize how GROUP BY
renders. Pull request courtesy Samuel Chou.
This change is also backported to: 1.2.13
[bug] [orm] Fixed bug where use of Lateral construct in conjunction with
Query.join() as well as Query.select_entity_from() would not
apply clause adaption to the right side of the join. "lateral" introduces
the use case of the right side of a join being correlatable. Previously,
adaptation of this clause wasn't considered. Note that in 1.2 only,
a selectable introduced by Query.subquery() is still not adapted
due to #4304; the selectable needs to be produced by the
select() function to be the right side of the "lateral" join.
This change is also backported to: 1.2.12
References: #4334
[feature] [oracle] Added a new event currently used only by the cx_Oracle dialect,
DialectEvents.setiputsizes(). The event passes a dictionary of
BindParameter objects to DBAPI-specific type objects that will be
passed, after conversion to parameter names, to the cx_Oracle
cursor.setinputsizes() method. This allows both visibility into the
setinputsizes process as well as the ability to alter the behavior of what
datatypes are passed to this method.
This change is also backported to: 1.2.9
References: #4290
[ext] [feature] Added new attribute Query.lazy_loaded_from which is populated
with an InstanceState that is using this Query in
order to lazy load a relationship. The rationale for this is that
it serves as a hint for the horizontal sharding feature to use, such that
the identity token of the state can be used as the default identity token
to use for the query within id_chooser().
This change is also backported to: 1.2.9
References: #4243
[feature] [postgresql] Added new PG type postgresql.REGCLASS which assists in casting
table names to OID values. Pull request courtesy Sebastian Bank.
This change is also backported to: 1.2.7
References: #4160
[feature] [orm] Added new feature Query.only_return_tuples(). Causes the
Query object to return keyed tuple objects unconditionally even
if the query is against a single entity. Pull request courtesy Eric
Atkin.
This change is also backported to: 1.2.5
[bug] [ext] Reworked AssociationProxy to store state that's specific to a
parent class in a separate object, so that a single
AssociationProxy can serve for multiple parent classes, as is
intrinsic to inheritance, without any ambiguity in the state returned by it.
A new method AssociationProxy.for_class() is added to allow
inspection of class-specific state.
References: #3423
[bug] [oracle] Updated the parameters that can be sent to the cx_Oracle DBAPI to both allow for all current parameters as well as for future parameters not added yet. In addition, removed unused parameters that were deprecated in version 1.2, and additionally we are now defaulting "threaded" to False.
References: #4369
[bug] [oracle] The Oracle dialect will no longer use the NCHAR/NCLOB datatypes
represent generic unicode strings or clob fields in conjunction with
Unicode and UnicodeText unless the flag
use_nchar_for_unicode=True is passed to create_engine() -
this includes CREATE TABLE behavior as well as setinputsizes() for
bound parameters. On the read side, automatic Unicode conversion under
Python 2 has been added to CHAR/VARCHAR/CLOB result rows, to match the
behavior of cx_Oracle under Python 3. In order to mitigate the performance
hit under Python 2, SQLAlchemy's very performant (when C extensions
are built) native Unicode handlers are used under Python 2.
References: #4242
[bug] [orm] Fixed issue regarding passive_deletes="all", where the foreign key attribute of an object is maintained with its value even after the object is removed from its parent collection. Previously, the unit of work would set this to NULL even though passive_deletes indicated it should not be modified.
References: #3844
[bug] [ext] The long-standing behavior of the association proxy collection maintaining only a weak reference to the parent object is reverted; the proxy will now maintain a strong reference to the parent for as long as the proxy collection itself is also in memory, eliminating the "stale association proxy" error. This change is being made on an experimental basis to see if any use cases arise where it causes side effects.
References: #4268
[bug] [sql] Added "like" based operators as "comparison" operators, including
ColumnOperators.startswith() ColumnOperators.endswith()
ColumnOperators.ilike() ColumnOperators.notilike() among many
others, so that all of these operators can be the basis for an ORM
"primaryjoin" condition.
References: #4302
[feature] [sqlite] Added support for SQLite's json functionality via the new
SQLite implementation for types.JSON, sqlite.JSON.
The name used for the type is JSON, following an example found at
SQLite's own documentation. Pull request courtesy Ilja Everilä.
References: #3850
[engine] [feature] Added new "lifo" mode to QueuePool, typically enabled by setting
the flag create_engine.pool_use_lifo to True. "lifo" mode
means the same connection just checked in will be the first to be checked
out again, allowing excess connections to be cleaned up from the server
side during periods of the pool being only partially utilized. Pull request
courtesy Taem Park.
[bug] [orm] Improved the behavior of a relationship-bound many-to-one object expression
such that the retrieval of column values on the related object are now
resilient against the object being detached from its parent
Session, even if the attribute has been expired. New features
within the InstanceState are used to memoize the last known value
of a particular column attribute before its expired, so that the expression
can still evaluate when the object is detached and expired at the same
time. Error conditions are also improved using modern attribute state
features to produce more specific messages as needed.
References: #4359
[feature] [mysql] Support added for the "WITH PARSER" syntax of CREATE FULLTEXT INDEX
in MySQL, using the mysql_with_parser keyword argument. Reflection
is also supported, which accommodates MySQL's special comment format
for reporting on this option as well. Additionally, the "FULLTEXT" and
"SPATIAL" index prefixes are now reflected back into the mysql_prefix
index option.
References: #4219
[bug] [mysql] [orm] [postgresql] The ORM now doubles the "FOR UPDATE" clause within the subquery that renders in conjunction with joined eager loading in some cases, as it has been observed that MySQL does not lock the rows from a subquery. This means the query renders with two FOR UPDATE clauses; note that on some backends such as Oracle, FOR UPDATE clauses on subqueries are silently ignored since they are unnecessary. Additionally, in the case of the "OF" clause used primarily with PostgreSQL, the FOR UPDATE is rendered only on the inner subquery when this is used so that the selectable can be targeted to the table within the SELECT statement.
References: #4246
[feature] [mssql] Added fast_executemany=True parameter to the SQL Server pyodbc dialect,
which enables use of pyodbc's new performance feature of the same name
when using Microsoft ODBC drivers.
References: #4158
[bug] [ext] Fixed multiple issues regarding de-association of scalar objects with the
association proxy. del now works, and additionally a new flag
AssociationProxy.cascade_scalar_deletes is added, which when
set to True indicates that setting a scalar attribute to None or
deleting via del will also set the source association to None.
References: #4308
[ext] [feature] Added new feature BakedQuery.to_query(), which allows for a
clean way of using one BakedQuery as a subquery inside of another
BakedQuery without needing to refer explicitly to a
Session.
References: #4318
[feature] [sqlite] Implemented the SQLite ON CONFLICT clause as understood at the DDL
level, e.g. for primary key, unique, and CHECK constraints as well as
specified on a Column to satisfy inline primary key and NOT NULL.
Pull request courtesy Denis Kataev.
References: #4360
[feature] [postgresql] Added rudimental support for reflection of PostgreSQL partitioned tables, e.g. that relkind='p' is added to reflection queries that return table information.
References: #4237
[ext] [feature] The AssociationProxy now has standard column comparison operations
such as ColumnOperators.like() and
ColumnOperators.startswith() available when the target attribute is a
plain column - the EXISTS expression that joins to the target table is
rendered as usual, but the column expression is then use within the WHERE
criteria of the EXISTS. Note that this alters the behavior of the
.contains() method on the association proxy to make use of
ColumnOperators.contains() when used on a column-based attribute.
References: #4351
[feature] [orm] Added new flag Session.bulk_save_objects.preserve_order to the
Session.bulk_save_objects() method, which defaults to True. When set
to False, the given mappings will be grouped into inserts and updates per
each object type, to allow for greater opportunities to batch common
operations together. Pull request courtesy Alessandro Cucci.
[bug] [orm] Refactored Query.join() to further clarify the individual components
of structuring the join. This refactor adds the ability for
Query.join() to determine the most appropriate "left" side of the
join when there is more than one element in the FROM list or the query is
against multiple entities. If more than one FROM/entity matches, an error
is raised that asks for an ON clause to be specified to resolve the
ambiguity. In particular this targets the regression we saw in
#4363 but is also of general use. The codepaths within
Query.join() are now easier to follow and the error cases are
decided more specifically at an earlier point in the operation.
References: #4365
[bug] [sql] Fixed issue with TypeEngine.bind_expression() and
TypeEngine.column_expression() methods where these methods would not
work if the target type were part of a Variant, or other target
type of a TypeDecorator. Additionally, the SQL compiler now
calls upon the dialect-level implementation when it renders these methods
so that dialects can now provide for SQL-level processing for built-in
types.
References: #3981
[bug] [orm] Fixed long-standing issue in Query where a scalar subquery such
as produced by Query.exists(), Query.as_scalar() and other
derivations from Query.statement would not correctly be adapted
when used in a new Query that required entity adaptation, such as
when the query were turned into a union, or a from_self(), etc. The change
removes the "no adaptation" annotation from the select() object
produced by the Query.statement accessor.
References: #4304
[bug] [declarative] [orm] Fixed bug where declarative would not update the state of the
Mapper as far as what attributes were present, when additional
attributes were added or removed after the mapper attribute collections had
already been called and memoized. Additionally, a NotImplementedError
is now raised if a fully mapped attribute (e.g. column, relationship, etc.)
is deleted from a class that is currently mapped, since the mapper will not
function correctly if the attribute has been removed.
References: #4133
[bug] [mssql] Deprecated the use of Sequence with SQL Server in order to affect
the "start" and "increment" of the IDENTITY value, in favor of new
parameters mssql_identity_start and mssql_identity_increment which
set these parameters directly. Sequence will be used to generate
real CREATE SEQUENCE DDL with SQL Server in a future release.
References: #4362
[feature] [mysql] Added support for the parameters in an ON DUPLICATE KEY UPDATE statement on
MySQL to be ordered, since parameter order in a MySQL UPDATE clause is
significant, in a similar manner as that described at
updates_order_parameters. Pull request courtesy Maxim Bublis.
[feature] [sql] Added Sequence to the "string SQL" system that will render a
meaningful string expression ("<next sequence value: my_sequence>")
when stringifying without a dialect a statement that includes a "sequence
nextvalue" expression, rather than raising a compilation error.
References: #4144
[bug] [orm] An informative exception is re-raised when a primary key value is not
sortable in Python during an ORM flush under Python 3, such as an Enum
that has no __lt__() method; normally Python 3 raises a TypeError
in this case. The flush process sorts persistent objects by primary key
in Python so the values must be sortable.
References: #4232
[bug] [orm] Removed the collection converter used by the MappedCollection
class. This converter was used only to assert that the incoming dictionary
keys matched that of their corresponding objects, and only during a bulk set
operation. The converter can interfere with a custom validator or
AttributeEvents.bulk_replace() listener that wants to convert
incoming values further. The TypeError which would be raised by this
converter when an incoming key didn't match the value is removed; incoming
values during a bulk assignment will be keyed to their value-generated key,
and not the key that's explicitly present in the dictionary.
Overall, @converter is superseded by the
AttributeEvents.bulk_replace() event handler added as part of
#3896.
References: #3604
[feature] [sql] Added new naming convention tokens column_0N_name, column_0_N_name,
etc., which will render the names / keys / labels for all columns referenced
by a particular constraint in a sequence. In order to accommodate for the
length of such a naming convention, the SQL compiler's auto-truncation
feature now applies itself to constraint names as well, which creates a
shortened, deterministically generated name for the constraint that will
apply to a target backend without going over the character limit of that
backend.
The change also repairs two other issues. One is that the column_0_key
token wasn't available even though this token was documented, the other was
that the referred_column_0_name token would inadvertently render the
.key and not the .name of the column if these two values were
different.
References: #3989
[ext] [feature] Added support for bulk Query.update() and Query.delete()
to the ShardedQuery class within the horizontal sharding
extension. This also adds an additional expansion hook to the
bulk update/delete methods Query._execute_crud().
References: #4196
[feature] [sql] Added new logic to the "expanding IN" bound parameter feature whereby if the given list is empty, a special "empty set" expression that is specific to different backends is generated, thus allowing IN expressions to be fully dynamic including empty IN expressions.
References: #4271
[feature] [mysql] The "pre-ping" feature of the connection pool now uses
the ping() method of the DBAPI connection in the case of
mysqlclient, PyMySQL and mysql-connector-python. Pull request
courtesy Maxim Bublis.
[feature] [orm] The "selectin" loader strategy now omits the JOIN in the case of a simple
one-to-many load, where it instead relies loads only from the related
table, relying upon the foreign key columns of the related table in order
to match up to primary keys in the parent table. This optimization can be
disabled by setting the relationship.omit_join flag to False.
Many thanks to Jayson Reis for the efforts on this.
References: #4340
[bug] [orm] Added new behavior to the lazy load that takes place when the "old" value of
a many-to-one is retrieved, such that exceptions which would be raised due
to either lazy="raise" or a detached session error are skipped.
References: #4353
[feature] [sql] The Python builtin dir() is now supported for a SQLAlchemy "properties"
object, such as that of a Core columns collection (e.g. .c),
mapper.attrs, etc. Allows iPython autocompletion to work as well.
Pull request courtesy Uwe Korn.
[feature] [orm] Added .info dictionary to the InstanceState class, the object
that comes from calling inspect() on a mapped object.
References: #4257
[feature] [sql] Added new feature FunctionElement.as_comparison() which allows a SQL
function to act as a binary comparison operation that can work within the
ORM.
References: #3831
[bug] [orm] A long-standing oversight in the ORM, the __delete__ method for a many-
to-one relationship was non-functional, e.g. for an operation such as del a.b. This is now implemented and is equivalent to setting the attribute
to None.
References: #4354
Your coding agent can read these notes before it upgrades. Set up the MCP server →
[bug] [orm] Fixed a regression in 1.2 due to the introduction of baked queries for relationship lazy loaders, where a race condition is created during
Released: April 15, 2019
[bug] [orm] Fixed a regression in 1.2 due to the introduction of baked queries for
relationship lazy loaders, where a race condition is created during the
generation of the "lazy clause" which occurs within a memoized attribute. If
two threads initialize the memoized attribute concurrently, the baked query
could be generated with bind parameter keys that are then replaced with new
keys by the next run, leading to a lazy load query that specifies the
related criteria as None. The fix establishes that the parameter names
are fixed before the new clause and parameter objects are generated, so that
the names are the same every time.
References: #4507
[bug] [oracle] Added support for reflection of the NCHAR datatype to the Oracle
dialect, and added NCHAR to the list of types exported by the
Oracle dialect.
References: #4506
[bug] [examples] Fixed bug in large_resultsets example case where a re-named "id" variable due to code reformatting caused the test to fail. Pull request courtesy Matt Schuchhardt.
References: #4528
[bug] [mssql] A commit() is emitted after an isolation level change to SNAPSHOT, as both pyodbc and pymssql open an implicit transaction which blocks subsequent SQL from being emitted in the current transaction.
References: #4536
[bug] [engine] Comparing two objects of URL using __eq__() did not take port
number into consideration, two objects differing only by port number were
considered equal. Port comparison is now added in __eq__() method of
URL, objects differing by port number are now not equal.
Additionally, __ne__() was not implemented for URL which
caused unexpected result when != was used in Python2, since there are no
implied relationships among the comparison operators in Python2.
References: #4406
[bug] [orm] Fixed a regression in 1.2 where a wildcard/load_only loader option would not work correctly against a loader path where of_type() were use
Released: February 15, 2019
[bug] [orm] Fixed a regression in 1.2 where a wildcard/load_only loader option would not work correctly against a loader path where of_type() were used to limit to a particular subclass. The fix only works for of_type() of a simple subclass so far, not a with_polymorphic entity which will be addressed in a separate issue; it is unlikely this latter case was working previously.
References: #4468
[bug] [orm] Fixed fairly simple but critical issue where the
SessionEvents.pending_to_persistent() event would be invoked for
objects not just when they move from pending to persistent, but when they
were also already persistent and just being updated, thus causing the event
to be invoked for all objects on every update.
References: #4489
[bug] [sql] Fixed issue where the JSON type had a read-only
JSON.should_evaluate_none attribute, which would cause failures
when making use of the TypeEngine.evaluates_none() method in
conjunction with this type. Pull request courtesy Sanjana S.
References: #4485
[bug] [mssql] Fixed bug where the SQL Server "IDENTITY_INSERT" logic that allows an INSERT
to proceed with an explicit value on an IDENTITY column was not detecting
the case where Insert.values() were used with a dictionary that
contained a Column as key and a SQL expression as a value.
References: #4499
[bug] [sqlite] Fixed bug in SQLite DDL where using an expression as a server side default required that it be contained within parenthesis to be accepted by the sqlite parser. Pull request courtesy Bartlomiej Biernacki.
References: #4474
[bug] [mysql] Fixed a second regression caused by #4344 (the first was
#4361), which works around MySQL issue 88718, where the lower
casing function used was not correct for Python 2 with OSX/Windows casing
conventions, which would then raise TypeError. Full coverage has been
added to this logic so that every codepath is exercised in a mock style for
all three casing conventions on all versions of Python. MySQL 8.0 has
meanwhile fixed issue 88718 so the workaround is only applies to a
particular span of MySQL 8.0 versions.
References: #4492
…function, as the consrc column is being deprecated in PG 12. Thanks to John A Stevenson for the tip.
Released: January 25, 2019
[feature] [orm] Added new event hooks QueryEvents.before_compile_update() and
QueryEvents.before_compile_delete() which complement
QueryEvents.before_compile() in the case of the Query.update()
and Query.delete() methods.
References: #4461
[bug] [postgresql] Revised the query used when reflecting CHECK constraints to make use of the
pg_get_constraintdef function, as the consrc column is being
deprecated in PG 12. Thanks to John A Stevenson for the tip.
References: #4463
[bug] [orm] Fixed issue where when using single-table inheritance in conjunction with a joined inheritance hierarchy that uses "with polymorphic" loading, the "single table criteria" for that single-table entity could get confused for that of other entities from the same hierarchy used in the same query.The adaption of the "single table criteria" is made more specific to the target entity to avoid it accidentally getting adapted to other tables in the query.
References: #4454
[bug] [oracle] Fixed regression in integer precision logic due to the refactor of the cx_Oracle dialect in 1.2. We now no longer apply the cx_Oracle.NATIVE_INT type to result columns sending integer values (detected as positive precision with scale ==0) which encounters integer overflow issues with values that go beyond the 32 bit boundary. Instead, the output variable is left untyped so that cx_Oracle can choose the best option.
References: #4457
Fixed issue in "expanding IN" feature where using the same bound parameter name more than once in a query would lead to a KeyError within the process
Released: January 11, 2019
Fixed issue in "expanding IN" feature where using the same bound parameter name more than once in a query would lead to a KeyError within the process of rewriting the parameters in the query.
References: #4394
[bug] [postgresql] Fixed issue where a postgresql.ENUM or a custom domain present
in a remote schema would not be recognized within column reflection if
the name of the enum/domain or the name of the schema required quoting.
A new parsing scheme now fully parses out quoted or non-quoted tokens
including support for SQL-escaped quotes.
References: #4416
[bug] [postgresql] Fixed issue where multiple postgresql.ENUM objects referred to
by the same MetaData object would fail to be created if
multiple objects had the same name under different schema names. The
internal memoization the PostgreSQL dialect uses to track if it has
created a particular postgresql.ENUM in the database during
a DDL creation sequence now takes schema name into account.
[bug] [engine] Fixed a regression introduced in version 1.2 where a refactor
of the SQLAlchemyError base exception class introduced an
inappropriate coercion of a plain string message into Unicode under
python 2k, which is not handled by the Python interpreter for characters
outside of the platform's encoding (typically ascii). The
SQLAlchemyError class now passes a bytestring through under
Py2K for __str__() as is the behavior of exception objects in general
under Py2K, does a safe coercion to unicode utf-8 with
backslash fallback for __unicode__(). For Py3K the message is
typically unicode already, but if not is again safe-coerced with utf-8
with backslash fallback for the __str__() method.
References: #4429
[bug] [mysql] [oracle] [sql] Fixed issue where the DDL emitted for DropTableComment, which
will be used by an upcoming version of Alembic, was incorrect for the MySQL
and Oracle databases.
References: #4436
[bug] [sqlite] Reflection of an index based on SQL expressions are now skipped with a warning, in the same way as that of the Postgresql dialect, where we currently do not support reflecting indexes that have SQL expressions within them. Previously, an index with columns of None were produced which would break tools like Alembic.
References: #4431
[bug] [orm] Fixed bug where the ORM annotations could be incorrect for the primaryjoin/secondaryjoin a relationship if one used the pattern ForeignKey
Released: December 11, 2018
[bug] [orm] Fixed bug where the ORM annotations could be incorrect for the
primaryjoin/secondaryjoin a relationship if one used the pattern
ForeignKey(SomeClass.id) in the declarative mappings. This pattern
would leak undesired annotations into the join conditions which can break
aliasing operations done within Query that are not supposed to
impact elements in that join condition. These annotations are now removed
up front if present.
References: #4367
[bug] [declarative] [orm] A warning is emitted in the case that a column() object is applied to
a declarative class, as it seems likely this intended to be a
Column object.
References: #4374
[bug] [orm] In continuing with a similar theme as that of very recent #4349,
repaired issue with RelationshipProperty.Comparator.any() and
RelationshipProperty.Comparator.has() where the "secondary"
selectable needs to be explicitly part of the FROM clause in the
EXISTS subquery to suit the case where this "secondary" is a Join
object.
References: #4366
[bug] [orm] Fixed regression caused by #4349 where adding the "secondary"
table to the FROM clause for a dynamic loader would affect the ability of
the Query to make a subsequent join to another entity. The fix
adds the primary entity as the first element of the FROM list since
Query.join() wants to jump from that. Version 1.3 will have
a more comprehensive solution to this problem as well (#4365).
References: #4363
[bug] [orm] Fixed bug where chaining of mapper options using
RelationshipProperty.of_type() in conjunction with a chained option
that refers to an attribute name by string only would fail to locate the
attribute.
Added support for the write_timeout flag accepted by mysqlclient and
pymysql to be passed in the URL string.
References: #4381
Fixed issue where reflection of a PostgreSQL domain that is expressed as an array would fail to be recognized. Pull request courtesy Jakub Synowiec.
[bug] [orm] Fixed bug in Session.bulk_update_mappings() where alternate mapped attribute names would result in the primary key column of the UPDATE st
Released: November 10, 2018
[bug] [orm] Fixed bug in Session.bulk_update_mappings() where alternate mapped
attribute names would result in the primary key column of the UPDATE
statement being included in the SET clause, as well as the WHERE clause;
while usually harmless, for SQL Server this can raise an error due to the
IDENTITY column. This is a continuation of the same bug that was fixed in
#3849, where testing was insufficient to catch this additional
flaw.
References: #4357
[bug] [mysql] Fixed regression caused by #4344 released in 1.2.13, where the fix
for MySQL 8.0's case sensitivity problem with referenced column names when
reflecting foreign key referents is worked around using the
information_schema.columns view. The workaround was failing on OSX /
lower_case_table_names=2 which produces non-matching casing for the
information_schema.columns vs. that of SHOW CREATE TABLE, so in
case-insensitive SQL modes case-insensitive matching is now used.
References: #4361
[bug] [orm] Fixed a minor performance issue which could in some cases add unnecessary overhead to result fetching, involving the use of ORM columns and entities that include those same columns at the same time within a query. The issue has to do with hash / eq overhead when referring to the column in different ways.
References: #4347
[bug] [postgresql] Added support for the aggregate_order_by function to receive multiple ORDER BY elements, previously only a single element was accep
Released: October 31, 2018
[bug] [postgresql] Added support for the aggregate_order_by function to receive
multiple ORDER BY elements, previously only a single element was accepted.
References: #4337
[bug] [mysql] Added word function to the list of reserved words for MySQL, which is
now a keyword in MySQL 8.0
References: #4348
[feature] [sql] Refactored SQLCompiler to expose a
SQLCompiler.group_by_clause() method similar to the
SQLCompiler.order_by_clause() and SQLCompiler.limit_clause()
methods, which can be overridden by dialects to customize how GROUP BY
renders. Pull request courtesy Samuel Chou.
[bug] [misc] Fixed issue where part of the utility language helper internals was passing
the wrong kind of argument to the Python __import__ builtin as the list
of modules to be imported. The issue produced no symptoms within the core
library but could cause issues with external applications that redefine the
__import__ builtin or otherwise instrument it. Pull request courtesy Joe
Urciuoli.
[bug] [orm] Fixed bug where "dynamic" loader needs to explicitly set the "secondary" table in the FROM clause of the query, to suit the case where the secondary is a join object that is otherwise not pulled into the query from its columns alone.
References: #4349
[bug] [declarative] [orm] Fixed regression caused by #4326 in version 1.2.12 where using
declared_attr with a mixin in conjunction with
orm.synonym() would fail to map the synonym properly to an inherited
subclass.
References: #4350
[bug] [misc] [py3k] Fixed additional warnings generated by Python 3.7 due to changes in the
organization of the Python collections and collections.abc packages.
Previous collections warnings were fixed in version 1.2.11. Pull request
courtesy xtreak.
References: #4339
[bug] [ext] Added missing .index() method to list-based association collections
in the association proxy extension.
[bug] [mysql] Added a workaround for a MySQL bug #88718 introduced in the 8.0 series, where the reflection of a foreign key constraint is not reporting the correct case sensitivity for the referred column, leading to errors during use of the reflected constraint such as when using the automap extension. The workaround emits an additional query to the information_schema tables in order to retrieve the correct case sensitive name.
References: #4344
[bug] [sql] Fixed bug where the Enum.create_constraint flag on the
Enum datatype would not be propagated to copies of the type, which
affects use cases such as declarative mixins and abstract bases.
References: #4341
[bug] [declarative] [orm] The column conflict resolution technique discussed at
declarative_column_conflicts is now functional for a Column
that is also a primary key column. Previously, a check for primary key
columns declared on a single-inheritance subclass would occur before the
column copy were allowed to pass.
References: #4352
[bug] [postgresql] Fixed bug in PostgreSQL dialect where compiler keyword arguments such as literal_binds=True were not being propagated to a DISTINCT
Released: September 19, 2018
[bug] [postgresql] Fixed bug in PostgreSQL dialect where compiler keyword arguments such as
literal_binds=True were not being propagated to a DISTINCT ON
expression.
References: #4325
[bug] [ext] Fixed issue where BakedQuery did not include the specific query
class used by the Session as part of the cache key, leading to
incompatibilities when using custom query classes, in particular the
ShardedQuery which has some different argument signatures.
References: #4328
[bug] [postgresql] Fixed the postgresql.array_agg() function, which is a slightly
altered version of the usual functions.array_agg() function, to also
accept an incoming "type" argument without forcing an ARRAY around it,
essentially the same thing that was fixed for the generic function in 1.1
in #4107.
References: #4324
[bug] [postgresql] Fixed bug in PostgreSQL ENUM reflection where a case-sensitive, quoted name would be reported by the query including quotes, which would not match a target column during table reflection as the quotes needed to be stripped off.
References: #4323
[bug] [orm] Added a check within the weakref cleanup for the InstanceState
object to check for the presence of the dict builtin, in an effort to
reduce error messages generated when these cleanups occur during interpreter
shutdown. Pull request courtesy Romuald Brunet.
[bug] [declarative] [orm] Fixed bug where the declarative scan for attributes would receive the
expression proxy delivered by a hybrid attribute at the class level, and
not the hybrid attribute itself, when receiving the descriptor via the
@declared_attr callable on a subclass of an already-mapped class. This
would lead to an attribute that did not report itself as a hybrid when
viewed within Mapper.all_orm_descriptors.
References: #4326
[bug] [orm] Fixed bug where use of Lateral construct in conjunction with
Query.join() as well as Query.select_entity_from() would not
apply clause adaption to the right side of the join. "lateral" introduces
the use case of the right side of a join being correlatable. Previously,
adaptation of this clause wasn't considered. Note that in 1.2 only,
a selectable introduced by Query.subquery() is still not adapted
due to #4304; the selectable needs to be produced by the
select() function to be the right side of the "lateral" join.
References: #4334
[bug] [oracle] Fixed issue for cx_Oracle 7.0 where the behavior of Oracle param.getvalue() now returns a list, rather than a single scalar value, breaking autoincrement logic throughout the Core and ORM. The dml_ret_array_val compatibility flag is used for cx_Oracle 6.3 and 6.4 to establish compatible behavior with 7.0 and forward, for cx_Oracle 6.2.1 and prior a version number check falls back to the old logic.
References: #4335
[bug] [orm] Fixed 1.2 regression caused by #3472 where the handling of an "updated_at" style column within the context of a post-update operation would also occur for a row that is to be deleted following the update, meaning both that a column with a Python-side value generator would show the now-deleted value that was emitted for the UPDATE before the DELETE (which was not the previous behavior), as well as that a SQL- emitted value generator would have the attribute expired, meaning the previous value would be unreachable due to the row having been deleted and the object detached from the session.The "postfetch" logic that was added as part of #3472 is now skipped entirely for an object that ultimately is to be deleted.
References: #4327
[bug] [py3k] Started importing "collections" from "collections.abc" under Python 3.3 and greater for Python 3.8 compatibility. Pull request courtesy N
Released: August 20, 2018
[bug] [py3k] Started importing "collections" from "collections.abc" under Python 3.3 and greater for Python 3.8 compatibility. Pull request courtesy Nathaniel Knight.
Fixed issue where the "schema" name used for a SQLite database within table reflection would not quote the schema name correctly. Pull request courtesy Phillip Cloud.
[bug] [sql] Fixed issue that is closely related to #3639 where an expression
rendered in a boolean context on a non-native boolean backend would
be compared to 1/0 even though it is already an implicitly boolean
expression, when ColumnElement.self_group() were used. While this
does not affect the user-friendly backends (MySQL, SQLite) it was not
handled by Oracle (and possibly SQL Server). Whether or not the
expression is implicitly boolean on any database is now determined
up front as an additional check to not generate the integer comparison
within the compilation of the statement.
References: #4320
[bug] [oracle] For cx_Oracle, Integer datatypes will now be bound to "int", per advice from the cx_Oracle developers. Previously, using cx_Oracle.NUMBER caused a loss in precision within the cx_Oracle 6.x series.
References: #4309
[bug] [declarative] [orm] Fixed issue in previously untested use case, allowing a declarative mapped
class to inherit from a classically-mapped class outside of the declarative
base, including that it accommodates for unmapped intermediate classes. An
unmapped intermediate class may specify __abstract__, which is now
interpreted correctly, or the intermediate class can remain unmarked, and
the classically mapped base class will be detected within the hierarchy
regardless. In order to anticipate existing scenarios which may be mixing
in classical mappings into existing declarative hierarchies, an error is
now raised if multiple mapped bases are detected for a given class.
References: #4321
[bug] [sql] Added missing window function parameters
WithinGroup.over.range_ and WithinGroup.over.rows
parameters to the WithinGroup.over() and
FunctionFilter.over() methods, to correspond to the range/rows
feature added to the "over" method of SQL functions as part of
#3049 in version 1.1.
References: #4322
[bug] [sql] Fixed bug where the multi-table support for UPDATE and DELETE statements
did not consider the additional FROM elements as targets for correlation,
when a correlated SELECT were also combined with the statement. This
change now includes that a SELECT statement in the WHERE clause for such a
statement will try to auto-correlate back to these additional tables in the
parent UPDATE/DELETE or unconditionally correlate if
Select.correlate() is used. Note that auto-correlation raises an
error if the SELECT statement would have no FROM clauses as a result, which
can now occur if the parent UPDATE/DELETE specifies the same tables in its
additional set of tables; specify Select.correlate() explicitly to
resolve.
References: #4313
[bug] [sql] Fixed bug where a Sequence would be dropped explicitly before any Table that refers to it, which breaks in the case when the sequence is a
Released: July 13, 2018
[bug] [sql] Fixed bug where a Sequence would be dropped explicitly before any
Table that refers to it, which breaks in the case when the
sequence is also involved in a server-side default for that table, when
using MetaData.drop_all(). The step which processes sequences
to be dropped via non server-side column default functions is now invoked
after the table itself is dropped.
References: #4300
[bug] [orm] Fixed bug in Bundle construct where placing two columns of the
same name would be de-duplicated, when the Bundle were used as
part of the rendered SQL, such as in the ORDER BY or GROUP BY of the statement.
References: #4295
[bug] [orm] Fixed regression in 1.2.9 due to #4287 where using a
Load option in conjunction with a string wildcard would result
in a TypeError.
References: #4298
…standard library, as inspect.formatargspec() is deprecated and as of Python 3.7.0 is emitting a warning.
Released: June 29, 2018
[bug] [mysql] Fixed percent-sign doubling in mysql-connector-python dialect, which does not require de-doubling of percent signs. Additionally, the mysql- connector-python driver is inconsistent in how it passes the column names in cursor.description, so a workaround decoder has been added to conditionally decode these randomly-sometimes-bytes values to unicode only if needed. Also improved test support for mysql-connector-python, however it should be noted that this driver still has issues with unicode that continue to be unresolved as of yet.
[bug] [mssql] Fixed bug in MSSQL reflection where when two same-named tables in different schemas had same-named primary key constraints, foreign key constraints referring to one of the tables would have their columns doubled, causing errors. Pull request courtesy Sean Dunn.
References: #4288
[bug] [sql] Fixed regression in 1.2 due to #4147 where a Table that
has had some of its indexed columns redefined with new ones, as would occur
when overriding columns during reflection or when using
Table.extend_existing, such that the Table.tometadata()
method would fail when attempting to copy those indexes as they still
referred to the replaced column. The copy logic now accommodates for this
condition.
References: #4279
[bug] [mysql] Fixed bug in index reflection where on MySQL 8.0 an index that includes ASC or DESC in an indexed column specification would not be correctly reflected, as MySQL 8.0 introduces support for returning this information in a table definition string.
References: #4293
[bug] [orm] Fixed issue where chaining multiple join elements inside of
Query.join() might not correctly adapt to the previous left-hand
side, when chaining joined inheritance classes that share the same base
class.
References: #3505
[bug] [orm] Fixed bug in cache key generation for baked queries which could cause a too-short cache key to be generated for the case of eager loads across subclasses. This could in turn cause the eagerload query to be cached in place of a non-eagerload query, or vice versa, for a polymorhic "selectin" load, or possibly for lazy loads or selectin loads as well.
References: #4287
[bug] [sqlite] Fixed issue in test suite where SQLite 3.24 added a new reserved word that conflicted with a usage in TypeReflectionTest. Pull request courtesy Nils Philippsen.
[feature] [oracle] Added a new event currently used only by the cx_Oracle dialect,
DialectEvents.setiputsizes(). The event passes a dictionary of
BindParameter objects to DBAPI-specific type objects that will be
passed, after conversion to parameter names, to the cx_Oracle
cursor.setinputsizes() method. This allows both visibility into the
setinputsizes process as well as the ability to alter the behavior of what
datatypes are passed to this method.
References: #4290
[bug] [orm] Fixed bug in new polymorphic selectin loading where the BakedQuery used internally would be mutated by the given loader options, which would both inappropriately mutate the subclass query as well as carry over the effect to subsequent queries.
References: #4286
[bug] [py3k] Replaced the usage of inspect.formatargspec() with a vendored version copied from the Python standard library, as inspect.formatargspec() is deprecated and as of Python 3.7.0 is emitting a warning.
References: #4291
[ext] [feature] Added new attribute Query.lazy_loaded_from which is populated
with an InstanceState that is using this Query in
order to lazy load a relationship. The rationale for this is that
it serves as a hint for the horizontal sharding feature to use, such that
the identity token of the state can be used as the default identity token
to use for the query within id_chooser().
References: #4243
[bug] [mysql] Fixed bug in MySQLdb dialect and variants such as PyMySQL where an additional "unicode returns" check upon connection makes explicit use of the "utf8" character set, which in MySQL 8.0 emits a warning that utf8mb4 should be used. This is now replaced with a utf8mb4 equivalent. Documentation is also updated for the MySQL dialect to specify utf8mb4 in all examples. Additional changes have been made to the test suite to use utf8mb3 charsets and databases (there seem to be collation issues in some edge cases with utf8mb4), and to support configuration default changes made in MySQL 8.0 such as explicit_defaults_for_timestamp as well as new errors raised for invalid MyISAM indexes.
References: #4283
[bug] [mysql] The Update construct now accommodates a Join object
as supported by MySQL for UPDATE..FROM. As the construct already
accepted an alias object for a similar purpose, the feature of UPDATE
against a non-table was already implied so this has been added.
References: #3645
[bug] [mssql] [py3k] Fixed issue within the SQL Server dialect under Python 3 where when running against a non-standard SQL server database that does not contain either the "sys.dm_exec_sessions" or "sys.dm_pdw_nodes_exec_sessions" views, leading to a failure to fetch the isolation level, the error raise would fail due to an UnboundLocalError.
References: #4273
[bug] [orm] Fixed regression caused by #4256 (itself a regression fix for
#4228) which breaks an undocumented behavior which converted for a
non-sequence of entities passed directly to the Query constructor
into a single-element sequence. While this behavior was never supported or
documented, it's already in use so has been added as a behavioral contract
to Query.
References: #4269
[bug] [orm] Fixed an issue that was both a performance regression in 1.2 as well as an
incorrect result regarding the "baked" lazy loader, involving the
generation of cache keys from the original Query object's loader
options. If the loader options were built up in a "branched" style using
common base elements for multiple options, the same options would be
rendered into the cache key repeatedly, causing both a performance issue as
well as generating the wrong cache key. This is fixed, along with a
performance improvement when such "branched" options are applied via
Query.options() to prevent the same option objects from being
applied repeatedly.
References: #4270
[bug] [mysql] [oracle] Fixed INSERT FROM SELECT with CTEs for the Oracle and MySQL dialects, where the CTE was being placed above the entire statement as is typical with other databases, however Oracle and MariaDB 10.2 wants the CTE underneath the "INSERT" segment. Note that the Oracle and MySQL dialects don't yet work when a CTE is applied to a subquery inside of an UPDATE or DELETE statement, as the CTE is still applied to the top rather than inside the subquery.
References: #4275
[bug] [orm] Fixed regression in 1.2.7 caused by #4228, which itself was fixing a 1.2-level regression, where the query_cls callable passed to a Sessio
Released: May 28, 2018
[bug] [orm] Fixed regression in 1.2.7 caused by #4228, which itself was fixing
a 1.2-level regression, where the query_cls callable passed to a
Session was assumed to be a subclass of Query with
class method availability, as opposed to an arbitrary callable. In
particular, the dogpile caching example illustrates query_cls as a
function and not a Query subclass.
References: #4256
[bug] [engine] Fixed connection pool issue whereby if a disconnection error were raised
during the connection pool's "reset on return" sequence in conjunction with
an explicit transaction opened against the enclosing Connection
object (such as from calling Session.close() without a rollback or
commit, or calling Connection.close() without first closing a
transaction declared with Connection.begin()), a double-checkin would
result, which could then lead towards concurrent checkouts of the same
connection. The double-checkin condition is now prevented overall by an
assertion, as well as the specific double-checkin scenario has been
fixed.
References: #4252
[bug] [oracle] The Oracle BINARY_FLOAT and BINARY_DOUBLE datatypes now participate within
cx_Oracle.setinputsizes(), passing along NATIVE_FLOAT, so as to support the
NaN value. Additionally, oracle.BINARY_FLOAT,
oracle.BINARY_DOUBLE and oracle.DOUBLE_PRECISION now
subclass Float, since these are floating point datatypes, not
decimal. These datatypes were already defaulting the
Float.asdecimal flag to False in line with what
Float already does.
References: #4264
[bug] [oracle] Added reflection capabilities for the oracle.BINARY_FLOAT,
oracle.BINARY_DOUBLE datatypes.
[bug] [ext] The horizontal sharding extension now makes use of the identity token added to ORM identity keys as part of #4137, when an object refresh or column-based deferred load or unexpiration operation occurs. Since we know the "shard" that the object originated from, we make use of this value when refreshing, thereby avoiding queries against other shards that don't match this object's identity in any case.
References: #4247
[bug] [sql] Fixed issue where the "ambiguous literal" error message used when interpreting literal values as SQL expression values would encounter a tuple value, and fail to format the message properly. Pull request courtesy Miguel Ventura.
[bug] [mssql] Fixed a 1.2 regression caused by #4061 where the SQL Server "BIT" type would be considered to be "native boolean". The goal here was to avoid creating a CHECK constraint on the column, however the bigger issue is that the BIT value does not behave like a true/false constant and cannot be interpreted as a standalone expression, e.g. "WHERE <column>". The SQL Server dialect now goes back to being non-native boolean, but with an extra flag that still avoids creating the CHECK constraint.
References: #4250
[bug] [oracle] Altered the Oracle dialect such that when an Integer type is in
use, the cx_Oracle.NUMERIC type is set up for setinputsizes(). In
SQLAlchemy 1.1 and earlier, cx_Oracle.NUMERIC was passed for all numeric
types unconditionally, and in 1.2 this was removed to allow for better
numeric precision. However, for integers, some database/client setups
will fail to coerce boolean values True/False into integers which introduces
regressive behavior when using SQLAlchemy 1.2. Overall, the setinputsizes
logic seems like it will need a lot more flexibility going forward so this
is a start for that.
References: #4259
[bug] [engine] Fixed a reference leak issue where the values of the parameter dictionary used in a statement execution would remain referenced by the "compiled cache", as a result of storing the key view used by Python 3 dictionary keys(). Pull request courtesy Olivier Grisel.
[bug] [orm] Fixed a long-standing regression that occurred in version
1.0, which prevented the use of a custom MapperOption
that alters the _params of a Query object for a
lazy load, since the lazy loader itself would overwrite those
parameters. This applies to the "temporal range" example
on the wiki. Note however that the
Query.populate_existing() method is now required in
order to rewrite the mapper options associated with an object
already loaded in the identity map.
As part of this change, a custom defined
MapperOption will now cause lazy loaders related to
the target object to use a non-baked query by default unless
the MapperOption._generate_cache_key() method is implemented.
In particular, this repairs one regression which occurred when
using the dogpile.cache "advanced" example, which was not
returning cached results and instead emitting SQL due to an
incompatibility with the baked query loader; with the change,
the RelationshipCache option included for many releases
in the dogpile example will disable the "baked" query altogether.
Note that the dogpile example is also modernized to avoid both
of these issues as part of issue #4258.
References: #4128
[bug] [ext] Fixed a race condition which could occur if automap
AutomapBase.prepare() were used within a multi-threaded context
against other threads which may call configure_mappers() as a
result of use of other mappers. The unfinished mapping work of automap
is particularly sensitive to being pulled in by a
configure_mappers() step leading to errors.
References: #4266
[bug] [orm] Fixed bug where the new baked.Result.with_post_criteria()
method would not interact with a subquery-eager loader correctly,
in that the "post criteria" would not be applied to embedded
subquery eager loaders. This is related to #4128 in that
the post criteria feature is now used by the lazy loader.
[bug] [tests] Fixed a bug in the test suite where if an external dialect returned
None for server_version_info, the exclusion logic would raise an
AttributeError.
References: #4249
[bug] [orm] Updated the dogpile.caching example to include new structures that accommodate for the "baked" query system, which is used by default within lazy loaders and some eager relationship loaders. The dogpile.caching "relationship_caching" and "advanced" examples were also broken due to #4256. The issue here is also worked-around by the fix in #4128.
References: #4258
[bug] [orm] Fixed regression in 1.2 within sharded query feature where the new "identity_token" element was not being correctly considered within the
Released: April 20, 2018
[bug] [orm] Fixed regression in 1.2 within sharded query feature where the
new "identity_token" element was not being correctly considered within
the scope of a lazy load operation, when searching the identity map
for a related many-to-one element. The new behavior will allow for
making use of the "id_chooser" in order to determine the best identity
key to retrieve from the identity map. In order to achieve this, some
refactoring of 1.2's "identity_token" approach has made some slight changes
to the implementation of ShardedQuery which should be noted for other
derivations of this class.
References: #4228
[bug] [postgresql] Fixed bug where the special "not equals" operator for the PostgreSQL
"range" datatypes such as DATERANGE would fail to render "IS NOT NULL" when
compared to the Python None value.
References: #4229
[bug] [mssql] Fixed 1.2 regression caused by #4060 where the query used to reflect SQL Server cross-schema foreign keys was limiting the criteria incorrectly.
References: #4234
[bug] [oracle] The Oracle NUMBER datatype is reflected as INTEGER if the precision is NULL and the scale is zero, as this is how INTEGER values come back when reflected from Oracle's tables. Pull request courtesy Kent Bower.
[feature] [postgresql] Added new PG type postgresql.REGCLASS which assists in casting
table names to OID values. Pull request courtesy Sebastian Bank.
References: #4160
[bug] [sql] Fixed issue where the compilation of an INSERT statement with the "literal_binds" option that also uses an explicit sequence and "inline" generation, as on PostgreSQL and Oracle, would fail to accommodate the extra keyword argument within the sequence processing routine.
References: #4231
[bug] [orm] Fixed issue in single-inheritance loading where the use of an aliased
entity against a single-inheritance subclass in conjunction with the
Query.select_from() method would cause the SQL to be rendered with
the unaliased table mixed in to the query, causing a cartesian product. In
particular this was affecting the new "selectin" loader when used against a
single-inheritance subclass.
References: #4241
[bug] [mssql] Adjusted the SQL Server version detection for pyodbc to only allow for numeric tokens, filtering out non-integers, since the dialect doe
Released: March 30, 2018
[bug] [mssql] Adjusted the SQL Server version detection for pyodbc to only allow for numeric tokens, filtering out non-integers, since the dialect does tuple- numeric comparisons with this value. This is normally true for all known SQL Server / pyodbc drivers in any case.
References: #4227
[feature] [postgresql] Added support for "PARTITION BY" in PostgreSQL table definitions, using "postgresql_partition_by". Pull request courtesy Vsevolod Solovyov.
[bug] [sql] Fixed a regression that occurred from the previous fix to #4204 in
version 1.2.5, where a CTE that refers to itself after the
CTE.alias() method has been called would not refer to itself
correctly.
References: #4204
[bug] [engine] Fixed bug in connection pool where a connection could be present in the pool without all of its "connect" event handlers called, if a previous "connect" handler threw an exception; note that the dialects themselves have connect handlers that emit SQL, such as those which set transaction isolation, which can fail if the database is in a non-available state, but still allows a connection. The connection is now invalidated first if any of the connect handlers fail.
References: #4225
[bug] [oracle] The minimum cx_Oracle version supported is 5.2 (June 2015). Previously, the dialect asserted against version 5.0 but as of 1.2.2 we are using some symbols that did not appear until 5.2.
References: #4211
[bug] [declarative] Removed a warning that would be emitted when calling upon
__table_args__, __mapper_args__ as named with a @declared_attr
method, when called from a non-mapped declarative mixin. Calling these
directly is documented as the approach to use when one is overriding one
of these methods on a mapped class. The warning still emits for regular
attribute names.
References: #4221
[bug] [orm] Fixed bug where using Mutable.associate_with() or
Mutable.as_mutable() in conjunction with a class that has non-
primary mappers set up with alternatively-named attributes would produce an
attribute error. Since non-primary mappers are not used for persistence,
the mutable extension now excludes non-primary mappers from its
instrumentation steps.
References: #4215
[bug] [mysql] MySQL dialects now query the server version using SELECT @@version explicitly to the server to ensure we are getting the correct version
Released: March 6, 2018
[bug] [mysql] MySQL dialects now query the server version using SELECT @@version
explicitly to the server to ensure we are getting the correct version
information back. Proxy servers like MaxScale interfere with the value
that is passed to the DBAPI's connection.server_version value so this
is no longer reliable.
This change is also backported to: 1.1.18
References: #4205
[bug] [postgresql] [py3k] Fixed bug in PostgreSQL COLLATE / ARRAY adjustment first introduced in #4006 where new behaviors in Python 3.7 regular expressions caused the fix to fail.
This change is also backported to: 1.1.18
References: #4208
[bug] [sql] Fixed bug in :class:.CTE construct along the same lines as that of
#4204 where a CTE that was aliased would not copy itself
correctly during a "clone" operation as is frequent within the ORM as well
as when using the ClauseElement.params() method.
References: #4210
[bug] [orm] Fixed bug in new "polymorphic selectin" loading when a selection of polymorphic objects were to be partially loaded from a relationship lazy loader, leading to an "empty IN" condition within the load that raises an error for the "inline" form of "IN".
References: #4199
[bug] [sql] Fixed bug in CTE rendering where a CTE that was also turned into
an Alias would not render its "ctename AS aliasname" clause
appropriately if there were more than one reference to the CTE in a FROM
clause.
References: #4204
[bug] [orm] Fixed 1.2 regression where a mapper option that contains an
AliasedClass object, as is typical when using the
QueryableAttribute.of_type() method, could not be pickled. 1.1's
behavior was to omit the aliased class objects from the path, so this
behavior is restored.
References: #4209
[feature] [orm] Added new feature Query.only_return_tuples(). Causes the
Query object to return keyed tuple objects unconditionally even
if the query is against a single entity. Pull request courtesy Eric
Atkin.
[bug] [sql] Fixed bug in new "expanding IN parameter" feature where the bind parameter processors for values wasn't working at all, tests failed to cover this pretty basic case which includes that ENUM values weren't working.
References: #4198
[bug] [orm] Fixed 1.2 regression in ORM versioning feature where a mapping against a select() or alias() that also used a versioning column against th
Released: February 22, 2018
[bug] [orm] Fixed 1.2 regression in ORM versioning feature where a mapping against a
select() or alias() that also used a versioning column
against the underlying table would fail due to the check added as part of
#3673.
References: #4193
[bug] [engine] Fixed regression caused in 1.2.3 due to fix from #4181 where
the changes to the event system involving Engine and
OptionEngine did not accommodate for event removals, which
would raise an AttributeError when invoked at the class
level.
References: #4190
[bug] [sql] Fixed bug where CTE expressions would not have their name or alias name quoted when the given name is case sensitive or otherwise requires quoting. Pull request courtesy Eric Atkin.
References: #4197
[bug] [postgresql] Added "SSL SYSCALL error: Operation timed out" to the list of messages that trigger a "disconnect" scenario for the psycopg2 driver
Released: February 16, 2018
[bug] [postgresql] Added "SSL SYSCALL error: Operation timed out" to the list of messages that trigger a "disconnect" scenario for the psycopg2 driver. Pull request courtesy André Cruz.
This change is also backported to: 1.1.16
[bug] [orm] Fixed issue in post_update feature where an UPDATE is emitted when the parent object has been deleted but the dependent object is not. This issue has existed for a long time however since 1.2 now asserts rows matched for post_update, this was raising an error.
This change is also backported to: 1.1.16
References: #4187
[bug] [orm] Fixed regression caused by fix for issue #4116 affecting versions
1.2.2 as well as 1.1.15, which had the effect of mis-calculation of the
"owning class" of an AssociationProxy as the NoneType class
in some declarative mixin/inheritance situations as well as if the
association proxy were accessed off of an un-mapped class. The "figure out
the owner" logic has been replaced by an in-depth routine that searches
through the complete mapper hierarchy assigned to the class or subclass to
determine the correct (we hope) match; will not assign the owner if no
match is found. An exception is now raised if the proxy is used
against an un-mapped instance.
This change is also backported to: 1.1.16
References: #4185
[bug] [postgresql] Added "TRUNCATE" to the list of keywords accepted by the PostgreSQL dialect as an "autocommit"-triggering keyword. Pull request courtesy Jacob Hayes.
This change is also backported to: 1.1.16
[bug] [pool] Fixed a fairly serious connection pool bug where a connection that is
acquired after being refreshed as a result of a user-defined
DisconnectionError or due to the 1.2-released "pre_ping" feature
would not be correctly reset if the connection were returned to the pool by
weakref cleanup (e.g. the front-facing object is garbage collected); the
weakref would still refer to the previously invalidated DBAPI connection
which would have the reset operation erroneously called upon it instead.
This would lead to stack traces in the logs and a connection being checked
into the pool without being reset, which can cause locking issues.
This change is also backported to: 1.1.16
References: #4184
[bug] [oracle] Fixed bug in cx_Oracle disconnect detection, used by pre_ping and other features, where an error could be raised as DatabaseError which includes a numeric error code; previously we weren't checking in this case for a disconnect code.
References: #4182
[bug] [sqlite] Fixed the import error raised when a platform has neither pysqlite2 nor sqlite3 installed, such that the sqlite3-related import error is raised, not the pysqlite2 one which is not the actual failure mode. Pull request courtesy Robin.
[bug] [orm] Fixed bug where the Bundle object did not
correctly report upon the primary Mapper object
represented by the bundle, if any. An immediate
side effect of this issue was that the new selectinload
loader strategy wouldn't work with the horizontal sharding
extension.
References: #4175
[bug] [sql] Fixed bug where the Enum type wouldn't handle
enum "aliases" correctly, when more than one key refers to the
same value. Pull request courtesy Daniel Knell.
References: #4180
[bug] [engine] Fixed bug where events associated with an Engine
at the class level would be doubled when the
Engine.execution_options() method were used. To
achieve this, the semi-private class OptionEngine
no longer accepts events directly at the class level
and will raise an error; the class only propagates class-level
events from its parent Engine. Instance-level
events continue to work as before.
References: #4181
[bug] [tests] A test added in 1.2 thought to confirm a Python 2.7 behavior turns out to be confirming the behavior only as of Python 2.7.8. Python bug #8743 still impacts set comparison in Python 2.7.7 and earlier, so the test in question involving AssociationSet no longer runs for these older Python 2.7 versions.
References: #3265
[feature] [oracle] The ON DELETE options for foreign keys are now part of Oracle reflection. Oracle does not support ON UPDATE cascades. Pull request courtesy Miroslav Shubernetskiy.
[bug] [orm] Fixed bug in concrete inheritance mapping where user-defined attributes such as hybrid properties that mirror the names of mapped attributes from sibling classes would be overwritten by the mapper as non-accessible at the instance level. Additionally ensured that user-bound descriptors are not implicitly invoked at the class level during the mapper configuration stage.
References: #4188
[bug] [orm] Fixed bug where the orm.reconstructor() event
helper would not be recognized if it were applied to the
__init__() method of the mapped class.
References: #4178
[bug] [engine] The URL object now allows query keys to be specified multiple
times where their values will be joined into a list. This is to support
the plugins feature documented at CreateEnginePlugin which
documents that "plugin" can be passed multiple times. Additionally, the
plugin names can be passed to create_engine() outside of the URL
using the new create_engine.plugins parameter.
References: #4170
[feature] [sql] Added support for Enum to persist the values of the enumeration,
rather than the keys, when using a Python pep-435 style enumerated object.
The user supplies a callable function that will return the string values to
be persisted. This allows enumerations against non-string values to be
value-persistable as well. Pull request courtesy Jon Snyder.
References: #3906
[feature] [orm] Added new argument attributes.set_attribute.inititator
to the attributes.set_attribute() function, allowing an
event token received from a listener function to be propagated
to subsequent set events.
[bug] [mssql] Added ODBC error code 10054 to the list of error codes that count as a disconnect for ODBC / MSSQL server.
Released: January 24, 2018
[bug] [mssql] Added ODBC error code 10054 to the list of error codes that count as a disconnect for ODBC / MSSQL server.
References: #4164
[bug] [orm] Fixed 1.2 regression regarding new bulk_replace event where a backref would fail to remove an object from the previous owner when a bulk-assignment assigned the object to a new owner.
References: #4171
[bug] [oracle] The cx_Oracle dialect now calls setinputsizes() with cx_Oracle.NCHAR unconditionally when the NVARCHAR2 datatype, in SQLAlchemy corresponding to sqltypes.Unicode(), is in use. Per cx_Oracle's author this allows the correct conversions to occur within the Oracle client regardless of the setting for NLS_NCHAR_CHARACTERSET.
References: #4163
[bug] [mysql] Added more MySQL 8.0 reserved words to the MySQL dialect for quoting purposes. Pull request courtesy Riccardo Magliocchetti.
[bug] [sql] Fixed bug in Insert.values() where using the "multi-values" format in combination with Column objects as keys rather than strings would fa
Released: January 15, 2018
[bug] [sql] Fixed bug in Insert.values() where using the "multi-values"
format in combination with Column objects as keys rather
than strings would fail. Pull request courtesy Aubrey Stark-Toller.
This change is also backported to: 1.1.16
References: #4162
[bug] [orm] Fixed bug where an object that is expunged during a rollback of a nested or subtransaction which also had its primary key mutated would not be correctly removed from the session, causing subsequent issues in using the session.
This change is also backported to: 1.1.16
References: #4151
[bug] [orm] Fixed regression where pickle format of a Load / _UnboundLoad object (e.g.
loader options) changed and __setstate__() was raising an
UnboundLocalError for an object received from the legacy format, even
though an attempt was made to do so. tests are now added to ensure this
works.
References: #4159
[bug] [ext] Fixed regression in association proxy due to #3769 (allow for chained any() / has()) where contains() against an association proxy chained in the form (o2m relationship, associationproxy(m2o relationship, m2o relationship)) would raise an error regarding the re-application of contains() on the final link of the chain.
References: #4150
[bug] [orm] Fixed regression caused by new lazyload caching scheme in #3954 where a query that makes use of loader options with of_type would cause lazy loads of unrelated paths to fail with a TypeError.
References: #4153
[bug] [oracle] Fixed regression where the removal of most setinputsizes rules from cx_Oracle dialect impacted the TIMESTAMP datatype's ability to retrieve fractional seconds.
References: #4157
[bug] [tests] Removed an oracle-specific requirements rule from the public test suite that was interfering with third party dialect suites.
[bug] [mssql] Fixed regression in 1.2 where newly repaired quoting of collation names in #3785 breaks SQL Server, which explicitly does not understand a quoted collation name. Whether or not mixed-case collation names are quoted or not is now deferred down to a dialect-level decision so that each dialect can prepare these identifiers directly.
References: #4154
[bug] [orm] Fixed bug in new "selectin" relationship loader where the loader could try
to load a non-existent relationship when loading a collection of
polymorphic objects, where only some of the mappers include that
relationship, typically when PropComparator.of_type() is being used.
References: #4156
[bug] [tests] Added a new exclusion rule group_by_complex_expression which disables tests that use "GROUP BY <expr>", which seems to be not viable for at least two third party dialects.
[bug] [oracle] Fixed regression in Oracle imports where a missing comma caused an undefined symbol to be present. Pull request courtesy Miroslav Shubernetskiy.
[bug] [sql] Fixed bug where __repr__ of ColumnDefault would fail if the argument were a tuple. Pull request courtesy Nicolas Caniart.
Released: December 27, 2017
[bug] [sql] Fixed bug where __repr__ of ColumnDefault would fail
if the argument were a tuple. Pull request courtesy Nicolas Caniart.
This change is also backported to: 1.1.15
References: #4126
[bug] [declarative] [orm] Fixed bug where a descriptor that is elsewhere a mapped column
or relationship within a hierarchy based on AbstractConcreteBase
would be referred towards during a refresh operation, causing an error
as the attribute is not mapped as a mapper property.
A similar issue can arise for other attributes like the "type" column
added by AbstractConcreteBase if the class fails to include
"concrete=True" in its mapper, however the check here should also
prevent that scenario from causing a problem.
This change is also backported to: 1.1.15
References: #4124
[bug] [ext] [orm] Fixed bug where the association proxy would inadvertently link itself
to an AliasedClass object if it were called first with
the AliasedClass as a parent, causing errors upon subsequent
usage.
This change is also backported to: 1.1.15
References: #4116
[bug] [mysql] 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.
This change is also backported to: 1.1.15
References: #4120
[feature] [orm] Added a new data member to the identity key tuple used by the ORM's identity map, known as the "identity_token". This token defaults to None but may be used by database sharding schemes to differentiate objects in memory with the same primary key that come from different databases. The horizontal sharding extension integrates this token applying the shard identifier to it, thus allowing primary keys to be duplicated across horizontally sharded backends.
References: #4137
[bug] [mysql] Fixed regression from issue 1.2.0b3 where "MariaDB" version comparison can fail for some particular MariaDB version strings under Python 3.
References: #4115
[enhancement] [sql] Implemented "DELETE..FROM" syntax for PostgreSQL, MySQL, MS SQL Server (as well as within the unsupported Sybase dialect) in a manner similar to how "UPDATE..FROM" works. A DELETE statement that refers to more than one table will switch into "multi-table" mode and render the appropriate "USING" or multi-table "FROM" clause as understood by the database. Pull request courtesy Pieter Mulder.
References: #959
[bug] [sql] Reworked the new "autoescape" feature introduced in
change_2694 in 1.2.0b2 to be fully automatic; the escape
character now defaults to a forwards slash "/" and
is applied to percent, underscore, as well as the escape
character itself, for fully automatic escaping. The
character can also be changed using the "escape" parameter.
References: #2694
[bug] [sql] Fixed bug where the Table.tometadata() method would not properly
accommodate Index objects that didn't consist of simple
column expressions, such as indexes against a text() construct,
indexes that used SQL expressions or func, etc. The routine
now copies expressions fully to a new Index object while
substituting all table-bound Column objects for those
of the target table.
References: #4147
[bug] [sql] Changed the "visit name" of ColumnElement from "column" to
"column_element", so that when this element is used as the basis for a
user-defined SQL element, it is not assumed to behave like a table-bound
ColumnClause when processed by various SQL traversal utilities,
as are commonly used by the ORM.
References: #4142
[bug] [ext] [sql] Fixed issue in ARRAY datatype which is essentially the same
issue as that of #3832, except not a regression, where
column attachment events on top of ARRAY would not fire
correctly, thus interfering with systems which rely upon this. A key
use case that was broken by this is the use of mixins to declare
columns that make use of MutableList.as_mutable().
References: #4141
[engine] [feature] The "password" attribute of the url.URL object can now be
any user-defined or user-subclassed string object that responds to the
Python str() builtin. The object passed will be maintained as the
datamember url.URL.password_original and will be consulted
when the url.URL.password attribute is read to produce the
string value.
References: #4089
[bug] [orm] Fixed bug in contains_eager() query option where making use of a
path that used PropComparator.of_type() to refer to a subclass
across more than one level of joins would also require that the "alias"
argument were provided with the same subtype in order to avoid adding
unwanted FROM clauses to the query; additionally, using
contains_eager() across subclasses that use aliased() objects
of subclasses as the PropComparator.of_type() argument will also
render correctly.
References: #4130
[feature] [postgresql] Added new postgresql.MONEY datatype. Pull request courtesy
Cleber J Santos.
[bug] [sql] Fixed bug in new "expanding bind parameter" feature whereby if multiple params were used in one statement, the regular expression would not match the parameter name correctly.
References: #4140
[enhancement] [ext] Added new method baked.Result.with_post_criteria() to baked
query system, allowing non-SQL-modifying transformations to take place
after the query has been pulled from the cache. Among other things,
this method can be used with horizontal_shard.ShardedQuery
to set the shard identifier. horizontal_shard.ShardedQuery
has also been modified such that its ShardedQuery.get() method
interacts correctly with that of baked.Result.
References: #4135
[bug] [oracle] Added some additional rules to fully handle Decimal('Infinity'),
Decimal('-Infinity') values with cx_Oracle numerics when using
asdecimal=True.
References: #4064
[bug] [mssql] Fixed bug where sqltypes.BINARY and sqltypes.VARBINARY datatypes would not include correct bound-value handlers for pyodbc, which allows the pyodbc.NullParam value to be passed that helps with FreeTDS.
References: #4121
[feature] [misc] Added a new errors section to the documentation with background about common error messages. Selected exceptions within SQLAlchemy will include a link in their string output to the relevant section within this page.
[bug] [orm] The Query.exists() method will now disable eager loaders for when
the query is rendered. Previously, joined-eager load joins would be rendered
unnecessarily as well as subquery eager load queries would be needlessly
generated. The new behavior matches that of the Query.subquery()
method.
References: #4032
Nothing published for this version
[bug] [py3k] [tests] Fixed issue in testing fixtures which was incompatible with a change made as of Python 3.6.2 involving context managers.
Released: July 24, 2017
[bug] [py3k] [tests] Fixed issue in testing fixtures which was incompatible with a change made as of Python 3.6.2 involving context managers.
This change is also backported to: 1.1.12, 1.0.18
References: #4034
[bug] [orm] Fixed regression from 1.1.11 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 #4011.
This change is also backported to: 1.1.12
References: #4033
[bug] [orm] Fixed bug involving JSON NULL evaluation logic added in 1.1 as part
of #3514 where the logic would not accommodate ORM
mapped attributes named differently from the Column
that was mapped.
This change is also backported to: 1.1.12
References: #4031
[bug] [orm] Added KeyError checks to all methods within
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.
This change is also backported to: 1.1.12
References: #4030
[bug] [orm] Added new argument with_for_update to the Session.refresh() method. When the Query.with_lockmode() method were deprecated in favor of Quer…
Released: July 10, 2017
[feature] [oracle] [postgresql] Added new keywords Sequence.cache and
Sequence.order to 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.
This change is also backported to: 1.1.12
[bug] [sql] Fixed AttributeError which would occur in WithinGroup
construct during an iteration of the structure.
This change is also backported to: 1.1.11
References: #4012
[bug] [orm] Fixed issue with subquery eagerloading which continues on from the series of issues fixed in #2699, #3106, #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.
This change is also backported to: 1.1.11
References: #4011
[bug] [postgresql] 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.
This change is also backported to: 1.1.11
References: #4005
[bug] [postgresql] Fixed bug where using ARRAY with a string type that
features a collation would fail to produce the correct syntax
within CREATE TABLE.
This change is also backported to: 1.1.11
References: #4006
[bug] [mysql] 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.
This change is also backported to: 1.1.11
References: #4007
[bug] [mssql] Fixed bug where SQL Server transaction isolation must be fetched from a different view when using Azure data warehouse, the query is now attempted against both views and then a NotImplemented is raised unconditionally if failure continues to provide the best resiliency against future arbitrary API changes in new SQL Server versions.
This change is also backported to: 1.1.11
References: #3994
[bug] [oracle] Support for two-phase transactions has been removed entirely for cx_Oracle when version 6.0b1 or later of the DBAPI is in use. The two- phase feature historically has never been usable under cx_Oracle 5.x in any case, and cx_Oracle 6.x has removed the connection-level "twophase" flag upon which this feature relied.
This change is also backported to: 1.1.11
References: #3997
[bug] [mssql] Added a placeholder type 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.
This change is also backported to: 1.1.11
References: #3973
[bug] [orm] Fixed bug where a cascade such as "delete-orphan" (but others as well) would fail to locate an object linked to a relationship that itself is local to a subclass in an inheritance relationship, thus causing the operation to not take place.
This change is also backported to: 1.1.10
References: #3986
[bug] [oracle] Fixed bug in cx_Oracle dialect where version string parsing would fail for cx_Oracle version 6.0b1 due to the "b" character. Version string parsing is now via a regexp rather than a simple split.
This change is also backported to: 1.1.10
References: #3975
[bug] [schema] An ArgumentError is now raised if a
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.
This change is also backported to: 1.1.10
References: #3949
[bug] [ext] Protected against testing "None" as a class in the case where declarative classes are being garbage collected and new automap prepare() operations are taking place concurrently, very infrequently hitting a weakref that has not been fully acted upon after gc.
This change is also backported to: 1.1.10
References: #3980
[bug] [postgresql] Added "autocommit" support for GRANT, REVOKE keywords. Pull request courtesy Jacob Hayes.
This change is also backported to: 1.1.10
[bug] [mysql] Removed an ancient and unnecessary intercept of the UTC_TIMESTAMP MySQL function, which was getting in the way of using it with a parameter.
This change is also backported to: 1.1.10
References: #3966
[bug] [mysql] Fixed bug in MySQL dialect regarding rendering of table options in conjunction with PARTITION options when rendering CREATE TABLE. The PARTITION related options need to follow the table options, whereas previously this ordering was not enforced.
This change is also backported to: 1.1.10
References: #3961
[bug] [sql] Fixed regression released in 1.1.5 due to #3859 where
adjustments to the "right-hand-side" evaluation of an expression
based on Variant to honor the underlying type's
"right-hand-side" rules caused the Variant type
to be inappropriately lost, in those cases when we do want the
left-hand side type to be transferred directly to the right hand side
so that bind-level rules can be applied to the expression's argument.
This change is also backported to: 1.1.9
References: #3952
[bug] [postgresql] [sql] Changed the mechanics of ResultProxy to unconditionally
delay the "autoclose" step until the Connection is done
with the object; in the case where PostgreSQL ON CONFLICT with
RETURNING returns no rows, autoclose was occurring in this previously
non-existent use case, causing the usual autocommit behavior that
occurs unconditionally upon INSERT/UPDATE/DELETE to fail.
This change is also backported to: 1.1.9
References: #3955
[bug] [ext] Fixed bug in sqlalchemy.ext.mutable where the
Mutable.as_mutable() method would not track a type that had
been copied using TypeEngine.copy(). This became more of
a regression in 1.1 compared to 1.0 because the TypeDecorator
class is now a subclass of SchemaEventTarget, which among
other things indicates to the parent Column that the type
should be copied when the Column is. These copies are
common when using declarative with mixins or abstract classes.
This change is also backported to: 1.1.8
References: #3950
[bug] [ext] Added support for bound parameters, e.g. those normally set up
via Query.params(), to the baked.Result.count()
method. Previously, support for parameters were omitted. Pull request
courtesy Pat Deegan.
This change is also backported to: 1.1.8
[bug] [postgresql] Added support for parsing the PostgreSQL version string for a development version like "PostgreSQL 10devel". Pull request courtesy Sean McCully.
This change is also backported to: 1.1.8
[feature] [orm] An aliased() construct can now be passed to the
Query.select_entity_from() method. Entities will be pulled
from the selectable represented by the aliased() construct.
This allows special options for aliased() such as
aliased.adapt_on_names to be used in conjunction with
Query.select_entity_from().
This change is also backported to: 1.1.7
References: #3933
[bug] [engine] Added an exception handler that will warn for the "cause" exception on
Py2K when the "autorollback" feature of Connection itself
raises an exception. In Py3K, the two exceptions are naturally reported
by the interpreter as one occurring during the handling of the other.
This is continuing with the series of changes for rollback failure
handling that were last visited as part of #2696 in 1.0.12.
This change is also backported to: 1.1.7
References: #3946
[bug] [orm] Fixed a race condition which could occur under threaded environments
as a result of the caching added via #3915. An internal
collection of Column objects could be regenerated on an alias
object inappropriately, confusing a joined eager loader when it
attempts to render SQL and collect results and resulting in an
attribute error. The collection is now generated up front before
the alias object is cached and shared among threads.
This change is also backported to: 1.1.7
References: #3947
[feature] [orm] Added .autocommit attribute to scoped_session, proxying
the .autocommit attribute of the underling Session
currently assigned to the thread. Pull request courtesy
Ben Fagin.
[feature] [mysql] Added support for MySQL's ON DUPLICATE KEY UPDATE
MySQL-specific mysql.dml.Insert object.
Pull request courtesy Michael Doronin.
References: #4009
[bug] [sql] The rules for type coercion between Numeric, 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 Numeric or Float and
Integer will preserve the "asdecimal" flag as well as
if the type should be the Float subclass.
References: #4018
[bug] [mysql] [sql] The result processor for the 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.
References: #4020
[bug] [sql] Added some extra strictness to the handling of Python "float" values
passed to SQL statements. A "float" value will be associated with the
Float datatype and not the Decimal-coercing Numeric
datatype as was the case before, eliminating a confusing warning
emitted on SQLite as well as unnecessary coercion to Decimal.
References: #4017
[feature] [orm] Added a new feature 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.
References: #3058
[bug] [orm] An UPDATE emitted as a result of the
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.
References: #3496
[bug] [ext] The AssociationProxy.any(), AssociationProxy.has()
and AssociationProxy.contains() comparison methods now support
linkage to an attribute that is itself also an
AssociationProxy, recursively.
References: #3769
[bug] [ext] Implemented in-place mutation operators __ior__, __iand__,
__ixor__ and __isub__ for mutable.MutableSet
and __iadd__ for mutable.MutableList so that change
events are fired off when these mutator methods are used to alter the
collection.
References: #3853
[bug] [declarative] A warning is emitted if the 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 declared_attr.cascading
modifier currently only applies to mixin/abstract classes.
References: #3847
[feature] [oracle] The Oracle dialect now inspects unique and check constraints when using
Inspector.get_unique_constraints(),
Inspector.get_check_constraints().
As Oracle does not have unique constraints that are separate from a unique
Index, a Table that's reflected will still continue
to not have UniqueConstraint objects associated with it.
Pull requests courtesy Eloy Felix.
References: #4003
[feature] [orm] 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.
References: #3948
[bug] [orm] Repaired several use cases involving the
relationship.post_update feature when used in conjunction
with a column that has an "onupdate" value. When the UPDATE emits,
the corresponding object attribute is now expired or refreshed so that
the newly generated "onupdate" value can populate on the object;
previously the stale value would remain. Additionally, if the target
attribute is set in Python for the INSERT of the object, the value is
now re-sent during the UPDATE so that the "onupdate" does not overwrite
it (note this works just as well for server-generated onupdates).
Finally, the SessionEvents.refresh_flush() event is now emitted
for these attributes when refreshed within the flush.
[bug] [orm] Fixed bug where programmatic version_id counter in conjunction with joined table inheritance would fail if the version_id counter were not actually incremented and no other values on the base table were modified, as the UPDATE would have an empty SET clause. Since programmatic version_id where version counter is not incremented is a documented use case, this specific condition is now detected and the UPDATE now sets the version_id value to itself, so that concurrency checks still take place.
References: #3996
[bug] [declarative] [orm] Fixed bug where using declared_attr on an
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 declared_attr is on a mapped class, and
does not occur on a mixin or abstract class. Since
AbstractConcreteBase is both "abstract" and actually
"mapped", a special exception case is made here so that the
"abstract" behavior takes precedence for declared_attr.
References: #3848
[bug] [orm] The versioning feature does not support NULL for the version counter. An exception is now raised if the version id is programmatic and was set to NULL for an UPDATE. Pull request courtesy Diana Clarke.
References: #3673
[bug] [sql] 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 precedence.
References: #3999
[bug] [orm] Removed a very old keyword argument from scoped_session
called scope. This keyword was never documented and was an
early attempt at allowing for variable scopes.
References: #3796
[bug] [mysql] Added support for views that are unreflectable due to stale
table definitions, when calling MetaData.reflect(); a warning
is emitted for the table that cannot respond to DESCRIBE,
but the operation succeeds.
References: #3871
[ext] [feature] Added new flag Session.enable_baked_queries to the
Session to allow baked queries to be disabled
session-wide, reducing memory use. Also added new Bakery
wrapper so that the bakery returned by BakedQuery.bakery
can be inspected.
[bug] [orm] Fixed bug where combining a "with_polymorphic" load in conjunction with subclass-linked relationships that specify joinedload with innerjoin=True, would fail to demote those "innerjoins" to "outerjoins" to suit the other polymorphic classes that don't support that relationship. This applies to both a single and a joined inheritance polymorphic load.
References: #3988
[bug] [orm] Added new argument with_for_update to the
Session.refresh() method. When the Query.with_lockmode()
method were deprecated in favor of Query.with_for_update(),
the Session.refresh() method was never updated to reflect
the new option.
References: #3991
[bug] [orm] Fixed bug where a column_property() that is also marked as
"deferred" would be marked as "expired" during a flush, causing it
to be loaded along with the unexpiry of regular attributes even
though this attribute was never accessed.
References: #3984
[bug] [sql] Repaired issue where the type of an expression that used
ColumnOperators.is_() or similar would not be a "boolean" type,
instead the type would be "nulltype", as well as when using custom
comparison operators against an untyped expression. This typing can
impact how the expression behaves in larger contexts as well as
in result-row-handling.
References: #3873
[bug] [ext] Improved the association proxy list collection so that premature
autoflush against a newly created association object can be prevented
in the case where list.append() is being used, and a lazy load
would be invoked when the association proxy accesses the endpoint
collection. The endpoint collection is now accessed first before
the creator is invoked to produce the association object.
References: #3941
[bug] [sql] Fixed the negation of a Label construct so that the
inner element is negated correctly, when the not_() modifier
is applied to the labeled expression.
References: #3969
[feature] [orm] Added a new kind of eager loading called "selectin" loading. This
style of loading is very similar to "subquery" eager loading,
except that it uses an IN expression given a list of primary key
values from the loaded parent objects, rather than re-stating the
original query. This produces a more efficient query that is
"baked" (e.g. the SQL string is cached) and also works in the
context of Query.yield_per().
References: #3944
[bug] [orm] Fixed bug in subquery eager loading where the "join_depth" parameter for self-referential relationships would not be correctly honored, loading all available levels deep rather than correctly counting the specified number of levels for eager loading.
References: #3967
[bug] [orm] Added warnings to the LRU "compiled cache" used by the Mapper
(and ultimately will be for other ORM-based LRU caches) such that
when the cache starts hitting its size limits, the application will
emit a warning that this is a performance-degrading situation that
may require attention. The LRU caches can reach their size limits
primarily if an application is making use of an unbounded number
of Engine objects, which is an antipattern. Otherwise,
this may suggest an issue that should be brought to the SQLAlchemy
developer's attention.
[bug] [postgresql] Fixed bug where the base sqltypes.ARRAY datatype would not
invoke the bind/result processors of postgresql.ARRAY.
References: #3964
[bug] [orm] Fixed bug to improve upon the specificity of loader options that take effect subsequent to the lazy load of a related entity, so that the loader options will match to an aliased or non-aliased entity more specifically if those options include entity information.
References: #3963
[feature] [orm] The lazy="select" loader strategy now makes used of the
BakedQuery query caching system in all cases. This
removes most overhead of generating a Query object and
running it into a select() and then string SQL statement from
the process of lazy-loading related collections and objects. The
"baked" lazy loader has also been improved such that it can now
cache in most cases where query load options are used.
References: #3954
[bug] [sql] The system by which percent signs in SQL statements are "doubled"
for escaping purposes has been refined. The "doubling" of percent
signs mostly associated with the literal_column construct
as well as operators like ColumnOperators.contains() now
occurs based on the stated paramstyle of the DBAPI in use; for
percent-sensitive paramstyles as are common with the PostgreSQL
and MySQL drivers the doubling will occur, for others like that
of SQLite it will not. This allows more database-agnostic use
of the literal_column construct to be possible.
References: #3740
[bug] [postgresql] Added support for all possible "fields" identifiers when reflecting the
PostgreSQL INTERVAL datatype, e.g. "YEAR", "MONTH", "DAY TO
MINUTE", etc.. In addition, the postgresql.INTERVAL
datatype itself now includes a new parameter
postgresql.INTERVAL.fields where these qualifiers can be
specified; the qualifier is also reflected back into the resulting
datatype upon reflection / inspection.
References: #3959
[bug] [sql] Fixed bug where a column-level CheckConstraint would fail
to compile the SQL expression using the underlying dialect compiler
as well as apply proper flags to generate literal values as
inline, in the case that the sqltext is a Core expression and
not just a plain string. This was long-ago fixed for table-level
check constraints in 0.9 as part of #2742, which more commonly
feature Core SQL expressions as opposed to plain string expressions.
References: #3957
[bug] [mssql] The SQL Server dialect now allows for a database and/or owner name
with a dot inside of it, using brackets explicitly in the string around
the owner and optionally the database name as well. In addition,
sending the quoted_name construct for the schema name will
not split on the dot and will deliver the full string as the "owner".
quoted_name is also now available from the sqlalchemy.sql
import space.
References: #2626
[feature] [sql] Added a new kind of bindparam() called "expanding". This is
for use in IN expressions where the list of elements is rendered
into individual bound parameters at statement execution time, rather
than at statement compilation time. This allows both a single bound
parameter name to be linked to an IN expression of multiple elements,
as well as allows query caching to be used with IN expressions. The
new feature allows the related features of "select in" loading and
"polymorphic in" loading to make use of the baked query extension
to reduce call overhead. This feature should be considered to be
experimental for 1.2.
References: #3953
[bug] [sql] Fixed bug where a SQL-oriented Python-side column default could fail to be executed properly upon INSERT in the "pre-execute" codepath, if the SQL itself were an untyped expression, such as plain text. The "pre- execute" codepath is fairly uncommon however can apply to non-integer primary key columns with SQL defaults when RETURNING is not used.
References: #3923
[bug] [sql] The expression used for COLLATE as rendered by the column-level
expression.collate() and ColumnOperators.collate() is now
quoted as an identifier when the name is case sensitive, e.g. has
uppercase characters. Note that this does not impact type-level
collation, which is already quoted.
References: #3785
[ext] [feature] [orm] The Query.update() method can now accommodate both
hybrid attributes as well as composite attributes as a source
of the key to be placed in the SET clause. For hybrids, an
additional decorator hybrid_property.update_expression()
is supplied for which the user supplies a tuple-returning function.
References: #3229
[bug] [orm] The attributes.flag_modified() function now raises
InvalidRequestError if the named attribute key is not
present within the object, as this is assumed to be present
in the flush process. To mark an object "dirty" for a flush
without referring to any specific attribute, the
attributes.flag_dirty() function may be used.
References: #3753
[bug] [ext] The sqlalchemy.ext.hybrid.hybrid_property class now supports
calling mutators like @setter, @expression etc. multiple times
across subclasses, and now provides a @getter mutator, so that
a particular hybrid can be repurposed across subclasses or other
classes. This now matches the behavior of @property in standard
Python.
[feature] [mysql] [oracle] [postgresql] [sql] Added support for SQL comments on Table and Column
objects, via the new Table.comment and
Column.comment arguments. The comments are included
as part of DDL on table creation, either inline or via an appropriate
ALTER statement, and are also reflected back within table reflection,
as well as via the Inspector. Supported backends currently
include MySQL, PostgreSQL, and Oracle. Many thanks to Frazer McLean
for a large amount of effort on this.
References: #1546
[engine] [feature] Added native "pessimistic disconnection" handling to the Pool
object. The new parameter Pool.pre_ping, available from
the engine as create_engine.pool_pre_ping, applies an
efficient form of the "pre-ping" recipe featured in the pooling
documentation, which upon each connection check out, emits a simple
statement, typically "SELECT 1", to test the connection for liveness.
If the existing connection is no longer able to respond to commands,
the connection is transparently recycled, and all other connections
made prior to the current timestamp are invalidated.
References: #3919
[bug] [sql] Fixed bug where the use of an Alias object in a column
context would raise an argument error when it tried to group itself
into a parenthesized expression. Using Alias in this way
is not yet a fully supported API, however it applies to some end-user
recipes and may have a more prominent role in support of some
future PostgreSQL features.
References: #3939
[bug] [orm] The "evaluate" strategy used by Query.update() and
Query.delete() can now accommodate a simple
object comparison from a many-to-one relationship to an instance,
when the attribute names of the primary key / foreign key columns
don't match the actual names of the columns. Previously this would
do a simple name-based match and fail with an AttributeError.
References: #3366
[feature] [orm] Added new attribute event AttributeEvents.bulk_replace().
This event is triggered when a collection is assigned to a
relationship, before the incoming collection is compared with the
existing one. This early event allows for conversion of incoming
non-ORM objects as well. The event is integrated with the
@validates decorator.
References: #3896
[bug] [orm] The @validates decorator now allows the decorated method to receive
objects from a "bulk collection set" operation that have not yet
been compared to the existing collection. This allows incoming values
to be converted to compatible ORM objects as is already allowed
from an "append" event. Note that this means that the
@validates method is called for all values during a collection
assignment, rather than just the ones that are new.
References: #3896
[bug] [engine] Fixed bug where in the unusual case of passing a
Compiled object directly to Connection.execute(),
the dialect with which the Compiled object were generated
was not consulted for the paramstyle of the string statement, instead
assuming it would match the dialect-level paramstyle, causing
mismatches to occur.
References: #3938
[feature] [orm] Added new event handler AttributeEvents.modified() which is
triggered when the func:.attributes.flag_modified function is
invoked, which is common when using the sqlalchemy.ext.mutable
extension module.
References: #3303
[bug] [ext] Fixed a bug in the sqlalchemy.ext.serializer extension whereby
an "annotated" SQL element (as produced by the ORM for many types
of SQL expressions) could not be reliably serialized. Also bumped
the default pickle level for the serializer to "HIGHEST_PROTOCOL".
References: #3918
[bug] [orm] Fixed bug in single-table inheritance where the select_from() argument would not be taken into account when limiting rows to a subclass. Previously, only expressions in the columns requested would be taken into account.
References: #3891
[bug] [orm] When assigning a collection to an attribute mapped by a relationship, the previous collection is no longer mutated. Previously, the old collection would be emptied out in conjunction with the "item remove" events that fire off; the events now fire off without affecting the old collection.
References: #3913
[bug] [oracle] The cx_Oracle dialect now supports "sane multi rowcount", that is,
when a series of parameter sets are executed via DBAPI
cursor.executemany(), we can make use of cursor.rowcount to
verify the number of rows matched. This has an impact within the
ORM when detecting concurrent modification scenarios, in that
some simple conditions can now be detected even when the ORM
is batching statements, as well as when the more strict versioning
feature is used, the ORM can still use statement batching. The
flag is enabled for cx_Oracle assuming at least version 5.0, which
is now commonplace.
References: #3932
[feature] [sql] The longstanding behavior of the ColumnOperators.in_() and
ColumnOperators.notin_() operators emitting a warning when
the right-hand condition is an empty sequence has been revised;
a simple "static" expression of "1 != 1" or "1 = 1" is now rendered
by default, rather than pulling in the original left-hand
expression. This causes the result for a NULL column comparison
against an empty set to change from NULL to true/false. The
behavior is configurable, and the old behavior can be enabled
using the create_engine.empty_in_strategy parameter
to create_engine().
References: #3907
[bug] [oracle] Oracle reflection now "normalizes" the name given to a foreign key constraint, that is, returns it as all lower case for a case insensitive name. This was already the behavior for indexes and primary key constraints as well as all table and column names. This will allow Alembic autogenerate scripts to compare and render foreign key constraint names correctly when initially specified as case insensitive.
References: #3276
[feature] [sql] Added a new option autoescape to the "startswith" and
"endswith" classes of comparators; this supplies an escape character
also applies it to all occurrences of the wildcard characters "%"
and "_" automatically. Pull request courtesy Diana Clarke.
This feature has been changed as of 1.2.0 from its initial implementation in 1.2.0b2 such that autoescape is now passed as a boolean value, rather than a specific character to use as the escape character.
References: #2694
[bug] [orm] The state of the Session is now present when the
SessionEvents.after_rollback() event is emitted, that is, the
attribute state of objects prior to their being expired. This is now
consistent with the behavior of the
SessionEvents.after_commit() event which also emits before the
attribute state of objects is expired.
References: #3934
[bug] [orm] Fixed bug where Query.with_parent() would not work if the
Query were against an aliased() construct rather than
a regular mapped class. Also adds a new parameter
util.with_parent.from_entity to the standalone
util.with_parent() function as well as
Query.with_parent().
References: #3607
[postgresql] [bug] [py3k] Fixed bug in PostgreSQL COLLATE / ARRAY adjustment first introduced in #4006 where new behaviors in Python 3.7 regular expre
Released: March 6, 2018
[postgresql] [bug] [py3k] Fixed bug in PostgreSQL COLLATE / ARRAY adjustment first introduced in #4006 where new behaviors in Python 3.7 regular expressions caused the fix to fail.
References: #4208
[mysql] [bug] MySQL dialects now query the server version using SELECT @@version
explicitly to the server to ensure we are getting the correct version
information back. Proxy servers like MaxScale interfere with the value
that is passed to the DBAPI's connection.server_version value so this
is no longer reliable.
References: #4205
[bug] [ext] Repaired regression caused in 1.2.3 and 1.1.16 regarding association proxy objects, revising the approach to #4185 when calculating the "o
Released: February 22, 2018
[bug] [ext] Repaired regression caused in 1.2.3 and 1.1.16 regarding association proxy objects, revising the approach to #4185 when calculating the "owning class" of an association proxy to default to choosing the current class if the proxy object is not directly associated with a mapped class, such as a mixin.
References: #4185
[orm] [bug] Fixed issue in post_update feature where an UPDATE is emitted when the parent object has been deleted but the dependent object is not. Thi
Released: February 16, 2018
[orm] [bug] Fixed issue in post_update feature where an UPDATE is emitted when the parent object has been deleted but the dependent object is not. This issue has existed for a long time however since 1.2 now asserts rows matched for post_update, this was raising an error.
References: #4187
[orm] [bug] Fixed regression caused by fix for issue #4116 affecting versions
1.2.2 as well as 1.1.15, which had the effect of mis-calculation of the
"owning class" of an AssociationProxy as the NoneType class
in some declarative mixin/inheritance situations as well as if the
association proxy were accessed off of an un-mapped class. The "figure out
the owner" logic has been replaced by an in-depth routine that searches
through the complete mapper hierarchy assigned to the class or subclass to
determine the correct (we hope) match; will not assign the owner if no
match is found. An exception is now raised if the proxy is used
against an un-mapped instance.
References: #4185
[orm] [bug] Fixed bug where an object that is expunged during a rollback of a nested or subtransaction which also had its primary key mutated would not be correctly removed from the session, causing subsequent issues in using the session.
References: #4151
[sql] [bug] Added nullsfirst() and nullslast() as top level imports
in the sqlalchemy. and sqlalchemy.sql. namespace. Pull request
courtesy Lele Gaifax.
[sql] [bug] Fixed bug in Insert.values() where using the "multi-values"
format in combination with Column objects as keys rather
than strings would fail. Pull request courtesy Aubrey Stark-Toller.
References: #4162
[postgresql] [bug] Added "SSL SYSCALL error: Operation timed out" to the list of messages that trigger a "disconnect" scenario for the psycopg2 driver. Pull request courtesy André Cruz.
[postgresql] [bug] Added "TRUNCATE" to the list of keywords accepted by the PostgreSQL dialect as an "autocommit"-triggering keyword. Pull request courtesy Jacob Hayes.
[mysql] [bug] Fixed bug where the MySQL "concat" and "match" operators failed to propagate kwargs to the left and right expressions, causing compiler options such as "literal_binds" to fail.
References: #4136
[bug] [pool] Fixed a fairly serious connection pool bug where a connection that is
acquired after being refreshed as a result of a user-defined
DisconnectionError or due to the 1.2-released "pre_ping" feature
would not be correctly reset if the connection were returned to the pool by
weakref cleanup (e.g. the front-facing object is garbage collected); the
weakref would still refer to the previously invalidated DBAPI connection
which would have the reset operation erroneously called upon it instead.
This would lead to stack traces in the logs and a connection being checked
into the pool without being reset, which can cause locking issues.
References: #4184
Released: November 3, 2017change: :tags: bug, sqlite :tickets: 4099 :versions: 1.2.0b3
Released: November 3, 2017change: :tags: bug, sqlite :tickets: 4099 :versions: 1.2.0b3
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.
[orm] [bug] [ext] Fixed bug where the association proxy would inadvertently link itself
to an AliasedClass object if it were called first with
the AliasedClass as a parent, causing errors upon subsequent
usage.
References: #4116
[orm] [bug] 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.
References: #4078
[orm] [bug] 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.
References: #4103
[bug] [declarative] [orm] Fixed bug where a descriptor that is elsewhere a mapped column
or relationship within a hierarchy based on AbstractConcreteBase
would be referred towards during a refresh operation, causing an error
as the attribute is not mapped as a mapper property.
A similar issue can arise for other attributes like the "type" column
added by AbstractConcreteBase if the class fails to include
"concrete=True" in its mapper, however the check here should also
prevent that scenario from causing a problem.
References: #4124
[sql] [bug] Fixed bug where __repr__ of ColumnDefault would fail
if the argument were a tuple. Pull request courtesy Nicolas Caniart.
References: #4126
[sql] [bug] Fixed bug where the recently added ColumnOperators.any_()
and ColumnOperators.all_() methods didn't work when called
as methods, as opposed to using the standalone functions
~.expression.any_() and ~.expression.all_(). Also
added documentation examples for these relatively unintuitive
SQL operators.
References: #4093
[postgresql] [bug] Made further fixes to the ARRAY class in conjunction with
COLLATE, as the fix made in #4006 failed to accommodate
for a multidimensional array.
References: #4006
[postgresql] [bug] Fixed bug in array_agg function where passing an argument
that is already of type ARRAY, such as a PostgreSQL
postgresql.array construct, would produce a ValueError, due
to the function attempting to nest the arrays.
References: #4107
[postgresql] [bug] Fixed bug in PostgreSQL postgresql.dml.Insert.on_conflict_do_update()
which would prevent the insert statement from being used as a CTE,
e.g. via Insert.cte(), within another statement.
References: #4074
[mysql] [bug] Warning emitted when MariaDB 10.2.8 or earlier in the 10.2 series is detected as there are major issues with CHECK constraints within these versions that were resolved as of 10.2.9.
Note that this changelog message was NOT released with SQLAlchemy 1.2.0b3 and was added retroactively.
References: #4097
[mysql] [bug] 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.
References: #4120
[mssql] [bug] Added a full range of "connection closed" exception codes to the PyODBC dialect for SQL Server, including '08S01', '01002', '08003', '08007', '08S02', '08001', 'HYT00', 'HY010'. Previously, only '08S01' was covered.
References: #4095
[orm] [bug] Fixed bug in Session.merge() following along similar lines as that of #4030, where an internal check for a target object in the identity m
Released: September 5, 2017
[orm] [bug] Fixed bug in Session.merge() following along similar lines as that
of #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.
References: #4069
[orm] [bug] Fixed bug where an undefer_group() option would not be recognized
if it extended from a relationship that was loading using joined eager
loading. Additionally, as the bug led to excess work being performed,
Python function call counts are also improved by 20% within the initial
calculation of result set columns, complementing the joined eager load
improvements of #3915.
References: #4048
[orm] [bug] 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.
References: #4068
[orm] [bug] Fixed bug in 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.
References: #4056
[orm] [bug] An InvalidRequestError is raised when a synonym()
is used against an attribute that is not against a MapperProperty,
such as an association proxy. Previously, a recursion overflow would
occur trying to locate non-existent attributes.
References: #4067
[sql] [bug] 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".
References: #4053
[oracle] [bug] [performance] [py2k] Fixed performance regression caused by the fix for #3937 where cx_Oracle as of version 5.3 dropped the .UNICODE sy
Released: August 3, 2017
[oracle] [bug] [performance] [py2k] Fixed performance regression caused by the fix for #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 #3937 is also restored.
This change is also backported to: 1.0.19
References: #4035
[orm] [bug] Fixed regression from 1.1.11 where adding additional non-entity columns to a query that includes an entity with subqueryload relationships
Released: July 24, 2017
[orm] [bug] Fixed regression from 1.1.11 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 #4011.
References: #4033
[orm] [bug] Fixed bug involving JSON NULL evaluation logic added in 1.1 as part
of #3514 where the logic would not accommodate ORM
mapped attributes named differently from the Column
that was mapped.
References: #4031
[orm] [bug] Added KeyError checks to all methods within
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.
References: #4030
Sequence.cache and
Sequence.order to 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.[bug] [py3k] [tests] Fixed issue in testing fixtures which was incompatible with a change made as of Python 3.6.2 involving context managers.
This change is also backported to: 1.0.18
References: #4034
Released: Monday, June 19, 2017
Released: Monday, June 19, 2017
[orm] [bug] Fixed issue with subquery eagerloading which continues on from the series of issues fixed in #2699, #3106, #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.
References: #4011
[sql] [bug] Fixed AttributeError which would occur in WithinGroup
construct during an iteration of the structure.
References: #4012
[postgresql] [bug] 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.
References: #4005
[postgresql] [bug] Fixed bug where using ARRAY with a string type that
features a collation would fail to produce the correct syntax
within CREATE TABLE.
References: #4006
[mysql] [bug] 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.
References: #4007
[mssql] [bug] Fixed bug where SQL Server transaction isolation must be fetched from a different view when using Azure data warehouse, the query is now attempted against both views and then a NotImplemented is raised unconditionally if failure continues to provide the best resiliency against future arbitrary API changes in new SQL Server versions.
References: #3994
[mssql] [bug] Added a placeholder type 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.
References: #3973
[oracle] [bug] Support for two-phase transactions has been removed entirely for cx_Oracle when version 6.0b1 or later of the DBAPI is in use. The two- phase feature historically has never been usable under cx_Oracle 5.x in any case, and cx_Oracle 6.x has removed the connection-level "twophase" flag upon which this feature relied.
References: #3997
[orm] [bug] Fixed bug where a cascade such as "delete-orphan" (but others as well) would fail to locate an object linked to a relationship that itself
Released: Friday, May 19, 2017
[orm] [bug] Fixed bug where a cascade such as "delete-orphan" (but others as well) would fail to locate an object linked to a relationship that itself is local to a subclass in an inheritance relationship, thus causing the operation to not take place.
References: #3986
[schema] [bug] An ArgumentError is now raised if a
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.
References: #3949
[mysql] [bug] Removed an ancient and unnecessary intercept of the UTC_TIMESTAMP MySQL function, which was getting in the way of using it with a parameter.
References: #3966
[mysql] [bug] Fixed bug in MySQL dialect regarding rendering of table options in conjunction with PARTITION options when rendering CREATE TABLE. The PARTITION related options need to follow the table options, whereas previously this ordering was not enforced.
References: #3961
[oracle] [bug] Fixed bug in cx_Oracle dialect where version string parsing would fail for cx_Oracle version 6.0b1 due to the "b" character. Version string parsing is now via a regexp rather than a simple split.
References: #3975
[bug] [ext] Protected against testing "None" as a class in the case where declarative classes are being garbage collected and new automap prepare() operations are taking place concurrently, very infrequently hitting a weakref that has not been fully acted upon after gc.
References: #3980
[sql] [bug] Fixed regression released in 1.1.5 due to #3859 where adjustments to the "right-hand-side" evaluation of an expression based on Variant to
Released: April 4, 2017
[sql] [bug] Fixed regression released in 1.1.5 due to #3859 where
adjustments to the "right-hand-side" evaluation of an expression
based on Variant to honor the underlying type's
"right-hand-side" rules caused the Variant type
to be inappropriately lost, in those cases when we do want the
left-hand side type to be transferred directly to the right hand side
so that bind-level rules can be applied to the expression's argument.
References: #3952
[sql] [bug] [postgresql] Changed the mechanics of ResultProxy to unconditionally
delay the "autoclose" step until the Connection is done
with the object; in the case where PostgreSQL ON CONFLICT with
RETURNING returns no rows, autoclose was occurring in this previously
non-existent use case, causing the usual autocommit behavior that
occurs unconditionally upon INSERT/UPDATE/DELETE to fail.
References: #3955
[postgresql] [bug] Added support for parsing the PostgreSQL version string for a development version like "PostgreSQL 10devel". Pull request courtesy
Released: March 31, 2017
[bug] [ext] Fixed bug in sqlalchemy.ext.mutable where the
Mutable.as_mutable() method would not track a type that had
been copied using TypeEngine.copy(). This became more of
a regression in 1.1 compared to 1.0 because the TypeDecorator
class is now a subclass of SchemaEventTarget, which among
other things indicates to the parent Column that the type
should be copied when the Column is. These copies are
common when using declarative with mixins or abstract classes.
References: #3950
[bug] [ext] Added support for bound parameters, e.g. those normally set up
via Query.params(), to the baked.Result.count()
method. Previously, support for parameters were omitted. Pull request
courtesy Pat Deegan.
[orm] [feature] An aliased() construct can now be passed to the Query.select_entity_from() method. Entities will be pulled from the selectable represe
Released: March 27, 2017
[orm] [feature] An aliased() construct can now be passed to the
Query.select_entity_from() method. Entities will be pulled
from the selectable represented by the aliased() construct.
This allows special options for aliased() such as
aliased.adapt_on_names to be used in conjunction with
Query.select_entity_from().
References: #3933
[orm] [bug] Fixed a race condition which could occur under threaded environments
as a result of the caching added via #3915. An internal
collection of Column objects could be regenerated on an alias
object inappropriately, confusing a joined eager loader when it
attempts to render SQL and collect results and resulting in an
attribute error. The collection is now generated up front before
the alias object is cached and shared among threads.
References: #3947
[engine] [bug] Added an exception handler that will warn for the "cause" exception on
Py2K when the "autorollback" feature of Connection itself
raises an exception. In Py3K, the two exceptions are naturally reported
by the interpreter as one occurring during the handling of the other.
This is continuing with the series of changes for rollback failure
handling that were last visited as part of #2696 in 1.0.12.
References: #3946
[sql] [bug] [postgresql] Added support for the Variant and the SchemaType
objects to be compatible with each other. That is, a variant
can be created against a type like Enum, and the instructions
to create constraints and/or database-specific type objects will
propagate correctly as per the variant's dialect mapping.
References: #2892
[sql] [bug] Fixed bug in compiler where the string identifier of a savepoint would
be cached in the identifier quoting dictionary; as these identifiers
are arbitrary, a small memory leak could occur if a single
Connection had an unbounded number of savepoints used,
as well as if the savepoint clause constructs were used directly
with an unbounded umber of savepoint names. The memory leak does
not impact the vast majority of cases as normally the
Connection, which renders savepoint names with a simple
counter starting at "1", is used on a per-transaction or
per-fixed-number-of-transactions basis before being discarded.
References: #3931
[sql] [bug] Fixed bug in new "schema translate" feature where the translated schema
name would be invoked in terms of an alias name when rendered along
with a column expression; occurred only when the source translate
name was "None". The "schema translate" feature now only takes
effect for SchemaItem and SchemaType subclasses,
that is, objects that correspond to a DDL-creatable structure in
a database.
References: #3924
[oracle] [bug] A fix to cx_Oracle's WITH_UNICODE mode which was uncovered by the fact that cx_Oracle 5.3 now seems to hardcode this flag on in the build; an internal method that uses this mode wasn't using the correct signature.
This change is also backported to: 1.0.18
References: #3937
[orm] [bug] Addressed some long unattended performance concerns within the joined eager loader query construction system that have accumulated since e
Released: February 28, 2017
[orm] [bug] Addressed some long unattended performance concerns within the joined
eager loader query construction system that have accumulated since
earlier versions as a result of increased abstraction. The use of ad-
hoc AliasedClass objects per query, which produces lots of
column lookup overhead each time, has been replaced with a cached
approach that makes use of a small pool of AliasedClass
objects that are reused between invocations of joined eager loading.
Some mechanics involving eager join path construction have also been
optimized. Callcounts for an end-to-end query construction + single
row fetch test with a worst-case joined loader scenario have been
reduced by about 60% vs. 1.1.5 and 42% vs. that of 0.8.6.
References: #3915
[orm] [bug] Fixed a major inefficiency in the "eager_defaults" feature whereby an unnecessary SELECT would be emitted for column values where the ORM had explicitly inserted NULL, corresponding to attributes that were unset on the object but did not have any server default specified, as well as expired attributes on update that nevertheless had no server onupdate set up. As these columns are not part of the RETURNING that eager_defaults tries to use, they should not be post-SELECTed either.
References: #3909
[orm] [bug] Fixed two closely related bugs involving the mapper eager_defaults flag in conjunction with single-table inheritance; one where the eager defaults logic would inadvertently try to access a column that's part of the mapper's "exclude_properties" list (used by Declarative with single table inheritance) during the eager defaults fetch, and the other where the full load of the row in order to fetch the defaults would fail to use the correct inheriting mapper.
References: #3908
[orm] [bug] Fixed bug first introduced in 0.9.7 as a result of #3106 which would cause an incorrect query in some forms of multi-level subqueryload against aliased entities, with an unnecessary extra FROM entity in the innermost subquery.
References: #3893
[bug] [declarative] [orm] Fixed bug where the "automatic exclude" feature of declarative that ensures a column local to a single table inheritance subclass does not appear as an attribute on other derivations of the base would not take effect for multiple levels of subclassing from the base.
References: #3895
[sql] [bug] Fixed bug whereby the DDLEvents.column_reflect() event would not
allow a non-textual expression to be passed as the value of the
"default" for the new column, such as a FetchedValue
object to indicate a generic triggered default or a
sql.expression.text() construct. Clarified the documentation
in this regard as well.
References: #3905
[postgresql] [bug] Added regular expressions for the "IMPORT FOREIGN SCHEMA", "REFRESH MATERIALIZED VIEW" PostgreSQL statements so that they autocommit when invoked via a connection or engine without an explicit transaction. Pull requests courtesy Frazer McLean and Paweł Stiasny.
References: #3804
[postgresql] [bug] Fixed bug in PostgreSQL ExcludeConstraint where the
"whereclause" and "using" parameters would not be copied during an
operation like Table.tometadata().
References: #3900
[mssql] [bug] Added a version check to the "get_isolation_level" feature, which is invoked upon first connect, so that it skips for SQL Server version 2000, as the necessary system view is not available prior to SQL Server 2005.
References: #3898
[bug] [py3k] Fixed Python 3.6 DeprecationWarnings related to escaped strings without the 'r' modifier, and added test coverage for Python 3.6.
Released: January 17, 2017
[orm] [bug] Fixed bug involving joined eager loading against multiple entities when polymorphic inheritance is also in use which would throw "'NoneType' object has no attribute 'isa'". The issue was introduced by the fix for #3611.
This change is also backported to: 1.0.17
References: #3884
[orm] [bug] Fixed bug in subquery loading where an object encountered as an "existing" row, e.g. already loaded from a different path in the same query, would not invoke subquery loaders for unloaded attributes that specified this loading. This issue is in the same area as that of #3431, #3811 which involved similar issues with joined loading.
References: #3854
[orm] [bug] The Session.no_autoflush context manager now ensures that
the autoflush flag is reset within a "finally" block, so that if
an exception is raised within the block, the state still resets
appropriately. Pull request courtesy Emin Arakelian.
[orm] [bug] Fixed bug where the single-table inheritance query criteria would not
be inserted into the query in the case that the Bundle
construct were used as the selection criteria.
References: #3874
[orm] [bug] Fixed bug related to #3177, where a UNION or other set operation
emitted by a Query would apply "single-inheritance" criteria
to the outside of the union (also referencing the wrong selectable),
even though this criteria is now expected to
be already present on the inside subqueries. The single-inheritance
criteria is now omitted once union() or another set operation is
called against Query in the same way as Query.from_self().
References: #3856
[engine] [bug] The "extend_existing" option of Table reflection would
cause indexes and constraints to be doubled up in the case that the parameter
were used with MetaData.reflect() (as the automap extension does)
due to tables being reflected both within the foreign key path as well
as directly. A new de-duplicating set is passed through within the
MetaData.reflect() sequence to prevent double reflection in this
way.
References: #3861
[sql] [bug] Fixed bug originally introduced in 0.9 via #1068 where order_by(<some Label()>) would order by the label name based on name alone, that is, even if the labeled expression were not at all the same expression otherwise present, implicitly or explicitly, in the selectable. The logic that orders by label now ensures that the labeled expression is related to the one that resolves to that name before ordering by the label name; additionally, the name has to resolve to an actual label explicit in the expression elsewhere, not just a column name. This logic is carefully kept separate from the order by(textual name) feature that has a slightly different purpose.
[sql] [bug] Fixed 1.1 regression where "import *" would not work for
sqlalchemy.sql.expression, due to mis-spelled any_ and all_
functions.
References: #3878
[sql] [bg] Fixed bug where literal_binds compiler flag was not honored by the
Insert construct for the "multiple values" feature; the
subsequent values are now rendered as literals.
References: #3880
[sql] [bug] The engine URL embedded in the exception for "could not reflect"
in MetaData.reflect() now conceals the password; also
the __repr__ for TLEngine now acts like that of
Engine, concealing the URL password. Pull request courtesy
Valery Yundin.
[sql] [bug] Fixed issue in Variant where the "right hand coercion" logic,
inherited from TypeDecorator, would
coerce the right-hand side into the Variant itself, rather than
what the default type for the Variant would do. In the
case of Variant, we want the type to act mostly like the base
type so the default logic of TypeDecorator is now overridden
to fall back to the underlying wrapped type's logic. Is mostly relevant
for JSON at the moment.
References: #3859
[postgresql] [bug] Fixed bug in new "ON CONFLICT DO UPDATE" feature where the "set"
values for the UPDATE clause would not be subject to type-level
processing, as normally takes effect to handle both user-defined
type level conversions as well as dialect-required conversions, such
as those required for JSON datatypes. Additionally, clarified that
the keys in the set_ dictionary should match the "key" of the
column, if distinct from the column name. A warning is emitted
for remaining column names that don't match column keys; for
compatibility reasons, these are emitted as they were previously.
References: #3888
[postgresql] [bug] The postgresql.TIME and postgresql.TIMESTAMP
datatypes now support a setting of zero for "precision"; previously
a zero would be ignored. Pull request courtesy Ionuț Ciocîrlan.
[mysql] [feature] Added a new parameter mysql_prefix supported by the Index
construct, allows specification of MySQL-specific prefixes such as
"FULLTEXT". Pull request courtesy Joseph Schorr.
[mysql] [bug] The MySQL dialect now will not warn when a reflected column has a "COMMENT" keyword on it, but note however the comment is not yet reflected; this is on the roadmap for a future release. Pull request courtesy Lele Long.
References: #3867
[mssql] [bug] Fixed bug where SQL Server dialects would attempt to select the last row identity for an INSERT from SELECT, failing in the case when the SELECT has no rows. For such a statement, the inline flag is set to True indicating no last primary key should be fetched.
References: #3876
[oracle] [bug] [postgresql] Fixed bug where an INSERT from SELECT where the source table contains an autoincrementing Sequence would fail to compile correctly.
References: #3877
[oracle] [bug] Fixed bug where the "COMPRESSION" keyword was used in the ALL_TABLES query on Oracle 9.2; even though Oracle docs state table compression was introduced in 9i, the actual column is not present until 10.1.
References: #3875
[firebird] [bug] Ported the fix for Oracle quoted-lowercase names to Firebird, so that a table name that is quoted as lower case can be reflected properly including when the table name comes from the get_table_names() inspection function.
References: #3548
[bug] [py3k] Fixed Python 3.6 DeprecationWarnings related to escaped strings without the 'r' modifier, and added test coverage for Python 3.6.
This change is also backported to: 1.0.17
References: #3886
[bug] [examples] Fixed two issues with the versioned_history example, one is that the history table now gets autoincrement=False to avoid 1.1's new errors regarding composite primary keys with autoincrement; the other is that the sqlite_autoincrement flag is now used to ensure on SQLite, unique identifiers are used for the lifespan of a table even if some rows are deleted. Pull request courtesy Carlos García Montoro.
References: #3872
[orm] [bug] Fixed bug in Session.bulk_update_mappings() where an alternate-named primary key attribute would not track properly into the UPDATE statem
Released: November 15, 2016
[orm] [bug] Fixed bug in Session.bulk_update_mappings() where an alternate-named
primary key attribute would not track properly into the UPDATE statement.
This change is also backported to: 1.0.16
References: #3849
[orm] [bug] Fixed bug in Session.bulk_save() where an UPDATE would
not function correctly in conjunction with a mapping that
implements a version id counter.
This change is also backported to: 1.0.16
References: #3781
[orm] [bug] Fixed bug where the Mapper.attrs,
Mapper.all_orm_descriptors and other derived attributes would
fail to refresh when mapper properties or other ORM constructs were
added to the mapper/class after these accessors were first called.
This change is also backported to: 1.0.16
References: #3778
[orm] [bug] Fixed regression in collections due to #3457 whereby deserialize during pickle or deepcopy would fail to establish all attributes of an ORM collection, causing further mutation operations to fail.
References: #3852
[orm] [bug] Fixed long-standing bug where the "noload" relationship loading strategy would cause backrefs and/or back_populates options to be ignored.
References: #3845
Connection. This method was left over from a very old
version and was non-working (e.g. would raise). Pull request
courtesy Benjamin Dopplinger.[sql] [bug] Fixed bug where newly added warning for primary key on insert w/o
autoincrement setting (see change_3216) would fail to emit
correctly when invoked upon a lower-case table() construct.
References: #3842
[postgresql] [bug] Fixed regression caused by the fix in #3807 (version 1.1.0) where we ensured that the tablename was qualified in the WHERE clause of the DO UPDATE portion of PostgreSQL's ON CONFLICT, however you cannot put the table name in the WHERE clause in the actual ON CONFLICT itself. This was an incorrect assumption, so that portion of the change in #3807 is rolled back.
[mysql] [feature] Added support for server side cursors to the mysqlclient and
pymysql dialects. This feature is available via the
Connection.execution_options.stream_results flag as well
as the server_side_cursors=True dialect argument in the
same way that it has been for psycopg2 on PostgreSQL. Pull request
courtesy Roman Podoliaka.
[mysql] [bug] MySQL's native ENUM type supports any non-valid value being sent, and in response will return a blank string. A hardcoded rule to check for "is returning the blank string" has been added to the MySQL implementation for ENUM so that this blank string is returned to the application rather than being rejected as a non-valid value. Note that if your MySQL enum is linking values to objects, you still get the blank string back.
References: #3841
[sqlite] [bug] Added quotes to the PRAGMA directives in the pysqlcipher dialect to support additional cipher arguments appropriately. Pull request courtesy Kevin Jurczyk.
[sqlite] [bug] [py3k] Added an optional import for the pysqlcipher3 DBAPI when using the pysqlcipher dialect. This package will attempt to be imported if the Python-2 only pysqlcipher DBAPI is non-present. Pull request courtesy Kevin Jurczyk.
[mssql] [bug] Fixed bug in pyodbc dialect (as well as in the mostly non-working adodbapi dialect) whereby a semicolon present in the password or username fields could be interpreted as a separator for another token; the values are now quoted when semicolons are present.
This change is also backported to: 1.0.16
References: #3762
[orm] [bug] Fixed regression caused by #2677 whereby calling Session.delete() on an object that was already flushed as deleted in that session would f
Released: October 27, 2016
[orm] [bug] Fixed regression caused by #2677 whereby calling
Session.delete() on an object that was already flushed as
deleted in that session would fail to set up the object in the
identity map (or reject the object), causing flush errors as the
object were in a state not accommodated by the unit of work.
The pre-1.1 behavior in this case has been restored, which is that
the object is put back into the identity map so that the DELETE
statement will be attempted again, which emits a warning that the number
of expected rows was not matched (unless the row were restored outside
of the session).
References: #3839
[orm] [bug] Fixed regression where some Query methods like
Query.update() and others would fail if the Query
were against a series of mapped columns, rather than the mapped
entity as a whole.
References: #3836
[sql] [bug] Fixed bug involving new value translation and validation feature
in Enum whereby using the enum object in a string
concatenation would maintain the Enum type as the type
of the expression overall, producing missing lookups. A string
concatenation against an Enum-typed column now uses
String as the datatype of the expression itself.
References: #3833
[sql] [bug] Fixed regression which occurred as a side effect of #2919,
which in the less typical case of a user-defined
TypeDecorator that was also itself an instance of
SchemaType (rather than the implementation being such)
would cause the column attachment events to be skipped for the
type itself.
References: #3832
[postgresql] [bug] PostgreSQL table reflection will ensure that the
Column.autoincrement flag is set to False when reflecting
a primary key column that is not of an Integer datatype,
even if the default is related to an integer-generating sequence.
This can happen if a column is created as SERIAL and the datatype
is changed. The autoincrement flag can only be True if the datatype
is of integer affinity in the 1.1 series.
References: #3835
[orm] [bug] Fixed bug involving the rule to disable a joined collection eager loader on the other side of a many-to-one lazy loader, first added in #1
Released: October 17, 2016
[orm] [bug] Fixed bug involving the rule to disable a joined collection eager loader on the other side of a many-to-one lazy loader, first added in #1495, where the rule would fail if the parent object had some other lazyloader-bound query options associated with it.
References: #3824
[orm] [bug] Fixed self-referential entity, deferred column loading issue in a similar style as that of #3431, #3811 where an entity is present in multiple positions within the row due to self-referential eager loading; when the deferred loader only applies to one of the paths, the "present" column loader will now override the deferred non- load for that entity regardless of row ordering.
References: #3822
[sql] [bug] Fixed a regression caused by a newly added function that performs the
"wrap callable" function of sql DefaultGenerator objects,
an attribute error raised for __module__ when the default callable
was a functools.partial or other object that doesn't have a
__module__ attribute.
References: #3823
[sql] [bug] [postgresql] Fixed regression in Enum type where event handlers were not
transferred in the case of the type object being copied, due to a
conflicting copy() method added as part of #3250. This copy
occurs normally in situations when the column is copied, such as
in tometadata() or when using declarative mixins with columns. The
event handler not being present would impact the constraint being
created for a non-native enumerated type, but more critically the
ENUM object on the PostgreSQL backend.
References: #3827
[postgresql] [bug] [sql] Changed the naming convention used when generating bound parameters for a multi-VALUES insert statement, so that the numbered parameter names don't conflict with the anonymized parameters of a WHERE clause, as is now common in a PostgreSQL ON CONFLICT construct.
References: #3828
[mssql] [bug] The "SELECT SERVERPROPERTY" query added in #3810 and #3814 is failing on unknown combinations of Pyodbc and SQL Server. While failure of
Released: October 7, 2016
[mssql] [bug] The "SELECT SERVERPROPERTY" query added in #3810 and #3814 is failing on unknown combinations of Pyodbc and SQL Server. While failure of this function was anticipated, the exception catch was not broad enough so it now catches all forms of pyodbc.Error.
References: #3820
[bug] [core] Changed the CompileError raised when various primary key missing situations are detected to a warning. The statement is again passed to the database where it will fail and the DBAPI error (usually IntegrityError) raises as usual.
References: #3216
[orm] [change] Passing False to Query.order_by() in order to cancel all order by's is deprecated; there is no longer any difference between calling th…
Released: October 5, 2016
[orm] [bug] Fixed bug where joined eager loading would fail for a polymorphically- loaded mapper, where the polymorphic_on was set to an un-mapped expression such as a CASE expression.
This change is also backported to: 1.0.16
References: #3800
[orm] [bug] Fixed bug where the ArgumentError raised for an invalid bind
sent to a Session via Session.bind_mapper(),
Session.bind_table(),
or the constructor would fail to be correctly raised.
This change is also backported to: 1.0.16
References: #3798
[orm] [bug] Fixed bug in subquery eager loading where a subqueryload of an "of_type()" object linked to a second subqueryload of a plain mapped class, or a longer chain of several "of_type()" attributes, would fail to link the joins correctly.
This change is also backported to: 1.0.15
[orm] [bug] ORM attributes can now be assigned any object that is has a
__clause_element__() attribute, which will result in inline
SQL the way any ClauseElement class does. This covers other
mapped attributes not otherwise transformed by further expression
constructs.
References: #3802
[orm] [feature] Enhanced the new "raise" lazy loader strategy to also include a
"raise_on_sql" variant, available both via orm.relationship.lazy
as well as 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.
References: #3812
[orm] [bug] 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.
References: #3811
[orm] [bug] Fixed bug in new SessionEvents.persistent_to_deleted() event
where the target object could be garbage collected before the event
is fired off.
References: #3808
[orm] [bug] The primaryjoin of a relationship() construct can now include
a 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.
References: #3767
[orm] [bug] 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.
References: #3801
[orm] [bug] 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.
References: #3788
[orm] [bug] 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.
References: #3776
[orm] [bug] Mapper errors raised during 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.
[orm] [change] Passing False to 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.
[orm] [feature] The Query.group_by() method now resets the group by collection
if an argument of None is passed, in the same way that
Query.order_by() has worked for a long time. Pull request
courtesy Iuri Diniz.
~.ext.declarative.as_declarative() acts more like a normal class
decorator.[sql] [bug] Fixed bug in Table where the internal method
_reset_exported() would corrupt the state of the object. This
method is intended for selectable objects and is called by the ORM
in some cases; an erroneous mapper configuration would could lead the
ORM to call this on a Table object.
This change is also backported to: 1.0.15
References: #3755
[sql] [bug] 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.
References: #3805
[sql] [bug] A string sent as a column default via the
Column.server_default parameter is now escaped for quotes.
References: #3809
[sql] [bug] [postgresql] 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.
References: #3806
[sql] [bug] [mysql] The BaseException exception class is now intercepted by the
exception-handling routines of Connection, and includes
handling by the ~.ConnectionEvents.handle_error()
event. The 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.
References: #3803
[sql] [bug] 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.
References: #3799
[sql] [bug] Stringify of expression with unnamed 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.
References: #3789
[sql] [bug] 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.
References: #3786
[sql] [bug] [mysql] [postgresql] 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 #3766.
References: #3765
[sql] [bug] Fixed bug where 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.
References: #3763
[postgresql] [bug] 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.
References: #3813
[postgresql] [bug] 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.
References: #3807
[mysql] [bug] Added support for parsing MySQL/Connector boolean and integer arguments within the URL query string: connection_timeout, connect_timeout, pool_size, get_warnings, raise_on_warnings, raw, consume_results, ssl_verify_cert, force_ipv6, pool_reset_session, compress, allow_local_infile, use_pure.
This change is also backported to: 1.0.15
References: #3787
[mysql] [bug] Fixed bug where the "literal_binds" flag would not be propagated to a CAST expression under MySQL.
References: #3766
[mssql] [bug] Changed the query used to get "default schema name", from one that queries the database principals table to using the "schema_name()" function, as issues have been reported that the former system was unavailable on the Azure Data Warehouse edition. It is hoped that this will finally work across all SQL Server versions and authentication styles.
This change is also backported to: 1.0.16
References: #3810
[mssql] [bug] Updated the server version info scheme for pyodbc to use SQL Server SERVERPROPERTY(), rather than relying upon pyodbc.SQL_DBMS_VER, which continues to be unreliable particularly with FreeTDS.
This change is also backported to: 1.0.16
References: #3814
[mssql] [bug] Added error code 20017 "unexpected EOF from the server" to the list of disconnect exceptions that result in a connection pool reset. Pull request courtesy Ken Robbins.
This change is also backported to: 1.0.16
[bug] [orm.declarative] Fixed bug where setting up a single-table inh subclass of a joined-table subclass which included an extra column would corrupt the foreign keys collection of the mapped table, thereby interfering with the initialization of relationships.
This change is also backported to: 1.0.16
References: #3797
[orm] [change] Removed a warning that dates back to 0.4 which emits when a same-named relationship is placed on two mappers that inherits via joined o
Released: July 26, 2016
[orm] [change] Removed a warning that dates back to 0.4 which emits when a same-named relationship is placed on two mappers that inherits via joined or single table inheritance. The warning does not apply to the current unit of work implementation.
References: #3749
[sql] [bug] Fixed bug in new CTE feature for update/insert/delete stated as a CTE inside of an enclosing statement (typically SELECT) whereby oninsert and onupdate values weren't called upon for the embedded statement.
References: #3745
[sql] [bug] Fixed bug in new CTE feature for update/insert/delete whereby
an anonymous (e.g. no name passed) CTE construct around
the statement would fail.
References: #3744
[postgresql] [bug] Fixed bug whereby TypeDecorator and Variant
types were not deeply inspected enough by the PostgreSQL dialect
to determine if SMALLSERIAL or BIGSERIAL needed to be rendered
rather than SERIAL.
This change is also backported to: 1.0.14
References: #3739
[oracle] [bug] Fixed bug in Select.with_for_update.of, where the Oracle
"rownum" approach to LIMIT/OFFSET would fail to accommodate for the
expressions inside the "OF" clause, which must be stated at the topmost
level referring to expression within the subquery. The expressions are
now added to the subquery if needed.
This change is also backported to: 1.0.14
References: #3741
[bug] [ext] Fixed bug in sqlalchemy.ext.baked where the unbaking of a
subquery eager loader query would fail due to a variable scoping
issue, when multiple subquery loaders were involved. Pull request
courtesy Mark Hahnenberg.
This change is also backported to: 1.0.15
References: #3743
[bug] [ext] sqlalchemy.ext.indexable will intercept IndexError as well as KeyError when raising as AttributeError.
[ext] [feature] Added a "default" parameter to the new sqlalchemy.ext.indexable extension.
[sql] [bug] Fixed issue in SQL math negation operator where the type of the expression would no longer be the numeric type of the original. This would
Released: July 1, 2016
[sql] [bug] Fixed issue in SQL math negation operator where the type of the expression would no longer be the numeric type of the original. This would cause issues where the type determined result set behaviors.
This change is also backported to: 1.0.14
References: #3735
[sql] [bug] Fixed bug whereby the __getstate__ / __setstate__
methods for sqlalchemy.util.Properties were
non-working due to the transition in the 1.0 series to __slots__.
The issue potentially impacted some third-party applications.
Pull request courtesy Pieter Mulder.
This change is also backported to: 1.0.14
References: #3728
[sql] [bug] The processing performed by the Boolean datatype for backends
that only feature integer types has been made consistent between the
pure Python and C-extension versions, in that the C-extension version
will accept any integer value from the database as a boolean, not just
zero and one; additionally, non-boolean integer values being sent to
the database are coerced to exactly zero or one, instead of being
passed as the original integer value.
References: #3730
[sql] [bug] Rolled back the validation rules a bit in Enum to allow
unknown string values to pass through, unless the flag
validate_string=True is passed to the Enum; any other kind of object is
still of course rejected. While the immediate use
is to allow comparisons to enums with LIKE, the fact that this
use exists indicates there may be more unknown-string-comparison use
cases than we expected, which hints that perhaps there are some
unknown string-INSERT cases too.
References: #3725
[postgresql] [bug] [ext] Made a slight behavioral change in the sqlalchemy.ext.compiler
extension, whereby the existing compilation schemes for an established
construct would be removed if that construct itself didn't already
have its own dedicated __visit_name__. This was a
rare occurrence in 1.0, however in 1.1 postgresql.ARRAY
subclasses sqltypes.ARRAY and has this behavior.
As a result, setting up a compilation handler for another dialect
such as SQLite would render the main postgresql.ARRAY
object no longer compilable.
References: #3732
[mysql] [bug] Dialed back the "order the primary key columns per auto-increment"
described in change_mysql_3216 a bit, so that if the
PrimaryKeyConstraint is explicitly defined, the order
of columns is maintained exactly, allowing control of this behavior
when necessary.
References: #3726
[orm] [change] The Mapper.order_by parameter is deprecated. This is an old parameter no longer relevant to how SQLAlchemy works, once the Query object…
Released: June 16, 2016
[orm] [ext] [feature] A new ORM extension indexable_toplevel is added, which allows
construction of Python attributes which refer to specific elements
of "indexed" structures such as arrays and JSON fields. Pull request
courtesy Jeong YunWon.
[orm] [bug] Fixed an issue where a many-to-one change of an object from one parent to another could work inconsistently when combined with an un-flushed modification of the foreign key attribute. The attribute move now considers the database-committed value of the foreign key in order to locate the "previous" parent of the object being moved. This allows events to fire off correctly including backref events. Previously, these events would not always fire. Applications which may have relied on the previously broken behavior may be affected.
References: #3708
[orm] [feature] Added new flag Session.bulk_insert_mappings.render_nulls
which allows an ORM bulk INSERT to occur with NULL values rendered;
this bypasses server side defaults, however allows all statements
to be formed with the same set of columns, allowing them to be
batched. Pull request courtesy Tobias Sauerwein.
[orm] [feature] Added new event AttributeEvents.init_scalar(), as well
as a new example suite illustrating its use. This event can be used
to provide a Core-generated default value to a Python-side attribute
before the object is persisted.
References: #1311
[orm] [feature] Added AutomapBase.prepare.schema to the
AutomapBase.prepare() method, to indicate which schema
tables should be reflected from if not the default schema.
Pull request courtesy Josh Marlow.
[orm] [change] The Mapper.order_by parameter is deprecated.
This is an old parameter no longer relevant to how SQLAlchemy
works, once the Query object was introduced. By deprecating it
we establish that we aren't supporting non-working use cases
and that we encourage applications to move off of the use of this
parameter.
References: #3394
[orm] [bug] Fixed bug where deferred columns would inadvertently be set up
for database load on the next object-wide unexpire, when the object
were merged into the session with session.merge(obj, load=False).
References: #3488
[orm] [bug] [mysql] Further continuing on the common MySQL exception case of
a savepoint being cancelled first covered in #2696,
the failure mode in which the Session is placed when a
SAVEPOINT vanishes before rollback has been improved to allow the
Session to still function outside of that savepoint.
It is assumed that the savepoint operation failed and was cancelled.
References: #3680
[orm] [bug] Fixed bug where a newly inserted instance that is rolled back would still potentially cause persistence conflicts on the next transaction, because the instance would not be checked that it was expired. This fix will resolve a large class of cases that erroneously cause the "New instance with identity X conflicts with persistent instance Y" error.
References: #3677
[orm] [bug] An improvement to the workings of Query.correlate() such
that when a "polymorphic" entity is used which represents a straight
join of several tables, the statement will ensure that all the
tables within the join are part of what's correlating.
References: #3662
[orm] [bug] Fixed bug which would cause an eagerly loaded many-to-one attribute to not be loaded, if the joined eager load were from a row where the same entity were present multiple times, some calling for the attribute to be eagerly loaded and others not. The logic here is revised to take in the attribute even though a different loader path has handled the parent entity already.
References: #3431
[orm] [bug] A refinement to the logic which adds columns to the resulting SQL when
Query.distinct() is combined with Query.order_by() such
that columns which are already present will not be added
a second time, even if they are labeled with a different name.
Regardless of this change, the extra columns added to the SQL have
never been returned in the final result, so this change only impacts
the string form of the statement as well as its behavior when used in
a Core execution context. Additionally, columns are no longer added
when the DISTINCT ON format is used, provided the query is not
wrapped inside a subquery due to joined eager loading.
References: #3641
[orm] [feature] Added new parameter orm.mapper.passive_deletes to
available mapper options. This allows a DELETE to proceed
for a joined-table inheritance mapping against the base table only,
while allowing for ON DELETE CASCADE to handle deleting the row
from the subclass tables.
References: #2349
[orm] [feature] Calling str() on a core SQL construct has been made more "friendly", when the construct contains non-standard SQL elements such as RETURNING, array index operations, or dialect-specific or custom datatypes. A string is now returned in these cases rendering an approximation of the construct (typically the PostgreSQL-style version of it) rather than raising an error.
References: #3631
[orm] [bug] Fixed issue where two same-named relationships that refer to a base class and a concrete-inherited subclass would raise an error if those relationships were set up using "backref", while setting up the identical configuration using relationship() instead with the conflicting names would succeed, as is allowed in the case of a concrete mapping.
References: #3630
[orm] [feature] The str() call for Query will now take into account
the Engine to which the Session is bound, when
generating the string form of the SQL, so that the actual SQL
that would be emitted to the database is shown, if possible. Previously,
only the engine associated with the MetaData to which the
mappings are associated would be used, if present. If
no bind can be located either on the Session or on
the MetaData to which the mappings are associated, then
the "default" dialect is used to render the SQL, as was the case
previously.
References: #3081
[orm] [bug] The Session.merge() method now tracks pending objects by
primary key before emitting an INSERT, and merges distinct objects with
duplicate primary keys together as they are encountered, which is
essentially semi-deterministic at best. This behavior
matches what happens already with persistent objects.
References: #3601
[orm] [bug] Fixed bug where the "single table inheritance" criteria would be added onto the end of a query in some inappropriate situations, such as when querying from an exists() of a single-inheritance subclass.
References: #3582
[orm] [bug] Added a new type-level modifier TypeEngine.evaluates_none()
which indicates to the ORM that a positive set of None should be
persisted as the value NULL, instead of omitting the column from
the INSERT statement. This feature is used both as part of the
implementation for #3514 as well as a standalone feature
available on any type.
References: #3250
[orm] [bug] Internal calls to "bookkeeping" functions within
Session.bulk_save_objects() and related bulk methods have
been scaled back to the extent that this functionality is not
currently used, e.g. checks for column default values to be
fetched after an INSERT or UPDATE statement.
References: #3526
[orm] [feature] The SessionEvents suite now includes events to allow
unambiguous tracking of all object lifecycle state transitions
in terms of the Session itself, e.g. pending,
transient, persistent, detached. The state of the object
within each event is also defined.
References: #2677
[orm] [feature] Added a new session lifecycle state :term:deleted. This new state
represents an object that has been deleted from the :term:persistent
state and will move to the :term:detached state once the transaction
is committed. This resolves the long-standing issue that objects
which were deleted existed in a gray area between persistent and
detached. The InstanceState.persistent accessor will
no longer report on a deleted object as persistent; the
InstanceState.deleted accessor will instead be True for
these objects, until they become detached.
Unknown interpreted text role "term".
Unknown interpreted text role "term".
Unknown interpreted text role "term".
References: #2677
[orm] [change] The Session.weak_identity_map parameter is deprecated.
See the new recipe at session_referencing_behavior for
an event-based approach to maintaining strong identity map behavior.
References: #2677
[orm] [feature] Added new checks for the common error case of passing mapped classes or mapped instances into contexts where they are interpreted as SQL bound parameters; a new exception is raised for this.
References: #3321
[orm] [bug] [postgresql] Additional fixes have been made regarding the value of None
in conjunction with the PostgreSQL postgresql.JSON type. When
the JSON.none_as_null flag is left at its default
value of False, the ORM will now correctly insert the JSON
"'null'" string into the column whenever the value on the ORM
object is set to the value None or when the value None
is used with Session.bulk_insert_mappings(),
including if the column has a default or server default on it.
References: #3514
[orm] [feature] Added new relationship loading strategy orm.raiseload() (also
accessible via lazy='raise'). This strategy behaves almost like
orm.noload() but instead of returning None it raises an
InvalidRequestError. Pull request courtesy Adrian Moennich.
References: #3512
[engine] [feature] Added connection pool events ConnectionEvents.close(),
ConnectionEvents.detach(),
ConnectionEvents.close_detached().
[engine] [feature] All string formatting of bound parameter sets and result rows for
logging, exception, and repr() purposes now truncate very large
scalar values within each collection, including an
"N characters truncated"
notation, similar to how the display for large multiple-parameter sets
are themselves truncated.
References: #2837
[engine] [feature] Multi-tenancy schema translation for Table objects is added.
This supports the use case of an application that uses the same set of
Table objects in many schemas, such as schema-per-user.
A new execution option
Connection.execution_options.schema_translate_map is
added.
References: #2685
[engine] [feature] Added a new entrypoint system to the engine to allow "plugins" to
be stated in the query string for a URL. Custom plugins can
be written which will be given the chance up front to alter and/or
consume the engine's URL and keyword arguments, and then at engine
create time will be given the engine itself to allow additional
modifications or event registration. Plugins are written as a
subclass of CreateEnginePlugin; see that class for
details.
References: #3536
[sql] [feature] Added TABLESAMPLE support via the new FromClause.tablesample()
method and standalone function. Pull request courtesy Ilja Everilä.
References: #3718
[sql] [bug] FromClause.count() is deprecated. This function makes use of
an arbitrary column in the table and is not reliable; for Core use,
func.count() should be preferred.
References: #3724
[sql] [feature] Added support for ranges in window functions, using the
expression.over.range_ and
expression.over.rows parameters.
References: #3049
[sql] [feature] Implemented reflection of CHECK constraints for SQLite and PostgreSQL.
This is available via the new inspector method
Inspector.get_check_constraints() as well as when reflecting
Table objects in the form of CheckConstraint
objects present in the constraints collection. Pull request courtesy
Alex Grönholm.
[sql] [feature] New ColumnOperators.is_distinct_from() and
ColumnOperators.isnot_distinct_from() operators; pull request
courtesy Sebastian Bank.
[sql] [feature] Added a hook in DDLCompiler.visit_create_table() called
DDLCompiler.create_table_suffix(), allowing custom dialects
to add keywords after the "CREATE TABLE" clause. Pull request
courtesy Mark Sandan.
[sql] [feature] Negative integer indexes are now accommodated by rows
returned from a ResultProxy. Pull request courtesy
Emanuele Gaifas.
[sql] [feature] Added Select.lateral() and related constructs to allow
for the SQL standard LATERAL keyword, currently only supported
by PostgreSQL.
References: #2857
[sql] [feature] Added support for rendering "FULL OUTER JOIN" to both Core and ORM. Pull request courtesy Stefan Urbanek.
References: #1957
[sql] [feature] CTE functionality has been expanded to support all DML, allowing INSERT, UPDATE, and DELETE statements to both specify their own WITH clause, as well as for these statements themselves to be CTE expressions when they include a RETURNING clause.
References: #2551
[sql] [feature] Added support for PEP-435-style enumerated classes, namely
Python 3's enum.Enum class but also including compatible
enumeration libraries, to the types.Enum datatype.
The types.Enum datatype now also performs in-Python validation
of incoming values, and adds an option to forego creating the
CHECK constraint Enum.create_constraint.
Pull request courtesy Alex Grönholm.
[sql] [feature] A deep improvement to the recently added TextClause.columns()
method, and its interaction with result-row processing, now allows
the columns passed to the method to be positionally matched with the
result columns in the statement, rather than matching on name alone.
The advantage to this includes that when linking a textual SQL statement
to an ORM or Core table model, no system of labeling or de-duping of
common column names needs to occur, which also means there's no need
to worry about how label names match to ORM columns and so-forth. In
addition, the ResultProxy has been further enhanced to
map column and string keys to a row with greater precision in some
cases.
References: #3501
[sql] [feature] Added a new type to core types.JSON. This is the
base of the PostgreSQL postgresql.JSON type as well as that
of the new mysql.JSON type, so that a PG/MySQL-agnostic
JSON column may be used. The type features basic index and path
searching support.
References: #3619
[sql] [bug] Fixed an assertion that would raise somewhat inappropriately
if a Index were associated with a Column that
is associated with a lower-case-t TableClause; the
association should be ignored for the purposes of associating
the index with a Table.
References: #3616
[sql] [change] [mysql] The system by which a Column considers itself to be an
"auto increment" column has been changed, such that autoincrement
is no longer implicitly enabled for a Table that has a
composite primary key. In order to accommodate being able to enable
autoincrement for a composite PK member column while at the same time
maintaining SQLAlchemy's long standing behavior of enabling
implicit autoincrement for a single integer primary key, a third
state has been added to the Column.autoincrement parameter
"auto", which is now the default.
References: #3216
[sql] [bug] The type_coerce() construct is now a fully fledged Core
expression element which is late-evaluated at compile time. Previously,
the function was only a conversion function which would handle different
expression inputs by returning either a Label of a column-oriented
expression or a copy of a given BindParameter object,
which in particular prevented the operation from being logically
maintained when an ORM-level expression transformation would convert
a column to a bound parameter (e.g. for lazy loading).
References: #3531
[sql] [bug] The TypeDecorator type extender will now work in conjunction
with a SchemaType implementation, typically Enum
or Boolean with regards to ensuring that the per-table
events are propagated from the implementation type to the outer type.
These events are used
to ensure that the constraints or PostgreSQL types (e.g. ENUM)
are correctly created (and possibly dropped) along with the parent
table.
References: #2919
[sql] [feature] Added support for "set-aggregate" functions of the form
<function> WITHIN GROUP (ORDER BY <criteria>), using the
method FunctionElement.within_group(). A series of common
set-aggregate functions with return types derived from the set have
been added. This includes functions like percentile_cont,
dense_rank and others.
References: #1370
[sql] [feature] [postgresql] Added support for the SQL-standard function array_agg,
which automatically returns an postgresql.ARRAY of the correct type
and supports index / slice operations, as well as
postgresql.array_agg(), which returns a postgresql.ARRAY
with additional comparison features. As arrays are only
supported on PostgreSQL at the moment, only actually works on
PostgreSQL. Also added a new construct
postgresql.aggregate_order_by in support of PG's
"ORDER BY" extension.
References: #3132
[sql] [feature] Added a new type to core types.ARRAY. This is the
base of the PostgreSQL postgresql.ARRAY type, and is now part of Core
to begin supporting various SQL-standard array-supporting features
including some functions and eventual support for native arrays
on other databases that have an "array" concept, such as DB2 or Oracle.
Additionally, new operators expression.any_() and
expression.all_() have been added. These support not just
array constructs on PostgreSQL, but also subqueries that are usable
on MySQL (but sadly not on PostgreSQL).
References: #3516
[sql] [bug] The behavior of the union() construct and related constructs
such as Query.union() now handle the case where the embedded
SELECT statements need to be parenthesized due to the fact that they
include LIMIT, OFFSET and/or ORDER BY. These queries do not work
on SQLite, and will fail on that backend as they did before, but
should now work on all other backends.
References: #2528
Column objects
are now run through "update_wrapper", or an equivalent function
if a callable non-function is passed, so that introspection tools
preserve the name and docstring of the wrapped function. Pull
request courtesy hsum.[postgresql] [feature] Added support for PostgreSQL's INSERT..ON CONFLICT using a new
PostgreSQL-specific postgresql.dml.Insert object.
Pull request and extensive efforts here by Robin Thomas.
References: #3529
[postgresql] [feature] The DDL for DROP INDEX will emit "CONCURRENTLY" if the
postgresql_concurrently flag is set upon the
Index and if the database in use is detected as
PostgreSQL version 9.2 or greater. For CREATE INDEX, database
version detection is also added which will omit the clause if
PG version is less than 8.2. Pull request courtesy Iuri de Silvio.
[postgresql] [feature] Added new parameter PGInspector.get_view_names.include,
allowing specification for what kinds of views should be returned.
Currently "plain" and "materialized" views are included. Pull
request courtesy Sebastian Bank.
References: #3588
[postgresql] [feature] Added postgresql_tablespace as an argument to Index
to allow specification of TABLESPACE for an index in PostgreSQL.
Complements the same-named parameter on Table. Pull
request courtesy Benjamin Bertrand.
References: #3720
[postgresql] [feature] Added new parameter
GenerativeSelect.with_for_update.key_share, which
will render the FOR NO KEY UPDATE version of FOR UPDATE
and FOR KEY SHARE instead of FOR SHARE
on the PostgreSQL backend. Pull request courtesy Sergey Skopin.
[postgresql] [feature] [oracle] Added new parameter
GenerativeSelect.with_for_update.skip_locked, which
will render the SKIP LOCKED phrase for a FOR UPDATE or
FOR SHARE lock on the PostgreSQL and Oracle backends. Pull
request courtesy Jack Zhou.
[postgresql] [feature] Added a new dialect for the PyGreSQL PostgreSQL dialect. Thanks to Christoph Zwerschke and Kaolin Imago Fire for their efforts.
[postgresql] [change] The sqlalchemy.dialects.postgres module, long deprecated, is
removed; this has emitted a warning for many years and projects
should be calling upon sqlalchemy.dialects.postgresql.
Engine URLs of the form postgres:// will still continue to function,
however.
[postgresql] [bug] Added support for reflecting the source of materialized views
to the PostgreSQL version of the Inspector.get_view_definition()
method.
References: #3587
[postgresql] [bug] The use of a postgresql.ARRAY object that refers
to a types.Enum or postgresql.ENUM subtype
will now emit the expected "CREATE TYPE" and "DROP TYPE" DDL when
the type is used within a "CREATE TABLE" or "DROP TABLE".
References: #2729
[postgresql] [bug] The "hashable" flag on special datatypes such as postgresql.ARRAY,
postgresql.JSON and postgresql.HSTORE is now
set to False, which allows these types to be fetchable in ORM
queries that include entities within the row.
References: #3499
[postgresql] [bug] The PostgreSQL postgresql.ARRAY type now supports multidimensional
indexed access, e.g. expressions such as somecol[5][6] without
any need for explicit casts or type coercions, provided
that the postgresql.ARRAY.dimensions parameter is set to the
desired number of dimensions.
References: #3487
[postgresql] [bug] The return type for the postgresql.JSON and postgresql.JSONB
when using indexed access has been fixed to work like PostgreSQL itself,
and returns an expression that itself is of type postgresql.JSON
or postgresql.JSONB. Previously, the accessor would return
NullType which disallowed subsequent JSON-like operators to be
used.
References: #3503
[postgresql] [bug] The postgresql.JSON, postgresql.JSONB and
postgresql.HSTORE datatypes now allow full control over the
return type from an indexed textual access operation, either column[someindex].astext
for a JSON type or column[someindex] for an HSTORE type,
via the postgresql.JSON.astext_type and
postgresql.HSTORE.text_type parameters.
References: #3503
[postgresql] [bug] The postgresql.JSON.Comparator.astext modifier no longer
calls upon ColumnElement.cast() implicitly, as PG's JSON/JSONB
types allow cross-casting between each other as well. Code that
makes use of ColumnElement.cast() on JSON indexed access,
e.g. col[someindex].cast(Integer), will need to be changed
to call postgresql.JSON.Comparator.astext explicitly.
References: #3503
[postgresql] [feature] Added a new constant postgresql.JSON.NULL, indicating
that the JSON NULL value should be used for a value
regardless of other settings.
References: #3514
[mysql] [feature] Added support for "autocommit" on MySQL drivers, via the AUTOCOMMIT isolation level setting. Pull request courtesy Roman Podoliaka.
References: #3332
[mysql] [feature] Added mysql.JSON for MySQL 5.7. The JSON type provides
persistence of JSON values in MySQL as well as basic operator support
of "getitem" and "getpath", making use of the JSON_EXTRACT
function in order to refer to individual paths in a JSON structure.
References: #3547
[mysql] [change] The MySQL dialect no longer generates an extra "KEY" directive when generating CREATE TABLE DDL for a table using InnoDB with a composite primary key with AUTO_INCREMENT on a column that isn't the first column; to overcome InnoDB's limitation here, the PRIMARY KEY constraint is now generated with the AUTO_INCREMENT column placed first in the list of columns.
References: #3216
[sqlite] [feature] The SQLite dialect now reflects ON UPDATE and ON DELETE phrases within foreign key constraints. Pull request courtesy Michal Petrucha.
[sqlite] [feature] The SQLite dialect now reflects the names of primary key constraints. Pull request courtesy Diana Clarke.
References: #3629
[sqlite] [bug] The workaround for right-nested joins on SQLite, where they are rewritten as subqueries in order to work around SQLite's lack of support for this syntax, is lifted when SQLite version 3.7.16 or greater is detected.
References: #3634
[sqlite] [bug] The workaround for SQLite's unexpected delivery of column names as
tablename.columnname for some kinds of queries is now disabled
when SQLite version 3.10.0 or greater is detected.
References: #3633
[sqlite] [change] Added support to the SQLite dialect for the
Inspector.get_schema_names() method to work with SQLite;
pull request courtesy Brian Van Klaveren. Also repaired support
for creation of indexes with schemas as well as reflection of
foreign key constraints in schema-bound tables.
[mssql] [feature] The mssql_clustered flag available on UniqueConstraint,
PrimaryKeyConstraint, Index now defaults to
None, and can be set to False which will render the NONCLUSTERED
keyword in particular for a primary key, allowing a different index to
be used as "clustered". Pull request courtesy Saulius Žemaitaitis.
[mssql] [bug] Adjustments to the mxODBC dialect to make use of the BinaryNull
symbol when appropriate in conjunction with the VARBINARY
data type. Pull request courtesy Sheila Allen.
[mssql] [feature] Added basic isolation level support to the SQL Server dialects
via create_engine.isolation_level and
Connection.execution_options.isolation_level
parameters.
References: #3534
[mssql] [change] The legacy_schema_aliasing flag, introduced in version 1.0.5
as part of #3424 to allow disabling of the MSSQL dialect's
attempts to create aliases for schema-qualified tables, now defaults
to False; the old behavior is now disabled unless explicitly turned on.
References: #3434
[mssql] [bug] Fixed issue where the SQL Server dialect would reflect a string-
or other variable-length column type with unbounded length
by assigning the token "max" to the
length attribute of the string. While using the "max" token
explicitly is supported by the SQL Server dialect, it isn't part
of the normal contract of the base string types, and instead the
length should just be left as None. The dialect now assigns the
length to None on reflection of the type so that the type behaves
normally in other contexts.
References: #3504
[bug] [ext] The docstring specified on a hybrid property or method is now honored at the class level, allowing it to work with tools like Sphinx autodoc. The mechanics here necessarily involve some wrapping of expressions to occur for hybrid properties, which may cause them to appear differently using introspection.
References: #3653
[ext] [feature] Added MutableSet and MutableList helper classes
to the mutable_toplevel extension. Pull request courtesy
Jeong YunWon.
References: #3297
[bug] [sybase] The unsupported Sybase dialect now raises NotImplementedError
when attempting to compile a query that includes "offset"; Sybase
has no straightforward "offset" feature.
References: #2278
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.