SqlAlchemy 2.0 中文文档(五十九)(2)https://developer.aliyun.com/article/1563148
1.4.29
Released: December 22, 2021
orm
- [orm] [usecase]
AddedSession.get.execution_options
parameter which was previously missing from theSession.get()
method.
References: #7410 - [orm] [bug]
Fixed issue in new “loader criteria” methodPropComparator.and_()
where usage with a loader strategy likeselectinload()
against a column that was a member of the.c.
collection of a subquery object, where the subquery would be dynamically added to the FROM clause of the statement, would be subject to stale parameter values within the subquery in the SQL statement cache, as the process used by the loader strategy to replace the parameters at execution time would fail to accommodate the subquery when received in this form.
References: #7489 - [orm] [bug]
Fixed recursion overflow which could occur within ORM statement compilation when using either thewith_loader_criteria()
feature or the thePropComparator.and_()
method within a loader strategy in conjunction with a subquery which referred to the same entity being altered by the criteria option, or loaded by the loader strategy. A check for coming across the same loader criteria option in a recursive fashion has been added to accommodate for this scenario.
References: #7491 - [orm] [bug] [mypy]
Fixed issue where the__class_getitem__()
method of the generated declarative base class byas_declarative()
would lead to inaccessible class attributes such as__table__
, for cases where aGeneric[T]
style typing declaration were used in the class hierarchy. This is in continuation from the basic addition of__class_getitem__()
in #7368. Pull request courtesy Kai Mueller.
References: #7368, #7462 - [orm] [bug] [regression]
Fixed caching-related issue where the use of a loader option of the formlazyload(aliased(A).bs).joinedload(B.cs)
would fail to result in the joinedload being invoked for runs subsequent to the query being cached, due to a mismatch for the options / object path applied to the objects loaded for a query with a lead entity that usedaliased()
.
References: #7447
engine
- [engine] [bug]
Corrected the error message for theAttributeError
that’s raised when attempting to write to an attribute on theRow
class, which is immutable. The previous message claimed the column didn’t exist which is misleading.
References: #7432 - [engine] [bug] [regression]
Fixed regression in themake_url()
function used to parse URL strings where the query string parsing would go into a recursion overflow if a Python 2u''
string were used.
References: #7446
mypy
- [mypy] [bug]
Fixed mypy regression where the release of mypy 0.930 added additional internal checks to the format of “named types”, requiring that they be fully qualified and locatable. This broke the mypy plugin for SQLAlchemy, raising an assertion error, as there was use of symbols such as__builtins__
and other un-locatable or unqualified names that previously had not raised any assertions.
References: #7496
asyncio
- [asyncio] [usecase]
Addedasync_engine_config()
function to create an async engine from a configuration dict. This otherwise behaves the same asengine_from_config()
.
References: #7301
mariadb
- [mariadb] [bug]
Corrected the error classes inspected for the “is_disconnect” check for themariadbconnector
dialect, which was failing for disconnects that occurred due to common MySQL/MariaDB error codes such as 2006; the DBAPI appears to currently use themariadb.InterfaceError
exception class for disconnect errors such as error code 2006, which has been added to the list of classes checked.
References: #7457
tests
- [tests] [bug] [regression]
Fixed a regression in the test suite where the test calledCompareAndCopyTest::test_all_present
would fail on some platforms due to additional testing artifacts being detected. Pull request courtesy Nils Philippsen.
References: #7450
1.4.28
Released: December 9, 2021
platform
- [platform] [bug]
Python 3.10 has deprecated “distutils” in favor of explicit use of “setuptools” in PEP 632; SQLAlchemy’s setup.py has replaced imports accordingly. However, since setuptools itself only recently added the replacement symbols mentioned in pep-632 as of November of 2021 in version 59.0.1,setup.py
still has fallback imports to distutils, as SQLAlchemy 1.4 does not have a hard setuptools versioning requirement at this time. SQLAlchemy 2.0 is expected to use a full PEP 517 installation layout which will indicate appropriate setuptools versioning up front.
References: #7311
orm
- [orm] [bug] [ext]
Fixed issue where the internal cloning used by thePropComparator.any()
method on arelationship()
in the case where the related class also makes use of ORM polymorphic loading, would fail if a hybrid property on the related, polymorphic class were used within the criteria for theany()
operation.
References: #7425 - [orm] [bug] [mypy]
Fixed issue where theas_declarative()
decorator and similar functions used to generate the declarative base class would not copy the__class_getitem__()
method from a given superclass, which prevented the use of pep-484 generics in conjunction with theBase
class. Pull request courtesy Kai Mueller.
References: #7368 - [orm] [bug] [regression]
Fixed ORM regression where the new behavior of “eager loaders run on unexpire” added in #1763 would lead to loader option errors being raised inappropriately for the case where a singleQuery
orSelect
were used to load multiple kinds of entities, along with loader options that apply to just one of those kinds of entity like ajoinedload()
, and later the objects would be refreshed from expiration, where the loader options would attempt to be applied to the mismatched object type and then raise an exception. The check for this mismatch now bypasses raising an error for this case.
References: #7318 - [orm] [bug]
User defined ORM options, such as those illustrated in the dogpile.caching example which subclassUserDefinedOption
, by definition are handled on every statement execution and do not need to be considered as part of the cache key for the statement. Caching of the baseExecutableOption
class has been modified so that it is no longer aHasCacheKey
subclass directly, so that the presence of user defined option objects will not have the unwanted side effect of disabling statement caching. Only ORM specific loader and criteria options, which are all internal to SQLAlchemy, now participate within the caching system.
References: #7394 - [orm] [bug]
Fixed issue where mappings that made use ofsynonym()
and potentially other kinds of “proxy” attributes would not in all cases successfully generate a cache key for their SQL statements, leading to degraded performance for those statements.
References: #7394 - [orm] [bug]
Fixed issue where a list mapped withrelationship()
would go into an endless loop if in-place added to itself, i.e. the+=
operator were used, as well as if.extend()
were given the same list.
References: #7389 - [orm] [bug]
Fixed issue where if an exception occurred when theSession
were to close the connection within theSession.commit()
method, when using a context manager forSession.begin()
, it would attempt a rollback which would not be possible as theSession
was in between where the transaction is committed and the connection is then to be returned to the pool, raising the exception “this sessiontransaction is in the committed state”. This exception can occur mostly in an asyncio context where CancelledError can be raised.
References: #7388 - [orm] [deprecated]
Deprecated an undocumented loader option syntax".*"
, which appears to be no different than passing a single asterisk, and will emit a deprecation warning if used. This syntax may have been intended for something but there is currently no need for it.
References: #4390
engine
- [engine] [usecase]
Added support forcopy()
anddeepcopy()
to theURL
class. Pull request courtesy Tom Ritchford.
References: #7400
sql
- [sql] [usecase]
”Compound select” methods likeSelect.union()
,Select.intersect_all()
etc. now accept*other
as an argument rather thanother
to allow for multiple additional SELECTs to be compounded with the parent statement at once. In particular, the change as applied toCTE.union()
andCTE.union_all()
now allow for a so-called “non-linear CTE” to be created with theCTE
construct, whereas previously there was no way to have more than two CTE sub-elements in a UNION together while still correctly calling upon the CTE in recursive fashion. Pull request courtesy Eric Masseran.
References: #7259 - [sql] [usecase]
Support multiple clause elements in theExists.where()
method, unifying the api with the one presented by a normalselect()
construct.
References: #7386 - [sql] [bug] [regression]
Extended theTypeDecorator.cache_ok
attribute and corresponding warning message if this flag is not defined, a behavior first established forTypeDecorator
as part of #6436, to also take place forUserDefinedType
, by generalizing the flag and associated caching logic to a new common base for these two types,ExternalType
to createUserDefinedType.cache_ok
.
The change means any currentUserDefinedType
will now cause SQL statement caching to no longer take place for statements which make use of the datatype, along with a warning being emitted, unless the class defines theUserDefinedType.cache_ok
flag as True. If the datatype cannot form a deterministic, hashable cache key derived from its arguments, the attribute may be set to False which will continue to keep caching disabled but will suppress the warning. In particular, custom datatypes currently used in packages such as SQLAlchemy-utils will need to implement this flag. The issue was observed as a result of a SQLAlchemy-utils datatype that is not currently cacheable.
See alsoExternalType.cache_ok
References: #7319 - [sql] [bug]
Custom SQL elements, third party dialects, custom or third party datatypes will all generate consistent warnings when they do not clearly opt in or out of SQL statement caching, which is achieved by setting the appropriate attributes on each type of class. The warning links to documentation sections which indicate the appropriate approach for each type of object in order for caching to be enabled.
References: #7394 - [sql] [bug]
Fixed missing caching directives for a few lesser used classes in SQL Core which would cause[no key]
to be logged for elements which made use of these.
References: #7394
mypy
- [mypy] [bug]
Fixed Mypy crash which would occur when using Mypy plugin against code which made use ofdeclared_attr
methods for non-mapped names like__mapper_args__
,__table_args__
, or other dunder names, as the plugin would try to interpret these as mapped attributes which would then be later mis-handled. As part of this change, the decorated function is still converted by the plugin into a generic assignment statement (e.g.__mapper_args__: Any
) so that the argument signature can continue to be annotated in the same way one would for any other@classmethod
without Mypy complaining about the wrong argument type for a method that isn’t explicitly@classmethod
.
References: #7321
postgresql
- [postgresql] [bug]
Fixed missing caching directives forhstore
andarray
constructs which would cause[no key]
to be logged for these elements.
References: #7394
tests
- [tests] [bug]
Implemented support for the test suite to run correctly under Pytest 7. Previously, only Pytest 6.x was supported for Python 3, however the version was not pinned on the upper bound in tox.ini. Pytest is not pinned in tox.ini to be lower than version 8 so that SQLAlchemy versions released with the current codebase will be able to be tested under tox without changes to the environment. Much thanks to the Pytest developers for their help with this issue.
1.4.27
Released: November 11, 2021
orm
- [orm] [bug]
Fixed bug in “relationship to aliased class” feature introduced at Relationship to Aliased Class where it was not possible to create a loader strategy option targeting an attribute on the target using thealiased()
construct directly in a second loader option, such asselectinload(A.aliased_bs).joinedload(aliased_b.cs)
, without explicitly qualifying usingPropComparator.of_type()
on the preceding element of the path. Additionally, targeting the non-aliased class directly would be accepted (inappropriately), but would silently fail, such asselectinload(A.aliased_bs).joinedload(B.cs)
; this now raises an error referring to the typing mismatch.
References: #7224 - [orm] [bug]
AllResult
objects will now consistently raiseResourceClosedError
if they are used after a hard close, which includes the “hard close” that occurs after calling “single row or value” methods likeResult.first()
andResult.scalar()
. This was already the behavior of the most common class of result objects returned for Core statement executions, i.e. those based onCursorResult
, so this behavior is not new. However, the change has been extended to properly accommodate for the ORM “filtering” result objects returned when using 2.0 style ORM queries, which would previously behave in “soft closed” style of returning empty results, or wouldn’t actually “soft close” at all and would continue yielding from the underlying cursor.
As part of this change, also addedResult.close()
to the baseResult
class and implemented it for the filtered result implementations that are used by the ORM, so that it is possible to call theCursorResult.close()
method on the underlyingCursorResult
when theyield_per
execution option is in use to close a server side cursor before remaining ORM results have been fetched. This was again already available for Core result sets but the change makes it available for 2.0 style ORM results as well.
References: #7274 - [orm] [bug] [regression]
Fixed 1.4 regression whereQuery.filter_by()
would not function correctly on aQuery
that was produced fromQuery.union()
,Query.from_self()
or similar.
References: #7239 - [orm] [bug]
Fixed issue where deferred polymorphic loading of attributes from a joined-table inheritance subclass would fail to populate the attribute correctly if theload_only()
option were used to originally exclude that attribute, in the case where the load_only were descending from a relationship loader option. The fix allows that other valid options such asdefer(..., raiseload=True)
etc. still function as expected.
References: #7304 - [orm] [bug] [regression]
Fixed 1.4 regression whereQuery.filter_by()
would not function correctly whenQuery.join()
were joined to an entity which made use ofPropComparator.of_type()
to specify an aliased version of the target entity. The issue also applies to future style ORM queries constructed withselect()
.
References: #7244
engine
- [engine] [bug]
Fixed issue in futureConnection
object where theConnection.execute()
method would not accept a non-dict mapping object, such as SQLAlchemy’s ownRowMapping
or otherabc.collections.Mapping
object as a parameter dictionary.
References: #7291 - [engine] [bug] [regression]
Fixed regression where theCursorResult.fetchmany()
method would fail to autoclose a server-side cursor (i.e. whenstream_results
oryield_per
is in use, either Core or ORM oriented results) when the results were fully exhausted.
References: #7274 - [engine] [bug]
Fixed issue in futureEngine
where calling uponEngine.begin()
and entering the context manager would not close the connection if the actual BEGIN operation failed for some reason, such as an event handler raising an exception; this use case failed to be tested for the future version of the engine. Note that the “future” context managers which handlebegin()
blocks in Core and ORM don’t actually run the “BEGIN” operation until the context managers are actually entered. This is different from the legacy version which runs the “BEGIN” operation up front.
References: #7272
sql
- [sql] [usecase]
AddedTupleType
to the top levelsqlalchemy
import namespace. - [sql] [bug] [regression]
Fixed regression where the row objects returned for ORM queries, which are now the normalRow
objects, would not be interpreted by theColumnOperators.in_()
operator as tuple values to be broken out into individual bound parameters, and would instead pass them as single values to the driver leading to failures. The change to the “expanding IN” system now accommodates for the expression already being of typeTupleType
and treats values accordingly if so. In the uncommon case of using “tuple-in” with an untyped statement such as a textual statement with no typing information, a tuple value is detected for values that implementcollections.abc.Sequence
, but that are notstr
orbytes
, as always when testing forSequence
.
References: #7292 - [sql] [bug]
Fixed issue where using the feature of using a string label for ordering or grouping described at Ordering or Grouping by a Label would fail to function correctly if used on aCTE
construct, when the CTE were embedded inside of an enclosingSelect
statement that itself was set up as a scalar subquery.
References: #7269 - [sql] [bug] [regression]
Fixed regression where thetext()
construct would no longer be accepted as a target case in the “whens” list within acase()
construct. The regression appears related to an attempt to guard against some forms of literal values that were considered to be ambiguous when passed here; however, there’s no reason the target cases shouldn’t be interpreted as open-ended SQL expressions just like anywhere else, and a literal string or tuple will be converted to a bound parameter as would be the case elsewhere.
References: #7287
schema
- [schema] [bug]
Fixed issue inTable
where theTable.implicit_returning
parameter would not be accommodated correctly when passed along withTable.extend_existing
to augment an existingTable
.
References: #7295
postgresql
- [postgresql] [usecase] [asyncpg]
Added overridable methodsPGDialect_asyncpg.setup_asyncpg_json_codec
andPGDialect_asyncpg.setup_asyncpg_jsonb_codec
codec, which handle the required task of registering JSON/JSONB codecs for these datatypes when using asyncpg. The change is that methods are broken out as individual, overridable methods to support third party dialects that need to alter or disable how these particular codecs are set up.
References: #7284 - [postgresql] [bug] [asyncpg]
Changed the asyncpg dialect to bind theFloat
type to the “float” PostgreSQL type instead of “numeric” so that the valuefloat(inf)
can be accommodated. Added test suite support for persistence of the “inf” value.
References: #7283 - [postgresql] [pg8000]
Improve array handling when using PostgreSQL with the pg8000 dialect.
References: #7167
mysql
- [mysql] [bug] [mariadb]
Reorganized the list of reserved words into two separate lists, one for MySQL and one for MariaDB, so that these diverging sets of words can be managed more accurately; adjusted the MySQL/MariaDB dialect to switch among these lists based on either explicitly configured or server-version-detected “MySQL” or “MariaDB” backend. Added all current reserved words through MySQL 8 and current MariaDB versions including recently added keywords like “lead” . Pull request courtesy Kevin Kirsche.
References: #7167 - [mysql] [bug]
Fixed issue in MySQLInsert.on_duplicate_key_update()
which would render the wrong column name when an expression were used in a VALUES expression. Pull request courtesy Cristian Sabaila.
References: #7281
mssql
- [mssql] [bug]
Adjusted the compiler’s generation of “post compile” symbols including those used for “expanding IN” as well as for the “schema translate map” to not be based directly on plain bracketed strings with underscores, as this conflicts directly with SQL Server’s quoting format of also using brackets, which produces false matches when the compiler replaces “post compile” and “schema translate” symbols. The issue created easy to reproduce examples both with theInspector.get_schema_names()
method when used in conjunction with theConnection.execution_options.schema_translate_map
feature, as well in the unlikely case that a symbol overlapping with the internal name “POSTCOMPILE” would be used with a feature like “expanding in”.
References: #7300
1.4.26
Released: October 19, 2021
orm
- [orm] [bug]
Improved the exception message generated when configuring a mapping with joined table inheritance where the two tables either have no foreign key relationships set up, or where they have multiple foreign key relationships set up. The message is now ORM specific and includes context that theMapper.inherit_condition
parameter may be needed particularly for the ambiguous foreign keys case. - [orm] [bug]
Fixed issue withwith_loader_criteria()
feature where ON criteria would not be added to a JOIN for a query of the formselect(A).join(B)
, stating a target while making use of an implicit ON clause.
References: #7189 - [orm] [bug]
Fixed bug where the ORM “plugin”, necessary for features such aswith_loader_criteria()
to work correctly, would not be applied to aselect()
which queried from an ORM column expression if it made use of theColumnElement.label()
modifier.
References: #7205 - [orm] [bug]
Add missing methods added in #6991 toscoped_session
andasync_scoped_session()
.
References: #7103 - [orm] [bug]
An extra layer of warning messages has been added to the functionality ofQuery.join()
and the ORM version ofSelect.join()
, where a few places where “automatic aliasing” continues to occur will now be called out as a pattern to avoid, mostly specific to the area of joined table inheritance where classes that share common base tables are being joined together without using explicit aliases. One case emits a legacy warning for a pattern that’s not recommended, the other case is fully deprecated.
The automatic aliasing within ORM join() which occurs for overlapping mapped tables does not work consistently with all APIs such ascontains_eager()
, and rather than continue to try to make these use cases work everywhere, replacing with a more user-explicit pattern is clearer, less prone to bugs and simplifies SQLAlchemy’s internals further.
The warnings include links to the errors.rst page where each pattern is demonstrated along with the recommended pattern to fix.
See also
An alias is being generated automatically for raw clauseelement
An alias is being generated automatically due to overlapping tables
References: #6972, #6974 - [orm] [bug]
Fixed bug where iterating aResult
from aSession
after thatSession
were closed would partially attach objects to that session in an essentially invalid state. It now raises an exception with a link to new documentation if an un-buffered result is iterated from aSession
that was closed or otherwise had theSession.expunge_all()
method called after thatResult
was generated. Theprebuffer_rows
execution option, as is used automatically by the asyncio extension for client-side result sets, may be used to produce aResult
where the ORM objects are prebuffered, and in this case iterating the result will produce a series of detached objects.
See also
Object cannot be converted to ‘persistent’ state, as this identity map is no longer valid.
References: #7128 - [orm] [bug]
Related to #7153, fixed an issue where result column lookups would fail for “adapted” SELECT statements that selected for “constant” value expressions most typically the NULL expression, as would occur in such places as joined eager loading in conjunction with limit/offset. This was overall a regression due to issue #6259 which removed all “adaption” for constants like NULL, “true”, and “false” when rewriting expressions in a SQL statement, but this broke the case where the same adaption logic were used to resolve the constant to a labeled expression for the purposes of result set targeting.
References: #7154 - [orm] [bug] [regression]
Fixed regression where ORM loaded objects could not be pickled in cases where loader options making use of"*"
were used in certain combinations, such as combining thejoinedload()
loader strategy withraiseload('*')
of sub-elements.
References: #7134 - [orm] [bug] [regression]
Fixed regression where the use of ahybrid_property
attribute or a mappedcomposite()
attribute as a key passed to theUpdate.values()
method for an ORM-enabledUpdate
statement, as well as when using it via the legacyQuery.update()
method, would be processed for incoming ORM/hybrid/composite values within the compilation stage of the UPDATE statement, which meant that in those cases where caching occurred, subsequent invocations of the same statement would no longer receive the correct values. This would include not only hybrids that use thehybrid_property.update_expression()
method, but any use of a plain hybrid attribute as well. For composites, the issue instead caused a non-repeatable cache key to be generated, which would break caching and could fill up the statement cache with repeated statements.
TheUpdate
construct now handles the processing of key/value pairs passed toUpdate.values()
andUpdate.ordered_values()
up front when the construct is first generated, before the cache key has been generated so that the key/value pairs are processed each time, and so that the cache key is generated against the individual column/value pairs that will ultimately be used in the statement.
References: #7209 - [orm]
Passing aQuery
object toSession.execute()
is not the intended use of this object, and will now raise a deprecation warning.
References: #6284
examples
- [examples] [bug]
Repaired the examples in examples/versioned_rows to use SQLAlchemy 1.4 APIs correctly; these examples had been missed when API changes like removing “passive” fromSession.is_modified()
were made as well as theSessionEvents.do_orm_execute()
event hook were added.
References: #7169
engine
- [engine] [bug]
Fixed issue where the deprecation warning for theURL
constructor which indicates that theURL.create()
method should be used would not emit if a full positional argument list of seven arguments were passed; additionally, validation of URL arguments will now occur if the constructor is called in this way, which was being skipped previously.
References: #7130 - [engine] [bug] [postgresql]
TheInspector.reflect_table()
method now supports reflecting tables that do not have user defined columns. This allowsMetaData.reflect()
to properly complete reflection on databases that contain such tables. Currently, only PostgreSQL is known to support such a construct among the common database backends.
References: #3247 - [engine] [bug]
Implemented proper__reduce__()
methods for all SQLAlchemy exception objects to ensure they all support clean round trips when pickling, as exception objects are often serialized for the purposes of various debugging tools.
References: #7077
sql
- [sql] [bug]
Fixed issue where SQL queries using theFunctionElement.within_group()
construct could not be pickled, typically when using thesqlalchemy.ext.serializer
extension but also for general generic pickling.
References: #6520 - [sql] [bug]
Repaired issue in newHasCTE.cte.nesting
parameter introduced with #4123 where a recursiveCTE
usingHasCTE.cte.recursive
in typical conjunction with UNION would not compile correctly. Additionally makes some adjustments so that theCTE
construct creates a correct cache key. Pull request courtesy Eric Masseran.
References: #4123 - [sql] [bug]
Account for thetable.schema
parameter passed to thetable()
construct, such that it is taken into account when accessing theTableClause.fullname
attribute.
References: #7061 - [sql] [bug]
Fixed an inconsistency in theColumnOperators.any_()
/ColumnOperators.all_()
functions / methods where the special behavior these functions have of “flipping” the expression such that the “ANY” / “ALL” expression is always on the right side would not function if the comparison were against the None value, that is, “column.any_() == None” should produce the same SQL expression as “null() == column.any_()”. Added more docs to clarify this as well, plus mentions that any_() / all_() generally supersede the ARRAY version “any()” / “all()”.
References: #7140 - [sql] [bug] [regression]
Fixed issue where “expanding IN” would fail to function correctly with datatypes that use theTypeEngine.bind_expression()
method, where the method would need to be applied to each element of the IN expression rather than the overall IN expression itself.
References: #7177 - [sql] [bug]
Adjusted the “column disambiguation” logic that’s new in 1.4, where the same expression repeated gets an “extra anonymous” label, so that the logic more aggressively deduplicates those labels when the repeated element is the same Python expression object each time, as occurs in cases like when using “singleton” values likenull()
. This is based on the observation that at least some databases (e.g. MySQL, but not SQLite) will raise an error if the same label is repeated inside of a subquery.
References: #7153
mypy
- [mypy] [bug]
Fixed issue in mypy plugin to improve upon some issues detectingEnum()
SQL types containing custom Python enumeration classes. Pull request courtesy Hiroshi Ogawa.
References: #6435
postgresql
- [postgresql] [bug]
Added a “disconnect” condition for the “SSL SYSCALL error: Bad address” error message as reported by psycopg2. Pull request courtesy Zeke Brechtel.
References: #5387 - [postgresql] [bug] [regression]
Fixed issue where IN expressions against a series of array elements, as can be done with PostgreSQL, would fail to function correctly due to multiple issues within the “expanding IN” feature of SQLAlchemy Core that was standardized in version 1.4. The psycopg2 dialect now makes use of theTypeEngine.bind_expression()
method withARRAY
to portably apply the correct casts to elements. The asyncpg dialect was not affected by this issue as it applies bind-level casts at the driver level rather than at the compiler level.
References: #7177
mysql
- [mysql] [bug] [mariadb]
Fixes to accommodate for the MariaDB 10.6 series, including backwards incompatible changes in both the mariadb-connector Python driver (supported on SQLAlchemy 1.4 only) as well as the native 10.6 client libraries that are used automatically by the mysqlclient DBAPI (applies to both 1.3 and 1.4). The “utf8mb3” encoding symbol is now reported by these client libraries when the encoding is stated as “utf8”, leading to lookup and encoding errors within the MySQL dialect that does not expect this symbol. Updates to both the MySQL base library to accommodate for this utf8mb3 symbol being reported as well as to the test suite. Thanks to Georg Richter for support.
This change is also backported to: 1.3.25
References: #7115, #7136 - [mysql] [bug]
Fixed issue in MySQLmatch()
construct where passing a clause expression such asbindparam()
or other SQL expression for the “against” parameter would fail. Pull request courtesy Anton Kovalevich.
References: #7144 - [mysql] [bug]
Fixed installation issue where thesqlalchemy.dialects.mysql
module would not be importable if “greenlet” were not installed.
References: #7204
mssql
- [mssql] [usecase]
Added reflection support for SQL Server foreign key options, including “ON UPDATE” and “ON DELETE” values of “CASCADE” and “SET NULL”. - [mssql] [bug]
Fixed issue withInspector.get_foreign_keys()
where foreign keys were omitted if they were established against a unique index instead of a unique constraint.
References: #7160 - [mssql] [bug]
Fixed issue withInspector.has_table()
where it would return False if a local temp table with the same name from a different session happened to be returned first when querying tempdb. This is a continuation of #6910 which accounted for the temp table existing only in the alternate session and not the current one.
References: #7168 - [mssql] [bug] [regression]
Fixed bug in SQL ServerDATETIMEOFFSET
datatype where the ODBC implementation would not generate the correct DDL, for cases where the type were converted using thedialect.type_descriptor()
method, the usage of which is illustrated in some documented examples forTypeDecorator
, though not necessary for most datatypes. Regression was introduced by #6366. As part of this change, the full list of SQL Server date types have been amended to return a “dialect impl” that generates the same DDL name as the supertype.
References: #7129
1.4.25
Released: September 22, 2021
platform
- [platform] [bug] [regression]
Fixed regression due to #7024 where the reorganization of the “platform machine” names used by thegreenlet
dependency mis-spelled “aarch64” and additionally omitted uppercase “AMD64” as is needed for Windows machines. Pull request courtesy James Dow.
References: #7024
SqlAlchemy 2.0 中文文档(五十九)(4)https://developer.aliyun.com/article/1563150