版本:1.1.0b2 |发布日期:2016年7月1日

SQLAlchemy 1.1文档


0.9.11 ¶ T0>


发动机¶ T0>

  • [engine] [bug] Fixed critical issue whereby the pool “checkout” event handler may be called against a stale connection without the “connect” event handler having been called, in the case where the pool attempted to reconnect after being invalidated and failed; the stale connection would remain present and would be used on a subsequent attempt. 这个问题在1.0.2之后的1.0系列中有更大的影响,因为它也向事件处理程序提供了一个空白的.info字典。在1.0.2之前,.info字典仍然是前一个。


预言¶ T0>

  • [oracle] [bug] [py3k] Fixed support for cx_Oracle version 5.2, which was tripping up SQLAlchemy’s version detection under Python 3 and inadvertently not using the correct unicode mode for Python 3. 这会导致绑定变量被错误地解释为NULL和行不会被返回的问题。


0.9.10 ¶ T0>


ORM ¶ T0>

  • [orm] [feature] 向由Query.column_descriptions返回的字典添加了一个新的条目"entity"这是指由表达式引用的主要ORM映射类或别名类。"type"的现有条目相比,即使从列表达式提取,它也将始终是映射实体,如果给定表达式是纯粹核心表达式,则它将始终为None。另见#3403,它修复了0.9.10版本中未发布但在1.0版本中发布的回归。


  • [orm] [bug] Query doesn’t support joins, subselects, or special FROM clauses when using the Query.update() or Query.delete() methods; instead of silently ignoring these fields if methods like Query.join() or Query.select_from() has been called, a warning is emitted. 从1.0.0b5开始,这会引发错误。


  • [orm] [bug] Fixed bug where the state tracking within multiple, nested Session.begin_nested() operations would fail to propagate the “dirty” flag for an object that had been updated within the inner savepoint, such that if the enclosing savepoint were rolled back, the object would not be part of the state that was expired and therefore reverted to its database state.


发动机¶ T0>

  • [engine] [bug] Added the string value "none" to those accepted by the Pool.reset_on_return parameter as a synonym for None, so that string values can be used for all settings, allowing utilities like engine_from_config() to be usable without issue.


SQL ¶ T0>

  • [sql] [feature] 增加了对Insert.from_select()中SELECT存在的CTE的官方支持。这个行为意外地工作到0.9.9,当它不再作为#3248的一部分而不相关的改变时。请注意,这是在SELECT之前的INSERT之后的WITH子句的呈现;在INSERT,UPDATE,DELETE顶层呈现的CTE的全部功能是针对以后版本的新功能。


  • [sql] [bug] Fixed issue where a MetaData object that used a naming convention would not properly work with pickle. 如果使用不带钩的MetaData对象来构建附加表格,则该属性被跳过导致不一致和失败。


的PostgreSQL ¶ T0>

  • [postgresql] [bug] Fixed a long-standing bug where the Enum type as used with the psycopg2 dialect in conjunction with non-ascii values and native_enum=False would fail to decode return results properly. 这源于PG postgresql.ENUM类型曾经是一个没有“非本地”选项的独立类型。


MySQL的¶ T0>

  • [mysql] [bug] [pymysql] Fixed unicode support for PyMySQL when using an “executemany” operation with unicode parameters. SQLAlchemy现在将语句以及绑定参数作为unicode对象传递,因为PyMySQL通常在内部使用字符串插值来生成最终语句,而在executemany的情况下,仅在最后语句中执行“编码”步骤。¶ T0>


  • [mysql] [bug] [py3k] Fixed the mysql.BIT type on Py3K which was not using the ord() function correctly. 请求提供David Marin。

    References: #3333, pull request github:158

源码¶ T0>

  • [sqlite] [bug] Fixed bug in SQLite dialect where reflection of UNIQUE constraints that included non-alphabetic characters in the names, like dots or spaces, would not be reflected with their name.


杂项¶ T0>

  • [bug] [ext] Fixed bug where when using extended attribute instrumentation system, the correct exception would not be raised when class_mapper() were called with an invalid input that also happened to not be weak referencable, such as an integer.


  • [bug] [tests] [pypy] 修正了阻止“pypy setup.py test”正常工作的导入。


  • [bug] [ext] 从0.9.9版中修复了as_declarative()符号从sqlalchemy.ext.declarative命名空间中的回归。 ¶ T7>


0.9.9 ¶ T0>


ORM ¶ T0>

  • [orm] [feature] 增加了一个新的参数Session.connection.execution_options,它可以用来在Connection上设置执行选项在交易开始之前先检查出来。这用于在事务启动之前设置连接上的隔离级别等选项。


    Setting Transaction Isolation Levels - 新的文档部分详细介绍了使用会话设置事务隔离的最佳实践。


  • [orm] [feature] Added new method Session.invalidate(), functions similarly to Session.close(), except also calls Connection.invalidate() on all connections, guaranteeing that they will not be returned to the connection pool. 这在例如情况下是有用的在进一步使用连接不安全的情况下处理gevent超时,即使是回滚。

  • [orm] [bug] Fixed bugs in ORM object comparisons where comparison of many-to-one != None would fail if the source were an aliased class, or if the query needed to apply special aliasing to the expression due to aliased joins or polymorphic querying; also fixed bug in the case where comparing a many-to-one to an object state would fail if the query needed to apply special aliasing due to aliased joins or polymorphic querying.


  • [orm] [bug] Fixed bug where internal assertion would fail in the case where an after_rollback() handler for a Session incorrectly adds state to that Session within the handler, and the task to warn and remove this state (established by #2389) attempts to proceed.


  • [orm] [bug] Fixed bug where TypeError raised when Query.join() called with unknown kw arguments would raise its own TypeError due to broken formatting. 请求Malthe Borch提出请求。


  • [orm] [bug] Fixed bug in lazy loading SQL construction whereby a complex primaryjoin that referred to the same “local” column multiple times in the “column that points to itself” style of self-referential join would not be substituted in all cases. 这里确定替代的逻辑已被重新设计为更加开放。


  • [orm] [bug] The “wildcard” loader options, in particular the one set up by the orm.load_only() option to cover all attributes not explicitly mentioned, now takes into account the superclasses of a given entity, if that entity is mapped with inheritance mapping, so that attribute names within the superclasses are also omitted from the load. 此外,多态鉴别器列无条件地包含在列表中,就像主键列一样,所以即使设置了load_only(),子类型的多态加载也能正常工作。 t0 >


  • [orm] [bug] [pypy] Fixed bug where if an exception were thrown at the start of a Query before it fetched results, particularly when row processors can’t be formed, the cursor would stay open with results pending and not actually be closed. 对于像Pypy这样的解释器来说,这通常只是一个问题,在这种解释器中,游标并没有立即被GC化,而且在某些情况下会导致事务/锁的打开时间比所需的时间长。


  • [orm] [bug] Fixed a leak which would occur in the unsupported and highly non-recommended use case of replacing a relationship on a fixed mapped class many times, referring to an arbitrarily growing number of target mappers. 旧的关系被替换时会发出警告,但是如果映射已经用于查询,旧的关系仍然会在某些注册表中引用。


  • [orm] [bug] [sqlite] Fixed bug regarding expression mutations which could express itself as a “Could not locate column” error when using Query to select from multiple, anonymous column entities when querying against SQLite, as a side effect of the “join rewriting” feature used by the SQLite dialect.


  • [orm] [bug] Fixed bug where the ON clause for Query.join(), and Query.outerjoin() to a single-inheritance subclass using of_type() would not render the “single table criteria” in the ON clause if the from_joinpoint=True flag were set.


发动机¶ T0>

SQL ¶ T0>

  • [sql] [bug] Added the native_enum flag to the __repr__() output of Enum, which is mostly important when using it with Alembic autogenerate. 拉请求礼貌Dimitris Theodorou。


  • [sql] [bug] Fixed bug where using a TypeDecorator that implemented a type that was also a TypeDecorator would fail with Python’s “Cannot create a consistent method resolution order (MRO)” error, when any kind of SQL comparison expression were used against an object using this type.


  • [sql] [bug] Fixed issue where the columns from a SELECT embedded in an INSERT, either through the values clause or as a “from select”, would pollute the column types used in the result set produced by the RETURNING clause when columns from both statements shared the same name, leading to potential errors or mis-adaptation when retrieving the returning rows.


架构¶ T0>

  • [schema] [bug] Fixed bug in 0.9’s foreign key setup system, such that the logic used to link a ForeignKey to its parent could fail when the foreign key used “link_to_name=True” in conjunction with a target Table that would not receive its parent column until later, such as within a reflection + “useexisting” scenario, if the target column in fact had a key value different from its name, as would occur in reflection if column reflect events were used to alter the .key of reflected Column objects so that the link_to_name becomes significant. 还通过类似的方式修复了通过FK传输对列类型的支持,当目标列有不同的键并且使用link_to_name引用时


的PostgreSQL ¶ T0>

  • [postgresql] [feature] 增加了对CONCURRENTLY关键字与Postgresql索引的支持,使用postgresql_concurrently建立。请求Iuri de Silvio提出请求。


    Indexes with CONCURRENTLY的索引


  • [postgresql] [bug] 使用psycopg2修复了对Postgresql UUID类型与ARRAY类型的支持。psycopg2方言现在使用了psycopg2.extras.register_uuid()钩子,以便始终将UUID值作为UUID()对象传递给DBAPI。UUID.as_uuid标志仍然有效,除了psycopg2,我们需要将返回的UUID对象转换回字符串。


  • [postgresql] [bug] Added support for the postgresql.JSONB datatype when using psycopg2 2.5.4 or greater, which features native conversion of JSONB data so that SQLAlchemy’s converters must be disabled; additionally, the newly added psycopg2 extension extras.register_default_jsonb is used to establish a JSON deserializer passed to the dialect via the json_deserializer argument. 还修复了Postgresql集成测试,实际上并没有将JSONB类型与JSON类型相比翻转。拉请求Mateusz Susik。


  • [postgresql] [bug] Repaired the use of the “array_oid” flag when registering the HSTORE type with older psycopg2 versions < 2.4.3, which does not support this flag, as well as use of the native json serializer hook “register_default_json” with user-defined json_deserializer on psycopg2 versions < 2.5, which does not include native json.

  • [postgresql] [bug] Fixed bug where Postgresql dialect would fail to render an expression in an Index that did not correspond directly to a table-bound column; typically when a text() construct was one of the expressions within the index; or could misinterpret the list of expressions if one or more of them were such an expression.


MySQL的¶ T0>

  • [mysql] [bug] Added a version check to the MySQLdb dialect surrounding the check for ‘utf8_bin’ collation, as this fails on MySQL server < 5.0.


  • [mysql] [change] The gaerdbms dialect is no longer necessary, and emits a deprecation warning. Google现在建议直接使用MySQLdb方言。


源码¶ T0>

  • [sqlite] [feature] 新增了对SQLite的部分索引(例如使用WHERE子句)的支持。请求Kai Groner提出的请求。


    Partial Indexes


  • [sqlite] [feature] 为SQLCipher后端添加了一个新的SQLite后端。这个后端提供使用pysqlcipher Python驱动程序的加密SQLite数据库,这与pysqlite驱动程序非常相似。



杂项¶ T0>

  • [bug] [ext] [py3k] Fixed bug where the association proxy list class would not interpret slices correctly under Py3K. 请求Gilles Dartiguelongue提供。


  • [bug] [examples] 更新了Versioning with a History Table的版本控制,以便将映射列重新映射为匹配列名称以及列组;特别是,这允许在历史映射中以相同方式映射显式分组在相同列名称的已连接继承场景中的列,避免在0.9系列中添加关于该模式的警告,并允许相同的属性键¶ T4>

  • [bug] [examples] Fixed a bug in the examples/generic_assocaitions/discriminator_on_association.py example, where the subclasses of AddressAssociation were not being mapped as “single table inheritance”, leading to problems when trying to use the mappings further.

0.9.8 ¶ T0>


ORM ¶ T0>

  • [orm] [bug] [engine] Fixed bug that affected generally the same classes of event as that of #3199, when the named=True parameter would be used. 一些事件将无法注册,而另一些则不能正确地调用事件参数,一般是在事件被“包装”以便以其他方式进行适应的情况下。“命名”机制已经重新排列,不会干扰内部包装函数所期望的参数签名。


  • [orm] [bug] Fixed bug that affected many classes of event, particularly ORM events but also engine events, where the usual logic of “de duplicating” a redundant call to event.listen() with the same arguments would fail, for those events where the listener function is wrapped. 一个断言将在registry.py中发生。现在这个说法已经被纳入重复数据删除检查中,并且还有一个简单的检查重复数据删除方法的好处。


  • [orm] [bug] Fixed warning that would emit when a complex self-referential primaryjoin contained functions, while at the same time remote_side was specified; the warning would suggest setting “remote side”. 现在只有在remote_side不存在时才会发出。


orm declarative

  • [bug] [declarative] [orm] Fixed “‘NoneType’ object has no attribute ‘concrete’” error when using AbstractConcreteBase in conjunction with a subclass that declares __abstract__.


发动机¶ T0>

  • [engine] [bug] The execution options passed to an Engine either via create_engine.execution_options or Engine.update_execution_options() are not passed to the special Connection used to initialize the dialect within the “first connect” event; dialects will usually perform their own queries in this phase, and none of the current available options should be applied here. 特别是,“autocommit”选项会导致尝试在这个初始连接中自动提交,由于Connection的非标准状态,会导致AttributeError失败。


  • [engine] [bug] 用于确定受INSERT或UPDATE影响的列的字符串键现在在对“编译缓存”缓存键作出贡献时被排序。这些键以前不是确定性排序的,这意味着相同的语句可以在相同的键上多次缓存,从内存和性能两个方面来说都是这样。


SQL ¶ T0>

  • [sql] [bug] Fixed bug where a fair number of SQL elements within the sql package would fail to __repr__() successfully, due to a missing description attribute that would then invoke a recursion overflow when an internal AttributeError would then re-invoke __repr__().


  • [sql] [bug] An adjustment to table/index reflection such that if an index reports a column that isn’t found to be present in the table, a warning is emitted and the column is skipped. 这可能会发生在一些特殊的系统列情况下,就像在Oracle中观察到的那样。


  • [sql] [bug] Fixed bug in CTE where literal_binds compiler argument would not be always be correctly propagated when one CTE referred to another aliased CTE in a statement.


  • [sql] [bug] Fixed 0.9.7 regression caused by #3067 in conjunction with a mis-named unit test such that so-called “schema” types like Boolean and Enum could no longer be pickled.


的PostgreSQL ¶ T0>

  • [postgresql] [feature] [pg8000] 使用pg8000驱动程序添加了“理智的多行计数”支持,主要适用于使用ORM进行版本控制的情况。该功能基于使用的pg8000 1.9.14或更高版本进行版本检测。请求托尼·洛克(Tony Locke)提出请求。


  • [postgresql] [bug] A revisit to this issue first patched in 0.9.5, apparently psycopg2’s .closed accessor is not as reliable as we assumed, so we have added an explicit check for the exception messages “SSL SYSCALL error: Bad file descriptor” and “SSL SYSCALL error: EOF detected” when detecting an is-disconnect scenario. 我们将继续咨询psycopg2的connection.closed作为第一个检查。


  • [postgresql] [bug] Fixed bug where Postgresql JSON type was not able to persist or otherwise render a SQL NULL column value, rather than a JSON-encoded 'null'. 为了支持这种情况,更改如下:

    • 现在可以指定null()值,这将始终导致产生该语句的NULL值。
    • 添加了一个新的参数JSON.none_as_null,当True表示Python None值应该作为SQL NULL执行,而不是JSON编码'null'



  • [postgresql] [bug] DBAPI错误的异常包装系统现在可以容纳非标准的DBAPI异常,例如psycopg2 TransactionRollbackError。这些异常现在将使用sqlalchemy.exc中最接近的可用子类进行引发,如果是TransactionRollbackError,sqlalchemy.exc.OperationalError


  • [postgresql] [bug] Fixed bug in postgresql.array object where comparison to a plain Python list would fail to use the correct array constructor. 拉请求礼貌Andrew。


  • [postgresql] [bug] 为函数添加了一个支持的FunctionElement.alias()方法。 func构造。以前,这个方法的行为是未定义的。当前的行为模仿0.9.4之前的行为,也就是说,该函数被转换为具有给定别名的单列FROM子句,其中列本身是匿名命名的。


MySQL的¶ T0>

  • [mysql] [bug] [mysqlconnector] Mysqlconnector as of version 2.0, probably as a side effect of the python 3 merge, now does not expect percent signs (e.g. as used as the modulus operator and others) to be doubled, even when using the “pyformat” bound parameter format (this change is not documented by Mysqlconnector). 当检测模运算符是否应该呈现为%%%时,方言现在检查py2k和小于版本2.0的mysql连接器。

  • [mysql] [bug] [mysqlconnector] Unicode SQL is now passed for MySQLconnector version 2.0 and above; for Py2k and MySQL < 2.0, strings are encoded.

源码¶ T0>

  • [sqlite] [bug] When selecting from a UNION using an attached database file, the pysqlite driver reports column names in cursor.description as ‘dbname.tablename.colname’, instead of ‘tablename.colname’ as it normally does for a UNION (note that it’s supposed to just be ‘colname’ for both, but we work around it). 这里的列转换逻辑已被调整来检索最右边的标记,而不是第二个标记,所以它在两种情况下都起作用。解决方法:Tony Roberts。



  • [mssql] [bug] 修复了pymssql方言中的版本字符串检测问题,与Microsoft SQL Azure一起使用,它将“SQL Server”一词改为“SQL Azure”。¶ t2 >


预言¶ T0>

  • [oracle] [bug] Fixed long-standing bug in Oracle dialect where bound parameter names that started with numbers would not be quoted, as Oracle doesn’t like numerics in bound parameter names.


杂项¶ T0>

  • [bug] [declarative] Fixed an unlikely race condition observed in some exotic end-user setups, where the attempt to check for “duplicate class name” in declarative would hit upon a not-totally-cleaned-up weak reference related to some other class being removed; the check here now ensures the weakref still references an object before calling upon it further.


  • [bug] [ext] Fixed bug in ordering list where the order of items would be thrown off during a collection replace event, if the reorder_on_append flag were set to True. 该修复确保排序列表仅影响与该对象显式关联的列表。


  • [bug] [ext] Fixed bug where ext.mutable.MutableDict failed to implement the update() dictionary method, thus not catching changes. 拉请求马特Chisholm。

  • [bug] [ext] Fixed bug where a custom subclass of ext.mutable.MutableDict would not show up in a “coerce” operation, and would instead return a plain ext.mutable.MutableDict. 拉请求马特Chisholm。

  • [bug] [pool] Fixed bug in connection pool logging where the “connection checked out” debug logging message would not emit if the logging were set up using logging.setLevel(), rather than using the echo_pool flag. 已经添加了测试来声明这个日志记录。这是在0.9.0中引入的回归。


0.9.7 ¶ T0>


ORM ¶ T0>

  • [orm] [bug] [eagerloading] Fixed a regression caused by #2976 released in 0.9.4 where the “outer join” propagation along a chain of joined eager loads would incorrectly convert an “inner join” along a sibling join path into an outer join as well, when only descendant paths should be receiving the “outer join” propagation; additionally, fixed related issue where “nested” join propagation would take place inappropriately between two sibling join paths.


  • [orm] [bug] Fixed a regression from 0.9.0 due to #2736 where the Query.select_from() method no longer set up the “from entity” of the Query object correctly, so that subsequent Query.filter_by() or Query.join() calls would fail to check the appropriate “from” entity when searching for attributes by string name.


  • [orm] [bug] The “evaluator” for query.update()/delete() won’t work with multi-table updates, and needs to be set to synchronize_session=False or synchronize_session=’fetch’; a warning is now emitted. 在1.0中,这将被提升为一个完整的异常。


  • [orm] [bug] Fixed bug where items that were persisted, deleted, or had a primary key change within a savepoint block would not participate in being restored to their former state (not in session, in session, previous PK) after the outer transaction were rolled back.


  • [orm] [bug] Fixed bug in subquery eager loading in conjunction with with_polymorphic(), the targeting of entities and columns in the subquery load has been made more accurate with respect to this type of entity and others.


  • [orm] [bug] Fixed bug involving dynamic attributes, that was again a regression of #3060 from version 0.9.5. lazy ='dynamic'的自引用关系会在flush操作中引发TypeError。


发动机¶ T0>

SQL ¶ T0>

  • [sql] [bug] Fixed bug in Enum and other SchemaType subclasses where direct association of the type with a MetaData would lead to a hang when events (like create events) were emitted on the MetaData.



  • [sql] [bug] Fixed a bug within the custom operator plus TypeEngine.with_variant() system, whereby using a TypeDecorator in conjunction with variant would fail with an MRO error when a comparison operator was used.



  • [sql] [bug] Fix bug in naming convention feature where using a check constraint convention that includes constraint_name would then force all Boolean and Enum types to require names as well, as these implicitly create a constraint, even if the ultimate target backend were one that does not require generation of the constraint such as Postgresql. 这些特定约束的命名约定的机制已被重新组织,以便在DDL编译时完成命名确定,而不是在约束/表构造时完成。


  • [sql] [bug] Fixed bug in common table expressions whereby positional bound parameters could be expressed in the wrong final order when CTEs were nested in certain ways.


  • 修正了多值Insert构造的错误,将无法检查给定的字面SQL表达式的第一个以后的值。[sql] [bug]


  • [sql] [bug] Added a “str()” step to the dialect_kwargs iteration for Python version < 2.6.5, working around the “no unicode keyword arg” bug as these args are passed along as keyword args within some reflection processes.


  • [sql] [bug] The TypeEngine.with_variant() method will now accept a type class as an argument which is internally converted to an instance, using the same convention long established by other constructs such as Column.


的PostgreSQL ¶ T0>

  • [postgresql] [feature] Added kw argument postgresql_regconfig to the ColumnOperators.match() operator, allows the “reg config” argument to be specified to the to_tsquery() function emitted. 请求Jonathan Vanasco提供。


  • [postgresql] [feature] 通过JSONB增加了对Postgresql JSONB的支持。请求Damian Dimmich请求。


  • [postgresql] [bug] [pg8000] 修正了0.9.5版本中新的pg8000隔离级别功能导致的错误,其中引擎级别的隔离级别参数会在连接时产生错误¶ t2 >


MySQL的¶ T0>

  • [mysql] [bug] MySQL error 2014 “commands out of sync” appears to be raised as a ProgrammingError, not OperationalError, in modern MySQL-Python versions; all MySQL error codes that are tested for “is disconnect” are now checked within OperationalError and ProgrammingError regardless.



源码¶ T0>

  • [sqlite] [bug] Fixed a SQLite join rewriting issue where a subquery that is embedded as a scalar subquery such as within an IN would receive inappropriate substitutions from the enclosing query, if the same table were present inside the subquery as were in the enclosing query such as in a joined inheritance scenario.



  • [mssql] [feature] Enabled “multivalues insert” for SQL Server 2008. 拉尔请求礼貌伟业Cervin。同样扩展了对“IDENTITY INSERT”模式的检查,以便在语句的VALUE子句中存在身份密钥时包含


  • [mssql] [bug] Added statement encoding to the “SET IDENTITY_INSERT” statements which operate when an explicit INSERT is being interjected into an IDENTITY column, to support non-ascii table identifiers on drivers such as pyodbc + unix + py2k that don’t support unicode statements.


  • [mssql] [bug] In the SQL Server pyodbc dialect, repaired the implementation for the description_encoding dialect parameter, which when not explicitly set was preventing cursor.description from being parsed correctly in the case of result sets that contained names in alternate encodings. 这个参数不需要继续。



  • [mssql] [bug] Fixed a regression from 0.9.5 caused by #3025 where the query used to determine “default schema” is invalid in SQL Server 2000. 对于SQL Server 2000,我们回到缺省方言的“模式名称”参数,该参数是可配置的,但是默认为'dbo'。


预言¶ T0>

  • [oracle] [bug] [tests] Fixed bug in oracle dialect test suite where in one test, ‘username’ was assumed to be in the database URL, even though this might not be the case.


杂项¶ T0>

  • [bug] [tests] Fixed bug where “python setup.py test” wasn’t calling into distutils appropriately, and errors would be emitted at the end of the test suite.

  • [bug] [declarative] Fixed bug when the declarative __abstract__ flag was not being distinguished for when it was actually the value False. __abstract__标志需要在正在测试的级别上进行真实值计算。


0.9.6 ¶ T0>


ORM ¶ T0>

  • [orm] [bug] Reverted the change for #3060 - this is a unit of work fix that is updated more comprehensively in 1.0 via #3061. 不幸的是,#3060中的修复产生了一个新问题,即多对一属性的急切加载可能会产生一个解释为属性更改的事件。


0.9.5 ¶ T0>


ORM ¶ T0>

  • [orm] [feature] The “primaryjoin” model has been stretched a bit further to allow a join condition that is strictly from a single column to itself, translated through some kind of SQL function or expression. 这是一种实验,但概念的第一个证明是“物化路径”连接条件,其中路径字符串与“like”相比较。The ColumnOperators.like() operator has also been added to the list of valid operators to use in a primaryjoin condition.


  • [orm] [feature] Added new utility function make_transient_to_detached() which can be used to manufacture objects that behave as though they were loaded from a session, then detached. 不存在的属性被标记为过期的,并且该对象可以被添加到Session中,在那里它将像一个永久的一样。


  • [orm] [bug] Fixed bug in subquery eager loading where a long chain of eager loads across a polymorphic-subclass boundary in conjunction with polymorphic loading would fail to locate the subclass-link in the chain, erroring out with a missing property name on an AliasedClass.



  • [orm] [bug] Fixed ORM bug where the class_mapper() function would mask AttributeErrors or KeyErrors that should raise during mapper configuration due to user errors. 属性/键错误的捕获已被更具体化,不包括配置步骤。



  • [orm] [bug] Additional checks have been added for the case where an inheriting mapper is implicitly combining one of its column-based attributes with that of the parent, where those columns normally don’t necessarily share the same value. 这是通过#1892添加的现有支票的扩展。然而,这个新的检查只发出一个警告,而不是一个例外,以允许可能依赖现有行为的应用程序。


  • [orm] [bug] Modified the behavior of orm.load_only() such that primary key columns are always added to the list of columns to be “undeferred”; otherwise, the ORM can’t load the row’s identity. 显然,可以推迟映射的主键,并且ORM将会失败,这是没有改变的。But as load_only is essentially saying “defer all but X”, it’s more critical that PK cols not be part of this deferral.


  • [orm] [bug] Fixed a few edge cases which arise in the so-called “row switch” scenario, where an INSERT/DELETE can be turned into an UPDATE. 在这种情况下,多对一关系设置为无,或者在某些情况下标量属性设置为无可能不会被检测为净更改值,因此UPDATE不会重置上一行。这是由于一些尚未解决的方式属性历史的工作方式隐含地假设None不是真正的“改变”以前未设置的属性。另见#3061


    This change has been REVERTED in 0.9.6. 完整的修补程序将在SQLAlchemy 1.0版中。


  • [orm] [bug] Related to #3060, an adjustment has been made to the unit of work such that loading for related many-to-one objects is slightly more aggressive, in the case of a graph of self-referential objects that are to be deleted; the load of related objects is to help determine the correct order for deletion if passive_deletes is not set.

  • [orm] [bug] Fixed bug in SQLite join rewriting where anonymized column names due to repeats would not correctly be rewritten in subqueries. 这会影响任何一种子查询+连接的SELECT查询。


  • [orm] [bug] [sql] Fixes to the newly enhanced boolean coercion in #2804 where the new rules for “where” and “having” woudn’t take effect for the “whereclause” and “having” kw arguments of the select() construct, which is also what Query uses so wasn’t working in the ORM either.


发动机¶ T0>

  • [engine] [bug] Fixed bug which would occur if a DBAPI exception occurs when the engine first connects and does its initial checks, and the exception is not a disconnect exception, yet the cursor raises an error when we try to close it. 在这种情况下,当我们尝试通过连接池记录游标关闭异常并且失败时,真正的异常将被废除,因为我们试图以在这种特定情况下不合适的方式访问池的记录器。 T0>


  • [engine] [bug] Fixed some “double invalidate” situations were detected where a connection invalidation could occur within an already critical section like a connection.close(); ultimately, these conditions are caused by the change in #2907, in that the “reset on return” feature calls out to the Connection/Transaction in order to handle it, where “disconnect detection” might be caught. However, it’s possible that the more recent change in #2985 made it more likely for this to be seen as the “connection invalidate” operation is much quicker, as the issue is more reproducible on 0.9.4 than 0.9.3.



SQL ¶ T0>

  • [sql] [feature] Liberalized the contract for Index a bit in that you can specify a text() expression as the target; the index no longer needs to have a table-bound column present if the index is to be manually added to the table, either via inline declaration or via Table.append_constraint().


  • 当设置为True呈现“BETWEEN SYMMETRIC”时,添加了新的标记expression.between.symmetric中的[sql] [feature] 还添加了一个新的否定运算符“notbetween_op”,该运算符现在允许像〜col.between(x, y) col NOT BETWEEN x AND y“,而不是一个括号中的NOT字符串。


  • [sql] [bug] Fixed bug in INSERT..FROM SELECT construct where selecting from a UNION would wrap the union in an anonymous (e.g. unlabled) subquery.



  • [sql] [bug] Fixed bug where Table.update() and Table.delete() would produce an empty WHERE clause when an empty and_() or or_() or other blank expression were applied. 这与select()的一致。



  • [sql] [bug] The Column.nullable flag is implicitly set to False when that Column is referred to in an explicit PrimaryKeyConstraint for that table. 现在,这种行为与Column本身将Column.primary_key标志设置为True时的行为相匹配,该行为旨在成为一个完全等效的情况¶ T8>


  • [sql] [bug] Fixed bug where the Operators.__and__(), Operators.__or__() and Operators.__invert__() operator overload methods could not be overridden within a custom TypeEngine.Comparator implementation.


  • [sql] [bug] Fixed bug in new DialectKWArgs.argument_for() method where adding an argument for a construct not previously included for any special arguments would fail.


  • [sql] [bug] Fixed regression introduced in 0.9 where new “ORDER BY ” feature from #1068 would not apply quoting rules to the label name as rendered in the ORDER BY.


  • [sql] [bug] Function的导入恢复到sqlalchemy.sql.expression import命名空间,该命名空间在0.9开始时被删除¶ T7>

的PostgreSQL ¶ T0>

  • [postgresql] [feature] 在使用pg8000 DBAPI时增加了对AUTOCOMMIT隔离级别的支持。请求托尼·洛克(Tony Locke)提出请求。


  • [postgresql] [feature] 添加了一个新的标志ARRAY.zero_indexes到Postgresql ARRAY类型。当设置为True时,在传递到数据库之前,值为1将被添加到所有数组索引值,从而允许Python样式的基于零的索引和基于PostgreSQL的基于1的索引之间的更好的互操作性。请求礼貌Alexey Terentev。

    References: #2785, pull request bitbucket:18

  • [postgresql] [bug] hashable=False标志添加到PG HSTORE类型中,ORM跳过在混合列/实体列表中请求ORM映射的HSTORE列时“散列”。补丁礼貌GunnlaugurÞórBriem。



  • [postgresql] [bug] 添加了一个新的“断开”消息“连接已经意外关闭”。这似乎与更新版本的SSL有关。请求Antti Haapala提供。



  • [postgresql] [bug] The psycopg2 .closed accessor is now consulted when determining if an exception is a “disconnect” error; ideally, this should remove the need for any other inspection of the exception message to detect disconnect, however we will leave those existing messages in place as a fallback. 这应该能够处理像“SSL EOF”条件的新情况。拉德要求礼貌德克米勒。


  • [postgresql] [enhancement] 将新的类型postgresql.OID添加到Postgresql方言中。尽管“oid”通常是PG中的私有类型,但在现代版本中并未公开,但有一些PG用例,例如可能暴露这些类型的大型对象支持,以及某些用户报告的模式反射用例。 ¶ T0>


MySQL的¶ T0>

  • [mysql] [bug] Fixed bug where column names added to mysql_length parameter on an index needed to have the same quoting for quoted names in order to be recognized. 该修复使得引号是可选的,但是也提供了与使用变通方法的向后兼容的旧行为。



  • [mysql] [bug] 增加了对使用等号来反映表的索引包括KEY_BLOCK_SIZE的支持。拉请求礼貌肖恩McGivern。




  • [mssql] [bug] Revised the query used to determine the current default schema name to use the database_principal_id() function in conjunction with the sys.database_principals view so that we can determine the default schema independently of the type of login in progress (e.g., SQL Server, Windows, etc).


火鸟¶ T0>

  • [firebird] [bug] Fixed bug where the combination of “limit” rendering as “SELECT FIRST n ROWS” using a bound parameter (only firebird has both), combined with column-level subqueries which also feature “limit” as well as “positional” bound parameters (e.g. qmark style) would erroneously assign the subquery-level positions before that of the enclosing SELECT, thus returning parameters which are out of order.


杂项¶ T0>

  • [feature] [examples] 添加了一个新示例,说明使用最新关系功能的物化路径。Jack Zhou提供的例子。


  • [bug] [declarative] The __mapper_args__ dictionary is copied from a declarative mixin or abstract class when accessed, so that modifications made to this dictionary by declarative itself won’t conflict with that of other mappings. 关于version_id_colpolymorphic_on参数的字典被修改,用正式映射到本地类/表的那个字段替换其中的字段。¶ t4 >



  • [bug] [ext] Fixed bug in mutable extension where MutableDict did not report change events for the setdefault() dictionary operation.



  • [bug] [ext] Fixed bug where MutableDict.setdefault() didn’t return the existing or new value (this bug was not released in any 0.8 version). 请求托马斯·赫维(ThomasHervé)提供。


    References: #3093, #3051, pull request bitbucket:24

  • [bug] [testsuite] In public test suite, shanged to use of String(40) from less-supported Text in StringTest.test_literal_backslashes. Pullreq礼貌Jan.


  • [bug] [tests] [py3k] 在运行测试时,纠正涉及imp模块和Python 3.3或更高版本的一些弃用警告。拉请求马特Chisholm。

    References: #2830, pull request bitbucket:2830

0.9.4 ¶ T0>


一般¶ T0>

  • [general] [feature] 已经为pytest添加了支持来运行测试。目前这个跑步者除了鼻子之外还能得到支持,而且可能会更喜欢前进。SQLAlchemy使用的鼻子插件系统已经被拆分出来,所以它也可以在pytest下运行。目前还没有计划放弃对鼻子的支持,我们希望测试套件本身可以继续尽可能不受测试平台的影响。请参阅文件README.unittests.rst以获取有关使用pytest运行测试的更新信息。


  • [general] [bug] Adjusted setup.py file to support the possible future removal of the setuptools.Feature extension from setuptools. 如果这个关键字不存在,安装程序仍然可以通过setuptools成功,而不会回退到distutils。可以通过设置DISABLE_SQLALCHEMY_CEXT环境变量来禁用C扩展构建。无论setuptools是否可用,此变量都可以工作。



  • [general] [bug] Fixed some test/feature failures occurring in Python 3.4, in particular the logic used to wrap “column default” callables wouldn’t work properly for Python built-ins.


ORM ¶ T0>

  • [orm] [feature] 添加了新的参数orm.mapper.confirm_deleted_rows默认为True,表示一系列的DELETE语句应该确认游标的行数与应该匹配的主键的数量相匹配;在大多数情况下(除了使用version_id时),此行为已被取消以支持自引用ON DELETE CASCADE的异常边缘情况;为了适应这种情况,现在这个消息只是一个警告,而不是一个例外,这个标志可以用来表示一个映射,这个映射需要这种性质的自引用级联删除。另请参阅#2403以了解原始更改的背景。


  • [orm] [feature] A warning is emitted if the MapperEvents.before_configured() or MapperEvents.after_configured() events are applied to a specific mapper or mapped class, as the events are only invoked for the Mapper target at the general level.

  • [orm] [feature] Added a new keyword argument once=True to event.listen() and event.listens_for(). 这是一个方便的功能,它将包装给定的侦听器,以便只调用一次。

  • [orm] [feature] relationship.innerjoin添加了一个新选项,用于指定字符串"nested"如果设置为"nested"而不是True,则连接的“链接”将会使现有外部连接右侧的内部连接括起来,而不是链接为一串外连接。这可能应该是0.9发布时的默认行为,因为我们在ORM中引入了右嵌套连接的功能,但是现在我们将其保留为非默认值,以避免更多的意外。


  • [orm] [bug] Fixed ORM bug where changing the primary key of an object, then marking it for DELETE would fail to target the correct row for DELETE.



  • [orm] [bug] Fixed regression from 0.8.3 as a result of #2818 where Query.exists() wouldn’t work on a query that only had a Query.select_from() entry but no other entities.



  • [orm] [bug] Improved an error message which would occur if a query() were made against a non-selectable, such as a literal_column(), and then an attempt was made to use Query.join() such that the “left” side would be determined as None and then fail. 现在可以明确地检测到这种情况。


  • [orm] [bug] sqlalchemy.orm.interfaces.__all__中删除了过时的名称,并用当前名称刷新,以至于import > *从这个模块再次工作。



  • [orm] [bug] Fixed a very old behavior where the lazy load emitted for a one-to-many could inappropriately pull in the parent table, and also return results inconsistent based on what’s in the parent table, when the primaryjoin includes some kind of discriminator against the parent table, such as and_(parent.id == child.parent_id, parent.deleted == False). 虽然这个主要连接对于一对多来说没有太大的意义,但是当应用到多对一的时候,这种连接稍微普遍一些,而一对多来自后向引用。在这种情况下从child加载行将会保持parent.deleted == False就像在查询中一样,从而将其放到FROM子句中并做一个笛卡尔积。新的行为现在将替换本地“parent.deleted”的值作为适当的参数。虽然通常情况下,真实世界的应用程序可能希望在任何情况下都使用不同的主连接方法。


  • [orm] [bug] Improved the check for “how to join from A to B” such that when a table has multiple, composite foreign keys targeting a parent table, the relationship.foreign_keys argument will be properly interpreted in order to resolve the ambiguity; previously this condition would raise that there were multiple FK paths when in fact the foreign_keys argument should be establishing which one is expected.


  • [orm] [bug] Added support for the not-quite-yet-documented insert=True flag for event.listen() to work with mapper / instance events.

  • [orm] [bug] [engine] Fixed bug where events set to listen at the class level (e.g. on the Mapper or ClassManager level, as opposed to on an individual mapped class, and also on Connection) that also made use of internal argument conversion (which is most within those categories) would fail to be removable.


  • [orm] [bug] Fixed regression from 0.8 where using an option like orm.lazyload() with the “wildcard” expression, e.g. "*", would raise an assertion error in the case where the query didn’t contain any actual entities. 这个断言是针对其他案件的,是不经意间捕获这个案子的。

  • [orm] [bug] [sqlite] More fixes to SQLite “join rewriting”; the fix from #2967 implemented right before the release of 0.9.3 affected the case where a UNION contained nested joins in it. “加入重写”是一个具有广泛可能性的特性,也是我们多年来介绍的第一个错综复杂的“SQL重写”特性,所以我们对其进行了大量的迭代(不同于急切的加载在0.2 / 0.3系列中,多晶型负荷在0.4 / 0.5)。我们应该在那里很快,所以感谢承担与我们:)。


发动机¶ T0>

  • [engine] [feature] 为方言级事件添加了一些新的事件机制;初始实现允许事件处理程序重新定义任意方言调用DBAPI游标上的execute()或executemany()的特定机制。在这个半公开和实验性的新事件中,支持一些即将到来的事务相关的扩展。

  • [engine] [feature] An event listener can now be associated with a Engine, after one or more Connection objects have been created (such as by an orm Session or via explicit connect) and the listener will pick up events from those connections. 以前,性能问题只会在init时间将事件从Engine转移到Connection,但是我们已经内联了一系列条件检查,使其成为可能而没有任何附加功能呼叫。¶ T6>


  • [engine] [bug] A major improvement made to the mechanics by which the Engine recycles the connection pool when a “disconnect” condition is detected; instead of discarding the pool and explicitly closing out connections, the pool is retained and a “generational” timestamp is updated to reflect the current time, thereby causing all existing connections to be recycled when they are next checked out. 这大大简化了回收过程,消除了在唤醒等待旧池的连接尝试的需要,并消除了在回收操作过程中可能创建的许多立即丢弃的“池”对象的竞争状态。 T0>


  • [engine] [bug] The ConnectionEvents.after_cursor_execute() event is now emitted for the “_cursor_execute()” method of Connection; this is the “quick” executor that is used for things like when a sequence is executed ahead of an INSERT statement, as well as for dialect startup checks like unicode returns, charset, etc. 这里已经调用了ConnectionEvents.before_cursor_execute()事件。现在,“executemany”标志总是被设置为False,因为这个事件总是对应于一次执行。以前,如果我们代表executemany INSERT语句,标志可能是True。

SQL ¶ T0>

  • [sql] [feature] 增加了对布尔值的文字渲染的支持。 “true”/“false”或“1”/“0”。

  • [sql] [feature] 增加了一个新的特性schema.conv(),其目的是将约束名称标记为已经应用了命名约定。Alembic 0.6.4版本中的Alembic迁移将使用此标记,以便在迁移脚本中显示约束条件,标记名称已经受到命名约定。

  • [sql] [feature] The new dialect-level keyword argument system for schema-level constructs has been enhanced in order to assist with existing schemes that rely upon addition of ad-hoc keyword arguments to constructs.


    idx = Index('a', 'b')
    idx.kwargs['mysql_someargument'] = True

    To suit the use case of allowing custom arguments at construction time, the DialectKWArgs.argument_for() method now allows this registration:

    Index.argument_for('mysql', 'someargument', False)
    idx = Index('a', 'b', mysql_someargument=True)


  • [sql] [bug] Fixed bug in tuple_() construct where the “type” of essentially the first SQL expression would be applied as the “comparison type” to a compared tuple value; this has the effect in some cases of an inappropriate “type coersion” occurring, such as when a tuple that has a mix of String and Binary values improperly coerces target values to Binary even though that’s not what they are on the left side. tuple_() now expects heterogeneous types within its list of values.



  • [sql] [bug] Fixed an 0.9 regression where a Table that failed to reflect correctly wouldn’t be removed from the parent MetaData, even though in an invalid state. Pullreq礼貌Roman Podoliaka。

    References: #2988, pull request github:78

  • [sql] [bug] MetaData.naming_convention feature will now also apply to CheckConstraint objects that are associated directly with a Column instead of just on the Table.

  • [sql] [bug] Fixed bug in new MetaData.naming_convention feature where the name of a check constraint making use of the “%(constraint_name)s” token would get doubled up for the constraint generated by a boolean or enum type, and overall duplicate events would cause the “%(constraint_name)s” token to keep compounding itself.


  • [sql] [bug] Adjusted the logic which applies names to the .c collection when a no-name BindParameter is received, e.g. via sql.literal() or similar; the “key” of the bind param is used as the key within .c. 而不是呈现的名字。由于这些绑定在任何情况下都有“匿名”的名字,所以这允许个别的绑定参数在可选择的情况下有自己的名字,如果它们是未标记的话。


  • [sql] [bug] FromClause.c集合在呈现重复列时的行为有些变化。发出警告和更换同名旧栏的行为仍然存在一定程度;更换尤其是保持向后兼容性。然而,被替换的列仍然保持与集合._all_columns中的c集合相关联,该集合被诸如别名和联合的结构使用,以处理在c中的列更多地指向实际在列表中的列,而不是唯一的键名集。This helps with situations where SELECT statements with same-named columns are used in unions and such, so that the union can match the columns up positionally and also there’s some chance of FromClause.corresponding_column() still being usable here (it can now return a column that is only in selectable.c._all_columns and not otherwise named). 强调新的集合,因为我们仍然需要确定这个列表可能会在哪里结束。理论上它将成为iter(selectable.c)的结果,但是这意味着迭代的长度将不再与keys()的长度匹配,并且需要检出行为。 T0>


  • [sql] [bug] Fixed issue in new TextClause.columns() method where the ordering of columns given positionally would not be preserved. This could have potential impact in positional situations such as applying the resulting TextAsFrom object to a union.

的PostgreSQL ¶ T0>

  • [postgresql] [feature] 启用了“理智的多行计数”检查psycopg2 DBAPI,因为这似乎支持psycopg2 2.0.9.


  • [postgresql] [bug] Fixed regression caused by release 0.8.5 / 0.9.3’s compatibility enhancements where index reflection on Postgresql versions specific to only the 8.1, 8.2 series again broke, surrounding the ever problematic int2vector type. 虽然int2vector从8.1开始支持数组操作,但显然它只支持从8.3开始的一个varchar的CAST。



MySQL的¶ T0>

  • [mysql] [bug] 调整了mysql-connector-python的设置。在Py2K中,“支持unicode语句”标志现在是False,所以SQLAlchemy会在发送到数据库之前将SQL字符串(注意:不是参数)编码为字节。这似乎允许所有unicode相关的测试通过mysql连接器,包括那些使用非ascii表/列名称,以及使用unicode在cursor.executemany()下的TEXT类型的一些测试。¶ T0>

预言¶ T0>

  • [oracle] [feature] 在cx_Oracle方言中增加了一个新的引擎选项coerce_to_unicode=True,它将Python 2 unicode转换中的cx_Oracle outputtypehandler方法恢复,在0.9.2中作为#2911的结果。尽管性能方面的考虑,一些使用情况更喜欢unicode coersion对于所有字符串值是无条件的。请求礼貌Christoph Zwerschke。


  • [oracle] [bug] 添加了新的数据类型oracle.DATE,它是DateTime的子类。As Oracle has no “datetime” type per se, it instead has only DATE, it is appropriate here that the DATE type as present in the Oracle dialect be an instance of DateTime. 这个问题不会改变任何类型的行为,因为在任何情况下数据转换都由DBAPI处理,但是改进的子类布局将有助于检查跨数据库兼容性类型的用例。也从Oracle方言中删除了大写的DATETIME,因为这种类型在该上下文中不起作用。


杂项¶ T0>

  • [bug] [ext] Fixed bug in mutable extension as well as attributes.flag_modified() where the change event would not be propagated if the attribute had been reassigned to itself.



  • [bug] [automap] [ext] Added support to automap for the case where a relationship should not be created between two classes that are in a joined inheritance relationship, for those foreign keys that link the subclass back to the superclass.


  • [bug] [tests] Fixed a few errant u'' strings that would prevent tests from passing in Py3.2. 补丁礼貌Arfrever Frehtes Taifersar Arahesis。


  • [bug] [pool] Fixed small issue in SingletonThreadPool where the current connection to be returned might get inadvertently cleaned out during the “cleanup” process. 补丁礼貌jd23.

  • [bug] [ext] [py3k] Fixed bug in association proxy where assigning an empty slice (e.g. x[:] = [...]) would fail on Py3k.

  • [bug] [ext] Fixed a regression in association proxy caused by #2810 which caused a user-provided “getter” to no longer receive values of None when fetching scalar values from a target that is non-present. 这个改变引入的None检查现在移到了默认的getter中,所以用户提供的getter也会再次接收None的值。


  • [bug] [examples] 修正了版本级别示例中列级别INSERT默认值会阻止写入历史值NULL的错误。

0.9.3 ¶ T0>


ORM ¶ T0>

  • [orm] [feature] 添加了新的MapperEvents.before_configured()事件,它允许在configure_mappers() __declare_first__()钩子在声明中补充__declare_last__()

  • [orm] [bug] Fixed bug where Query.get() would fail to consistently raise the InvalidRequestError that invokes when called on a query with existing criterion, when the given identity is already present in the identity map.



  • [orm] [bug] [sqlite] Fixed bug in SQLite “join rewriting” where usage of an exists() construct would fail to be rewritten properly, such as when the exists is mapped to a column_property in an intricate nested-join scenario. 还修复了一些相关的问题,如果目标是别名表,而不是单独的别名列,那么在SELECT语句的columns子句上连接重写将失败。


  • [orm] [bug] Fixed an 0.9 regression where ORM instance or mapper events applied to a base class such as a declarative base with the propagate=True flag would fail to apply to existing mapped classes which also used inheritance due to an assertion. 另外,修复了在删除这样的事件时可能发生的属性错误,这取决于它是如何被首先分配的。


  • [orm] [bug] Improved the initialization logic of composite attributes such that calling MyClass.attribute will not require that the configure mappers step has occurred, e.g. it will just work without throwing any error.


  • [orm] [bug] More issues with [ticket:2932] first resolved in 0.9.2 where using a column key of the form <tablename>_<columnname> matching that of an aliased column in the text would still not match at the ORM level, which is ultimately due to a core column-matching issue. 额外的规则已经添加了,所以当使用TextAsFrom结构或者使用文字列时,需要考虑_label列。


orm declarative

发动机¶ T0>

  • [engine] [bug] [pool] Fixed a critical regression caused by #2880 where the newly concurrent ability to return connections from the pool means that the “first_connect” event is now no longer synchronized either, thus leading to dialect mis-configurations under even minimal concurrency situations.



SQL ¶ T0>

  • [sql] [bug] Fixed bug where calling Insert.values() with an empty list or tuple would raise an IndexError. 它现在产生一个空的插入结构,就像空字典一样。



  • [sql] [bug] Fixed bug where in_() would go into an endless loop if erroneously passed a column expression whose comparator included the __getitem__() method, such as a column that uses the postgresql.ARRAY type.



  • [sql] [bug] Fixed regression in new “naming convention” feature where conventions would fail if the referred table in a foreign key contained a schema name. 请求提供Thomas Farvour。


  • [sql] [bug] Fixed bug where so-called “literal render” of bindparam() constructs would fail if the bind were constructed with a callable, rather than a direct value. 这阻止了ORM表达式使用“literal_binds”编译器标志进行呈现。

的PostgreSQL ¶ T0>

  • [postgresql] [feature] TypeEngine.python_type便利访问器添加到postgresql.ARRAY类型中。请求礼貌Alexey Terentev。


  • [postgresql] [bug] Added an additional message to psycopg2 disconnect detection, “could not send data to server”, which complements the existing “could not receive data from server” and has been observed by users.



  • [postgresql] [bug]



  • [postgresql] [bug] Revised this very old issue where the Postgresql “get primary key” reflection query were updated to take into account primary key constraints that were renamed; the newer query fails on very old versions of Postgresql such as version 7, so the old query is restored in those cases when server_version_info < (8, 0) is detected.



  • [postgresql] [bug] 增加了对“show standard_conforming_strings”新增的方言启动查询的服务器版本检测;因为这个变量是从PG 8.2开始添加的,所以我们跳过PG版本的查询,这些版本早于那个版本字符串。


MySQL的¶ T0>

  • [mysql] [feature] 添加了新的特定于MySQL的mysql.DATETIME,其中包括小数秒支持;还添加了小数秒支持mysql.TIMESTAMPDBAPI支持是有限的,虽然小数秒被MySQL Connector / Python支持。补丁由Geert JM Vanderkelen提供



  • [mysql] [bug] Added support for the PARTITION BY and PARTITIONS MySQL table keywords, specified as mysql_partition_by='value' and mysql_partitions='value' to Table. 请求Marcus McCurdy提供。


    References: #2966, pull request bitbucket:12

  • [mysql] [bug] Fixed bug which prevented MySQLdb-based dialects (e.g. pymysql) from working in Py3K, where a check for “connection charset” would fail due to Py3K’s more strict value comparison rules. 这个调用在任何情况下都没有考虑到数据库版本,因为服务器版本在这个时候仍然是None,所以整个方法被简化为依赖于connection.character_set_name()。¶ t0 >



  • [mysql] [bug] [cymysql] Fixed bug in cymysql dialect where a version string such as '33a-MariaDB' would fail to parse properly. 拉请求马特·施密特。

    References: #2934, pull request github:69

源码¶ T0>

  • [sqlite] [bug] The SQLite dialect will now skip unsupported arguments when reflecting types; such as if it encounters a string like INTEGER(5), the INTEGER type will be instantiated without the “5” being included, based on detecting a TypeError on the first attempt.

  • [sqlite] [bug] 支持已经被添加到SQLite类型的反射,以完全支持在http://www.sqlite.org/datatype3.html指定的“type affinity” T2>。在此方案中,位于类型名称中的关键字(如INTCHARBLOBREAL与五个亲缘之一。拉请求礼貌Erich布卢姆。


    Type Reflection


杂项¶ T0>

  • [feature] [examples] 在版本化的行示例中添加了可选的“changed”列,以及当版本化的Table具有显式的schema拉请求jplaverdure。


  • [bug] [ext] Fixed bug where the AutomapBase class of the new automap extension would fail if classes were pre-arranged in single or potentially joined inheritance patterns. 当使用DeferredReflection时,修复的已连接继承问题也可能适用。

0.9.2 ¶ T0>


ORM ¶ T0>

  • [orm] [feature] 添加了一个新的参数Operators.op.is_comparison该标志允许来自Operators.op()的自定义操作被视为“比较”操作符,因此可用于自定义relationship.primaryjoin条件。

  • [orm] [feature] 为了创建非常简单的目的,提供join()结构作为relationship.secondary复杂的relationship()加入条件。该更改包括对查询连接的调整,加载的不加载SELECT子查询的加载,对“延迟加载”的更改以使“辅助”目标正确包含在SELECT中,并更改为声明式以更好地支持join()以班级为目标。


  • [orm] [bug] Fixed error message when an iterator object is passed to class_mapper() or similar, where the error would fail to render on string formatting. Pullleq礼貌Kyle Stark。



  • [orm] [bug] Fixed bug in new TextAsFrom construct where Column- oriented row lookups were not matching up to the ad-hoc ColumnClause objects that TextAsFrom generates, thereby making it not usable as a target in Query.from_statement(). 还修复了Query.from_statement()结构,使其不会将TextAsFrom误认为Select结构。当调用Text.columns()方法来适应text.typemap参数时,这个bug也是0.9回归。


  • [orm] [bug] Added a new directive used within the scope of an attribute “set” operation to disable autoflush, in the case that the attribute needs to lazy-load the “old” value, as in when replacing one-to-one values or some kinds of many-to-one. 在这一点上的刷新否则会发生在属性为None的地方,并且可能导致NULL违规。


  • [orm] [bug] Fixed an 0.9 regression where the automatic aliasing applied by Query and in other situations where selects or joins were aliased (such as joined table inheritance) could fail if a user-defined Column subclass were used in the expression. 在这种情况下,子类将无法传播适应所需的ORM特定的“注释”。“表达注释”系统已被纠正以解释这种情况。


  • [orm] [bug] Fixed a bug involving the new flattened JOIN structures which are used with joinedload() (thereby causing a regression in joined eager loading) as well as aliased() in conjunction with the flat=True flag and joined-table inheritance; basically multiple joins across a “parent JOIN sub” entity using different paths to get to a target class wouldn’t form the correct ON conditions. 在一个别名,连接类的情况下,在计算连接的“左侧”的机制中做出的调整/简化修复了这个问题。


发动机¶ T0>

  • [engine] [feature] [pool] 添加了一个新的池事件PoolEvents.invalidate()当DBAPI连接被标记为“invaldated”并从池中丢弃时调用。

SQL ¶ T0>

  • [sql] [feature] Added MetaData.reflect.**dialect_kwargs to support dialect-level reflection options for all Table objects reflected.

  • [sql] [feature] 新增了一项新功能,允许将自动命名约定应用于ConstraintIndex对象。根据Wiki中的配方,新功能使用架构事件来设置名称,因为各种架构对象都是相互关联的。The events then expose a configuration system through a new argument MetaData.naming_convention. This system allows production of both simple and custom naming schemes for constraints and indexes on a per-MetaData basis.


  • [sql] [feature] Options can now be specified on a PrimaryKeyConstraint object independently of the specification of columns in the table with the primary_key=True flag; use a PrimaryKeyConstraint object with no columns in it to achieve this result.

    Previously, an explicit PrimaryKeyConstraint would have the effect of those columns marked as primary_key=True being ignored; since this is no longer the case, the PrimaryKeyConstraint will now assert that either one style or the other is used to specify the columns, or if both are present, that the column lists match exactly. 如果PrimaryKeyConstraintTable中标记为primary_key=True的列不一致,则会发出警告,并且列表的列仅从PrimaryKeyConstraint单独获取,就像以前版本中的情况一样。




  • [sql] [feature] The system by which schema constructs and certain SQL constructs accept dialect-specific keyword arguments has been enhanced. This system includes commonly the Table and Index constructs, which accept a wide variety of dialect-specific arguments such as mysql_engine and postgresql_where, as well as the constructs PrimaryKeyConstraint, UniqueConstraint, Update, Insert and Delete, and also newly added kwarg capability to ForeignKeyConstraint and ForeignKey. 改变是现在参与的方言可以为这些结构指定可接受的参数列表,如果为特定的方言指定了无效的关键字,则允许引发参数错误。如果关键字的方言部分无法识别,则仅发出警告;而系统实际上将使用setuptools入口点来定位非本地方言,但是仍然支持在卸载该第三方方言的环境中使用某些方言特定参数的用例。方言也必须明确地加入这个系统,所以不使用这个系统的外部方言不会受到影响。


  • [sql] [bug] The behavior of Table.tometadata() has been adjusted such that the schema target of a ForeignKey will not be changed unless that schema matches that of the parent table. 也就是说,如果表“schema_a.user”具有“schema_b.order.id”的外键,则不管“schema”参数是否被传递给Table.tometadata()但是,如果表“schema_a.user”引用“schema_a.order.id”,则将在父表和被引用的表上更新“schema_a”的存在。这是一个行为上的变化,因此不可能回到0.8;假设之前的行为是非常麻烦的,而且不太可能有人依赖它。

    Additionally, a new parameter has been added Table.tometadata.referred_schema_fn. 这指的是一个可调用的函数,它将用于确定tometadata操作中遇到的任何ForeignKeyConstraint的新引用模式。这个可调用的方法可以用来恢复到以前的行为,或者定制如何在每个约束的基础上处理引用的模式。


  • [sql] [bug] Fixed bug whereby binary type would fail in some cases if used with a “test” dialect, such as a DefaultDialect or other dialect with no DBAPI.

  • [sql] [bug] [py3k] Fixed bug where “literal binds” wouldn’t work with a bound parameter that’s a binary type. 一个类似但不同的问题在0.8中得到了解决。

  • [sql] [bug] Fixed regression whereby the “annotation” system used by the ORM was leaking into the names used by standard functions in sqlalchemy.sql.functions, such as func.coalesce() and func.max(). 在ORM属性中使用这些函数,从而产生它们的注释版本可能会破坏在SQL中呈现的实际函数名称。


  • [sql] [bug] Fixed 0.9 regression where the new sortable support for RowProxy would lead to TypeError when compared to non-tuple types as it attempted to apply tuple() to the “other” object unconditionally. The full range of Python comparison operators have now been implemented on RowProxy, using an approach that guarantees a comparison system that is equivalent to that of a tuple, and the “other” object is only coerced if it’s an instance of RowProxy.


  • Table内联创建的UniqueConstraint,其中不包含任何列的[sql] [bug] Pullreq礼貌Derek Harland。


  • 修复了多表“UPDATE..FROM”构造,只能在MySQL上使用,才能在跨表的多个具有相同名称的列中正确呈现SET子句。[sql] [bug] [orm] 这也将仅用于非主表的绑定参数的名称更改为“_ ”;因为通常直接使用Column对象指定此参数,所以不应该对应用程序产生影响。 T1> T0>这个修正对于ORM中的Table.update()以及Query.update()都有效。


架构¶ T0>

  • [schema] [bug] Restored sqlalchemy.schema.SchemaVisitor to the .schema module. Pullreq礼貌Sean Dague。


的PostgreSQL ¶ T0>

  • [postgresql] [feature] Added a new dialect-level argument postgresql_ignore_search_path; this argument is accepted by both the Table constructor as well as by the MetaData.reflect() method. 当用于Postgresql时,即使名称存在于search_path中,指定远程模式名称的外键引用表也将保留该模式名称。 0.7.3以来的默认行为就是search_path中的模式不会被复制到反映的ForeignKey对象中。文档已经更新,以详细描述pg_get_constraintdef()函数的行为,以及postgresql_ignore_search_path特性如何确定我们是否将遵守此函数报告的模式限定或不。


MySQL的¶ T0>

  • [mysql] [bug] 添加到cymysql方言的一些缺失方法,包括_get_server_version_info()和_detect_charset()。Pullreq礼貌Hajime Nakagami。



  • [mysql] [bug] [sql] Added new test coverage for so-called “down adaptions” of SQL types, where a more specific type is adapted to a more generic one - this use case is needed by some third party tools such as sqlacodegen. 这个测试套件中需要修复的特定情况是将mysql.ENUM向下转换为types.Enum,而SQLite日期类型转换为通用日期类型。The adapt() method needed to become more specific here to counteract the removal of a “catch all” **kwargs collection on the base TypeEngine class that was removed in 0.9.


  • [mysql] [bug] The MySQL CAST compilation now takes into account aspects of a string type such as “charset” and “collation”. While MySQL wants all character- based CAST calls to use the CHAR type, we now create a real CHAR object at CAST time and copy over all the parameters it has, so that an expression like cast(x, mysql.TEXT(charset='utf8')) will render CAST(t.col AS CHAR CHARACTER SET utf8).

  • [mysql] [bug] Added new “unicode returns” detection to the MySQL dialect and to the default dialect system overall, such that any dialect can add extra “tests” to the on-first-connect “does this DBAPI return unicode directly?” detection. 在这种情况下,我们使用明确的“utf8_bin”排序类型(在检查这个排序规则可用之后)添加一个特别针对“utf8”编码的检查来测试MySQLdb 1.2.3版中观察到的一些错误的unicode行为。虽然MySQLdb从1.2.4开始已经解决了这个问题,但是这里的检查应该防止回退。更改还允许“unicode”检查登录引擎日志,这是以前没有的情况。


  • [mysql] [bug] [engine] [pool] Connection now associates a new RootTransaction or TwoPhaseTransaction with its immediate _ConnectionFairy as a “reset handler” for the span of that transaction, which takes over the task of calling commit() or rollback() for the “reset on return” behavior of Pool if the transaction was not otherwise completed. 这样可以解决这样一个问题:如果没有显式的回滚或提交,连接关闭时,像MySQL两阶段那样的挑剔事务将被正确关闭(例如,在这种情况下,不会再引发“XAER_RMFAIL” - 注意这只会出现在日志中因为异常不会在池重置中传播)。This issue would arise e.g. when using an orm Session with twophase set, and then Session.close() is called without an explicit rollback or commit. 此更改还具有以下效果:无论会话被丢弃如何,在非自动提交模式下使用Session对象时,您现在将在日志中看到明确的“ROLLBACK”。Thanks to Jeff Dairiki and Laurence Rowe for isolating the issue here.


源码¶ T0>

  • [sqlite] [bug] Fixed bug whereby SQLite compiler failed to propagate compiler arguments such as “literal binds” into a CAST expression.


预言¶ T0>

  • [oracle] [bug] It’s been observed that the usage of a cx_Oracle “outputtypehandler” in Python 2.xx in order to coerce string values to Unicode is inordinately expensive; even though cx_Oracle is written in C, when you pass the Python unicode primitive to cursor.var() and associate with an output handler, the library counts every conversion as a Python function call with all the requisite overhead being recorded; this despite the fact when running in Python 3, all strings are also unconditionally coerced to unicode but it does not incur this overhead, meaning that cx_Oracle is failing to use performant techniques in Py2K. 由于SQLAlchemy无法轻松地在每列的基础上选择这种类型的处理程序样式,因此无条件地组装处理程序,从而将开销添加到所有字符串访问。


    这一变化对cx_Oracle后端有两个影响。一个是Py2K中没有被Unicode类型或convert_unicode = True明确请求的字符串值现在将返回为str,而不是unicode - 这种行为类似于后端如MySQL。此外,当使用cx_Oracle后端请求unicode值时,如果C扩展名not被使用,现在每列有isinstance()检查的额外开销。这种权衡是可以解决的,不会给非Unicode字符串的大部分Oracle结果列带来性能负担。


杂项¶ T0>

  • [bug] [examples] Added a tweak to the “history_meta” example where the check for “history” on a relationship-bound attribute will now no longer emit any SQL if the relationship is unloaded.

  • [bug] [pool] The argument names for the PoolEvents.reset() event have been renamed to dbapi_connection and connection_record in order to maintain consistency with all the other pool events. 预计这个相对较新和很少使用的事件的任何现有的监听器在任何情况下都使用位置风格来接收参数。

  • [bug] [cextensions] [py3k] Fixed an issue where the C extensions in Py3K are using the wrong API to specify the top-level module function, which breaks in Python 3.4b2. Py3.4b2改变了PyMODINIT_FUNC返回“void”而不是PyObject *,所以我们现在确保使用“PyMODINIT_FUNC”而不是 PyObject *请求cgohlke请求。


0.9.1 ¶ T0>


ORM ¶ T0>

  • [orm] [feature] [extensions] 添加了新的实验扩展sqlalchemy.ext.automapThis extension expands upon the functionality of Declarative as well as the DeferredReflection class to produce a base class which automatically generates mapped classes and relationships based on table metadata.

  • [orm] [bug] [events] Fixed regression where using a functools.partial() with the event system would cause a recursion overflow due to usage of inspect.getargspec() on it in order to detect a legacy calling signature for certain events, and apparently there’s no way to do this with a partial object. 相反,我们跳过了传统检查,并采取现代风格;检查本身现在只发生在SessionEvents.after_bulk_update和SessionEvents.after_bulk_delete事件中。如果分配给“部分”事件监听器,那么这两个事件将需要新的签名样式。


  • [orm] [bug] Fixed bug where using new Session.info attribute would fail if the .info argument were only passed to the sessionmaker creation call but not to the object itself. 礼貌Robin Schoonover。


  • [orm] [bug] Fixed regression where we don’t check the given name against the correct string class when setting up a backref based on a name, therefore causing the error “too many values to unpack”. 这与Py3k转换有关。


  • [orm] [bug] Fixed regression where we apparently still create an implicit alias when saying query(B).join(B.cs), where “C” is a joined inh class; however, this implicit alias was created only considering the immediate left side, and not a longer chain of joins along different joined-inh subclasses of the same base. 只要我们在这种情况下仍然隐含别名,行为就会被回拨一下,这样它就会在各种各样的情况下混淆右侧。


orm declarative

  • [bug] [orm] [declarative] Fixed an extremely unlikely memory issue where when using DeferredReflection to define classes pending for reflection, if some subset of those classes were discarded before the DeferredReflection.prepare() method were called to reflect and map the class, a strong reference to the class would remain held within the declarative internals. 这个“映射类”的内部集合现在对这些类本身使用弱引用。

  • [bug] [orm] [declarative] A quasi-regression where apparently in 0.8 you can set a class-level attribute on declarative to simply refer directly to an InstrumentedAttribute on a superclass or on the class itself, and it acts more or less like a synonym; in 0.9, this fails to set up enough bookkeeping to keep up with the more liberalized backref logic from #2789. 尽管这个用例从来没有被直接考虑过,但是现在通过声明在“setattr()”级别以及在设置子类时检测到,而镜像/重命名属性现在被设置为synonym()代替。


SQL ¶ T0>

  • [sql] [feature] Conjunctions like and_() and or_() can now accept Python generators as a single argument, e.g.:

    and_(x == y for x, y in tuples)


架构¶ T0>

0.9.0 ¶ T0>


ORM ¶ T0>

  • [orm] [feature] The exc.StatementError or DBAPI-related subclass now can accommodate additional information about the “reason” for the exception; the Session now adds some detail to it when the exception occurs within an autoflush. This approach is taken as opposed to combining FlushError with a Python 3 style “chained exception” approach so as to maintain compatibility both with Py2K code as well as code that already catches IntegrityError or similar.

  • [orm] [feature] [backrefs] Added new argument include_backrefs=True to the validates() function; when set to False, a validation event will not be triggered if the event was initated as a backref to an attribute operation from the other side.


  • [orm] [feature] A new API for specifying the FOR UPDATE clause of a SELECT is added with the new Query.with_for_update() method, to complement the new GenerativeSelect.with_for_update() method. 拉玛尼奥·拉斯尼希提供的请求。


  • [orm] [bug] An adjustment to the subqueryload() strategy which ensures that the query runs after the loading process has begun; this is so that the subqueryload takes precedence over other loaders that may be hitting the same attribute due to other eager/noload situations at the wrong time.



  • [orm] [bug] Fixed bug when using joined table inheritance from a table to a select/alias on the base, where the PK columns were also not same named; the persistence system would fail to copy primary key values from the base table to the inherited table upon INSERT.



  • [orm] [bug] composite() will raise an informative error message when the columns/attribute (names) passed don’t resolve to a Column or mapped attribute (such as an erroneous tuple); previously raised an unbound local.



  • [orm] [bug] Fixed a regression introduced by #2818 where the EXISTS query being generated would produce a “columns being replaced” warning for a statement with two same-named columns, as the internal SELECT wouldn’t have use_labels set.

    This change is also backported to: 0.8.4


  • [orm] [bug] [collections] [py3k] Added support for the Python 3 method list.clear() within the ORM collection instrumentation system; pull request courtesy Eduardo Schettino.


  • [orm] [bug] Some refinements to the AliasedClass construct with regards to descriptors, like hybrids, synonyms, composites, user-defined descriptors, etc. 继续进行的属性适配已经变得更加健壮,例如,如果描述符返回另一个插装属性,而不是复合SQL表达式元素,则操作仍将继续。Addtionally, the “adapted” operator will retain its class; previously, a change in class from InstrumentedAttribute to QueryableAttribute (a superclass) would interact with Python’s operator system such that an expression like aliased(MyClass.x) > MyClass.x would reverse itself to read myclass.x < myclass_1.x. 修改后的属性也会将新的AliasedClass作为它的父项,这在以前并不总是这样。


  • [orm] [bug] The viewonly flag on relationship() will now prevent attribute history from being written on behalf of the target attribute. 如果对象没有被写入到Session.dirty列表,如果它被突变的话,会产生这种效果。以前,该对象将存在于Session.dirty中,但在刷新期间不会发生代表修改的属性的更改。该属性仍然发出诸如backref事件和用户定义事件的事件,并且仍然会从backrefs接收到突变。


  • [orm] [bug] 增加了对Session.info属性对scoped_session的支持。

  • [orm] [bug] Fixed bug where usage of new Bundle object would cause the Query.column_descriptions attribute to fail.

  • [orm] [bug] [sqlite] [sql] Fixed a regression introduced by the join rewriting feature of #2369 and #2587 where a nested join with one side already an aliased select would fail to translate the ON clause on the outside correctly; in the ORM this could be seen when using a SELECT statement as a “secondary” table.


orm declarative

  • [bug] [orm] [declarative] Declarative does an extra check to detect if the same Column is mapped multiple times under different properties (which typically should be a synonym() instead) or if two or more Column objects are given the same name, raising a warning if this condition is detected.


  • [bug] [orm] [declarative] 已经增强了DeferredReflection类,以便为由relationship()“secondary”, when specified either as a string table name, or as a Table object with only a name and MetaData object will also be included in the reflection process when DeferredReflection.prepare() is called.


  • [bug] [orm] [declarative] Fixed bug where in Py2K a unicode literal would not be accepted as the string name of a class or other argument within declarative using relationship().

发动机¶ T0>

  • [engine] [feature] The engine_from_config() function has been improved so that we will be able to parse dialect-specific arguments from string configuration dictionaries. 方言类现在可以提供自己的参数类型列表和字符串转换例程。但是,内置方言尚未使用该功能。


  • [engine] [bug] A DBAPI that raises an error on connect() which is not a subclass of dbapi.Error (such as TypeError, NotImplementedError, etc.) 将不会传播异常。以前,特定于connect()例程的错误处理将通过方言的Dialect.is_disconnect()例程错误地运行异常,并将其包装在sqlalchemy.exc.DBAPIError它现在以与执行过程中发生的相同的方式传播。

    This change is also backported to: 0.8.4


  • [engine] [bug] [pool] The QueuePool has been enhanced to not block new connection attempts when an existing connection attempt is blocking. 以前,在监视溢出的块中,新连接的产生被串行化;溢出计数器现在在连接过程本身之外的其自己的关键部分内被更改

    This change is also backported to: 0.8.4


  • [engine] [bug] [pool] Made a slight adjustment to the logic which waits for a pooled connection to be available, such that for a connection pool with no timeout specified, it will every half a second break out of the wait to check for the so-called “abort” flag, which allows the waiter to break out in case the whole connection pool was dumped; normally the waiter should break out due to a notify_all() but it’s possible this notify_all() is missed in very slim cases. 这是在0.8.0中首次引入的逻辑的扩展,这个问题偶尔在压力测试中被观察到。

    This change is also backported to: 0.8.4


  • [engine] [bug] Fixed bug where SQL statement would be improperly ASCII-encoded when a pre-DBAPI StatementError were raised within Connection.execute(), causing encoding errors for non-ASCII statements. 字符串化现在保留在Python unicode中,从而避免编码错误。

    This change is also backported to: 0.8.4


  • [engine] [bug] The create_engine() routine and the related make_url() function no longer considers the + sign to be a space within the password field. 解析已经与RFC 1738完全匹配,因为usernamepassword只有:@ ,和/进行编码。


  • [engine] [bug] The RowProxy object is now sortable in Python as a regular tuple is; this is accomplished via ensuring tuple() conversion on both sides within the __eq__() method as well as the addition of a __lt__() method.


SQL ¶ T0>

  • [sql] [feature] New improvements to the text() construct, including more flexible ways to set up bound parameters and return types; in particular, a text() can now be turned into a full FROM-object, embeddable in other statements as an alias or CTE using the new method TextClause.columns(). 当构造体在“文字边界”上下文中编译时,text()结构也可以呈现“内联”的边界参数。


  • [sql] [feature] A new API for specifying the FOR UPDATE clause of a SELECT is added with the new GenerativeSelect.with_for_update() method. This method supports a more straightforward system of setting dialect-specific options compared to the for_update keyword argument of select(), and also includes support for the SQL standard FOR UPDATE OF clause. ORM还包含一个新的相应的方法Query.with_for_update()拉玛尼奥·拉斯尼希提供的请求。


  • [sql] [feature] 通过字符串将返回的浮点值强制转换为Python Decimal时使用的精度现在是可配置的。现在所有的NumericFloat类型都支持flag decimal_return_scale,这将确保这个很多数字是从本地浮点值被转换为字符串。如果不存在,则类型将使用.scale的值,如果类型支持此设置,则它是非无。否则使用原来的默认长度10。


  • [sql] [bug] Fixed issue where a primary key column that has a Sequence on it, yet the column is not the “auto increment” column, either because it has a foreign key constraint or autoincrement=False set, would attempt to fire the Sequence on INSERT for backends that don’t support sequences, when presented with an INSERT missing the primary key value. 这将发生在像SQLite,MySQL这样的非序列后端上。



  • [sql] [bug] Fixed bug with Insert.from_select() method where the order of the given names would not be taken into account when generating the INSERT statement, thus producing a mismatch versus the column names in the given SELECT statement. 另外还指出,Insert.from_select()意味着Python端的插入默认值不能被使用,因为声明没有VALUES子句。



  • [sql] [bug] The cast() function, when given a plain literal value, will now apply the given type to the given literal value on the bind parameter side according to the type given to the cast, in the same manner as that of the type_coerce() function. 但是,与type_coerce()不同,只有在将非子句元素的值传递给cast()时,才会生效。一个现有的类型化构造将保留它的类型。

  • [sql] [bug] The ForeignKey class more aggressively checks the given column argument. If not a string, it checks that the object is at least a ColumnClause, or an object that resolves to one, and that the .table attribute, if present, refers to a TableClause or subclass, and not something like an Alias. 否则,引发一个ArgumentError


  • [sql] [bug] The precedence rules for the ColumnOperators.collate() operator have been modified, such that the COLLATE operator is now of lower precedence than the comparison operators. 这样做的结果是,应用于比较的COLLATE不会在比较周围产生括号,而后者不会被MSSQL等后端解析。对于通过将Operators.collate()应用于比较表达式的单个元素而不是比较表达式作为整体来解决问题的设置,这种改变是向后兼容的。


  • [sql] [enhancement] The exception raised when a BindParameter is present in a compiled statement without a value now includes the key name of the bound parameter in the error message.


架构¶ T0>

  • [schema] [bug] Fixed a regression caused by #2812 where the repr() for table and column names would fail if the name contained non-ascii characters.


的PostgreSQL ¶ T0>

  • [postgresql] [feature] 使用新的JSON类型添加了对Postgresql JSON的支持。非常感谢Nathan Rice的实施和测试。


  • [postgresql] [feature] 通过postgresql.TSVECTOR类型增加了对Postgresql TSVECTOR的支持。请求提供Noufal Ibrahim。


  • [postgresql] [bug] Fixed bug where index reflection would mis-interpret indkey values when using the pypostgresql adapter, which returns these values as lists vs. psycopg2’s return type of string.

    This change is also backported to: 0.8.4


  • [postgresql] [bug] 现在使用psycopg2 UNICODEARRAY扩展来处理unicode数组,使用psycopg2 +正常的“native unicode”模式,就像使用UNICODE扩展一样

  • [postgresql] [bug] 修正了单引号内没有转义ENUM值的错误。请注意,这是手动转义单引号的现有解决方法向后不兼容。


MySQL的¶ T0>

  • [mysql] [bug] __repr__()中,SQL类型生成的系统的改进,特别是关于具有宽各种关键字参数。在Python代码在迁移脚本中呈现时,__repr__()对于Alembic自动生成非常重要。



  • [mssql] [bug] [firebird] The “asdecimal” flag used with the Float type will now work with Firebird as well as the mssql+pyodbc dialects; previously the decimal conversion was not occurring.


  • [mssql] [bug] [pymssql] Added “Net-Lib error during Connection reset by peer” message to the list of messages checked for “disconnect” within the pymssql dialect. John Anderson提供。



  • [mssql] [bug] 修正了0.8.0版本中引入索引的DROP INDEX如果索引处于备用模式,MSSQL将会错误地呈现; schemaname / tablename将被颠倒。格式也被修改为符合当前的MSSQL文档。Courtesy Derek Harland。

    This change is also backported to: 0.8.4


预言¶ T0>

  • [oracle] [bug] 增加了ORA-02396“最大空闲时间”的错误代码到“断开连接”代码列表中使用cx_oracle

    This change is also backported to: 0.8.4


  • [oracle] [bug] Fixed bug where Oracle VARCHAR types given with no length (e.g. for a CAST or similar) would incorrectly render None CHAR or similar.

    This change is also backported to: 0.8.4


火鸟¶ T0>

  • [firebird] [bug] The firebird dialect will quote identifiers which begin with an underscore. Courtesy Treeve Jelbert。



  • [firebird] [bug] Fixed bug in Firebird index reflection where the columns within the index were not sorted correctly; they are now sorted in order of RDB$FIELD_POSITION.


  • [firebird] [bug] Changed the queries used by Firebird to list table and view names to query from the rdb$relations view instead of the rdb$relation_fields and rdb$view_relations views. 旧的和新的查询的变体在许多常见问题和博客中都有提及,但是新的查询直接来自“Firebird常见问题”,它似乎是最正式的信息来源。


杂项¶ T0>

  • [removed] “informix”和“informixdb”方言已被删除;该代码现在作为Bitbucket上的单独存储库提供。由于首先添加了informixdb方言,因此IBM-DB项目提供了生产级别的Informix支持。

  • [bug] [declarative] 错误消息,当一个字符串arg发送到relationship(),它不解析为一个类或映射器时,当收到一个非字符串arg时,表示有配置错误的关系的名字。



  • [bug] [ext] Fixed bug which prevented the serializer extension from working correctly with table or column names that contain non-ASCII characters.

    This change is also backported to: 0.8.4


  • [bug] [examples] Fixed bug which prevented history_meta recipe from working with joined inheritance schemes more than one level deep.

0.9.0b1 ¶ T0>


一般¶ T0>

  • [general] [feature] [py3k] The C extensions are ported to Python 3 and will build under any supported CPython 2 or 3 environment.


  • [general] [feature] [py3k] 对于Python 2和3,现在代码库是“就地”的,运行2to3的需求已经被删除。兼容性现在在Python 2.6上正向运行。


  • [general] 对包进行了大量的重构,重组了许多Core模块的导入结构以及ORM模块的某些方面。In particular sqlalchemy.sql has been broken out into several more modules than before so that the very large size of sqlalchemy.sql.expression is now pared down. 这一努力的重点是大量减少进口周期。Additionally, the system of API functions in sqlalchemy.sql.expression and sqlalchemy.orm has been reorganized to eliminate redundancy in documentation between the functions vs. the objects they produce.

ORM ¶ T0>

  • [orm] [feature] Added new option to relationship() distinct_target_key. 这使得子查询预热加载器策略能够将DISTINCT应用到最内层的SELECT子查询中,以协助对应于这种关系的最内层查询生成重复行的情况(对于内部行的问题还没有一个通用的解决方案子查询迫切加载,但是,当加入最内层的子查询产生愚蠢)。当标志被设置为True时,DISTINCT被无条件渲染,当它被设置为None时,如果最内层关系指向不包含完整的主键。0.8中的选项默认为False(例如,在所有情况下默认关闭),0.9中的None(例如默认为自动)。感谢Alexander Koval对此的帮助。



  • [orm] [feature] The association proxy now returns None when fetching a scalar attribute off of a scalar relationship, where the scalar relationship itself points to None, instead of raising an AttributeError.


  • [orm] [feature] Added new method AttributeState.load_history(), works like AttributeState.history but also fires loader callables.


  • [orm] [feature] 添加了一个新的加载选项orm.load_only()这允许一系列列名被指定为仅“加载”那些属性,推迟其余的属性。


  • [orm] [feature] 加载器选项的系统已经完全重新架构,建立在一个更为全面的基础上,Load对象。这个基础允许像joinedload()defer()等常见的加载器选项。to be used in a “chained” style for the purpose of specifying options down a path, such as joinedload("foo").subqueryload("bar"). 新系统取代点分隔路径名称的使用,选项中的多个属性以及_all()选项的用法。


  • [orm] [feature] The composite() construct now maintains the return object when used in a column-oriented Query, rather than expanding out into individual columns. 这使得内部使用新的Bundle功能。这种行为是向后不相容的;要从将要展开的组合列中选择,请使用MyClass.some_composite.clauses


  • [orm] [feature] A new construct Bundle is added, which allows for specification of groups of column expressions to a Query construct. 该列组默认情况下作为单个元组返回。然而,可以重写Bundle的行为,以向返回的行提供任何类型的结果处理。当在面向列的Query中使用时,Bundle的行为现在也嵌入到复合属性中。


  • [orm] [feature] The version_id_generator parameter of Mapper can now be specified to rely upon server generated version identifiers, using triggers or other database-provided versioning features, or via an optional programmatic value, by setting version_id_generator=False. 当使用服务器生成的版本标识符时,ORM将在可用时使用RETURNING立即加载新的版本值,否则它将发出第二个SELECT。


  • [orm] [feature] The eager_defaults flag of Mapper will now allow the newly generated default values to be fetched using an inline RETURNING clause, rather than a second SELECT statement, for backends that support RETURNING.


  • [orm] [feature] 添加了一个新的属性Session.infoSession;这是一个字典,应用程序可以存储本地到Session的任意数据。The contents of Session.info can be also be initialized using the info argument of Session or sessionmaker.

  • [orm] [feature] 现在实现了事件监听器的移除。该功能是通过event.remove()函数提供的。


    Event Removal API


  • [orm] [feature] The mechanism by which attribute events pass along an AttributeImpl as an “initiator” token has been changed; the object is now an event-specific object called attributes.Event. 此外,属性系统不再基于匹配的“启动器”令牌停止事件;这个逻辑已经被移动到ORM backref事件处理程序的特定位置,这是处理属性事件重新传播到随后的append / set / remove操作的典型源。如果方案不使用backref处理程序,那么模拟backrefs行为的最终用户代码现在必须确保递归事件传播方案被暂停。使用这个新系统,当一个对象被追加到一个集合上时,backref处理程序现在可以执行一个“双跳”操作,与一个新的多对一关联,与之前的多对一关联,然后从以前的集合中删除。在此更改之前,不会发生从前一个集合中删除的最后一步。


  • [orm] [feature] A major change regarding how the ORM constructs joins where the right side is itself a join or left outer join. The ORM is now configured to allow simple nesting of joins of the form a JOIN (b JOIN c ON b.id=c.id) ON a.id=b.id, rather than forcing the right side into a SELECT subquery. 这应该允许大多数后端显着的性能改进,特别是MySQL。多年来,一个数据库后端阻止了这种变化,SQLite现在通过将SELECT子查询的生成从ORM移动到SQL编译器来解决;所以SQLite上的右嵌套连接最终仍然会以SELECT呈现,而所有其他后端不再受此解决方法的影响。



  • [orm] [bug] Fixed bug where using an annotation such as remote() or foreign() on a Column before association with a parent Table could produce issues related to the parent table not rendering within joins, due to the inherent copy operation performed by an annotation.



  • [orm] [bug] Fixed bug where Query.exists() failed to work correctly without any WHERE criterion. 礼貌Vladimir Magamedov。



  • [orm] [bug] Fixed a potential issue in an ordered sequence implementation used by the ORM to iterate mapper hierarchies; under the Jython interpreter this implementation wasn’t ordered, even though cPython and Pypy maintained ordering.



  • [orm] [bug] Fixed bug in ORM-level event registration where the “raw” or “propagate” flags could potentially be mis-configured in some “unmapped base class” configurations.



  • [orm] [bug] A performance fix related to the usage of the defer() option when loading mapped entities. 在加载时将每个对象的延迟调用应用于实例的函数开销要比仅从该行加载数据的开销(请注意,defer()是为了减少DB /网络开销,不一定函数调用计数);在所有情况下,函数调用开销都小于从列中加载数据的开销。每个负载创建的“惰性可调用”对象的数量也会从N(结果中的总延迟值)减少到1(延迟列的总数)。



  • [orm] [bug] Fixed bug whereby attribute history functions would fail when an object we moved from “persistent” to “pending” using the make_transient() function, for operations involving collection-based backrefs.



  • [orm] [bug] 尝试刷新继承类的对象时发出警告,其中多态鉴别符被分配给一个对该类无效的值¶ T2>



  • [orm] [bug] Fixed bug in polymorphic SQL generation where multiple joined-inheritance entities against the same base class joined to each other as well would not track columns on the base table independently of each other if the string of joins were more than two entities long.



  • [orm] [bug] Fixed bug where sending a composite attribute into Query.order_by() would produce a parenthesized expression not accepted by some databases.



  • [orm] [bug] Fixed the interaction between composite attributes and the aliased() function. 以前,当应用别名时,复合属性在比较操作中不能正常工作。



  • [orm] [bug] [ext] Fixed bug where MutableDict didn’t report a change event when clear() was called.



  • [orm] [bug] Fixed bug where list instrumentation would fail to represent a setslice of [0:0] correctly, which in particular could occur when using insert(0, item) with the association proxy. 由于Python集合中的一些怪癖,这个问题更可能发生在Python 3而不是2上。

    This change is also backported to: 0.8.3, 0.7.11


  • [orm] [bug] attributes.get_history() when used with a scalar column-mapped attribute will now honor the “passive” flag passed to it; as this defaults to PASSIVE_OFF, the function will by default query the database if the value is not present. 这是一个行为变化与0.8。


  • [orm] [bug] [associationproxy] Added additional criterion to the ==, != comparators, used with scalar values, for comparisons to None to also take into account the association record itself being non-present, in addition to the existing test for the scalar endpoint on the association record being NULL. Previously, comparing Cls.scalar == None would return records for which Cls.associated were present and Cls.associated.scalar is None, but not rows for which Cls.associated is non-present. More significantly, the inverse operation Cls.scalar != None would return Cls rows for which Cls.associated was non-present.

    Cls.scalar != 'somevalue'的情况也进行了修改,使其更像是直接的SQL比较;只有存在Cls.associated的行以及Associated.scalar是非NULL,并且不等于'somevalue'以前,这将是一个简单的NOT EXISTS

    Also added a special use case where you can call Cls.scalar.has() with no arguments, when Cls.scalar is a column-based value - this returns whether or not Cls.associated has any rows present, regardless of whether or not Cls.associated.scalar is NULL or not.


  • [orm] [bug] Fixed an obscure bug where the wrong results would be fetched when joining/joinedloading across a many-to-many relationship to a single-table-inheriting subclass with a specific discriminator value, due to “secondary” rows that would come back. 现在,“辅助”表和右侧表在内部加入了所有ORM在多对多关系上的括号内部,从而可以精确地过滤左右连接。最终通过#2587中概述的右嵌套连接解决了这个问题,从而实现了这一改变。


  • [orm] [bug] Query.select_from()方法的“自动别名”行为已被关闭。具体的行为现在可以通过一个新的方法Query.select_entity_from()得到。The auto-aliasing behavior here was never well documented and is generally not what’s desired, as Query.select_from() has become more oriented towards controlling how a JOIN is rendered. Query.select_entity_from() will also be made available in 0.8 so that applications which rely on the auto-aliasing can shift their applications to use this method.


orm declarative

  • [feature] [orm] [declarative] Added a convenience class decorator as_declarative(), is a wrapper for declarative_base() which allows an existing base class to be applied using a nifty class-decorated approach.


  • [feature] [orm] [declarative] ORM descriptors such as hybrid properties can now be referenced by name in a string argument used with order_by, primaryjoin, or similar in relationship(), in addition to column-bound attributes.



发动机¶ T0>

  • [engine] [feature] repr() for the URL of an Engine will now conceal the password using asterisks. Courtesy GunnlaugurÞórBriem。



  • [engine] [feature] 添加到ConnectionEvents的新事件:


  • [engine] [bug] [oracle] Dialect.initialize() is not called a second time if an Engine is recreated, due to a disconnect error. 这解决了Oracle 8方言中的一个特定问题,但是通常dialect.initialize()阶段只应该是每个方言一次。



  • [engine] [bug] [pool] Fixed bug where QueuePool would lose the correct checked out count if an existing pooled connection failed to reconnect after an invalidate or recycle event.



  • [engine] [bug] Fixed bug where the reset_on_return argument to various Pool implementations would not be propagated when the pool was regenerated. Courtesy Eevee。



  • [engine] [bug] The regexp used by the make_url() function now parses ipv6 addresses, e.g. surrounded by brackets.

    This change is also backported to: 0.8.3, 0.7.11


  • [engine] [bug] The method signature of Dialect.reflecttable(), which in all known cases is provided by DefaultDialect, has been tightened to expect include_columns and exclude_columns arguments without any kw option, reducing ambiguity - previously exclude_columns was missing.


SQL ¶ T0>

  • [sql] [feature] Added support for “unique constraint” reflection, via the Inspector.get_unique_constraints() method. 感谢Roman Podolyaka的补丁。

    This change is also backported to: 0.8.4


  • [sql] [feature] The update(), insert(), and delete() constructs will now interpret ORM entities as target tables to be operated upon, e.g.:

    from sqlalchemy import insert, update, delete
    ins = insert(SomeMappedClass).values(x=5)
    del_ = delete(SomeMappedClass).where(SomeMappedClass.id == 5)
    upd = update(SomeMappedClass).where(SomeMappedClass.id == 5).values(name='ed')


  • [sql] [feature] [postgresql] [mysql] The Postgresql and MySQL dialects now support reflection/inspection of foreign key options, including ON UPDATE, ON DELETE. Postgresql也反映了MATCH,DEFERRABLE和INITIALLY。Coutesy ijl。


  • [sql] [feature] A bindparam() construct with a “null” type (e.g. no type specified) is now copied when used in a typed expression, and the new copy is assigned the actual type of the compared column. 以前,这个逻辑会发生在给定的bindparam()上。Additionally, a similar process now occurs for bindparam() constructs passed to ValuesBase.values() for an Insert or Update construct, within the compilation phase of the construct.



  • [sql] [feature] An overhaul of expression handling for special symbols particularly with conjunctions, e.g. None expression.null() expression.true() expression.false(), including consistency in rendering NULL in conjunctions, “short-circuiting” of and_() and or_() expressions which contain boolean constants, and rendering of boolean constants and expressions as compared to “1” or “0” for backends that don’t feature true/false constants.

    References: #2734, #2804, #2823

  • [sql] [feature] The typing system now handles the task of rendering “literal bind” values, e.g. values that are normally bound parameters but due to context must be rendered as strings, typically within DDL constructs such as CHECK constraints and indexes (note that “literal bind” values become used by DDL as of #2742). A new method TypeEngine.literal_processor() serves as the base, and TypeDecorator.process_literal_param() is added to allow wrapping of a native literal rendering method.


  • [sql] [feature] The Table.tometadata() method now produces copies of all SchemaItem.info dictionaries from all SchemaItem objects within the structure including columns, constraints, foreign keys, etc. 由于这些字典是复制品,因此它们与原始字典无关。以前只有Column.info字典在这个操作中被传送,而且它只被连接到位,不被复制。


  • [sql] [feature] The default argument of Column now accepts a class or object method as an argument, in addition to a standalone function; will properly detect if the “context” argument is accepted or not.

  • [sql] [feature] Added new method to the insert() construct Insert.from_select(). Given a list of columns and a selectable, renders INSERT INTO (table) (columns) SELECT ... 虽然这个特性作为0.9的一部分被突出显示,但是也被反馈到了0.8.3。




  • [sql] [feature] Provided a new attribute for TypeDecorator called TypeDecorator.coerce_to_is_types, to make it easier to control how comparisons using == or != to None and boolean types goes about producing an IS expression, or a plain equality expression with a bound parameter.


  • [sql] [feature] A label() construct will now render as its name alone in an ORDER BY clause, if that label is also referred to in the columns clause of the select, instead of rewriting the full expression. 这给了数据库更好的机会来优化在两个不同的上下文中对相同表达式的评估。


  • [sql] [bug] Fixed bug where type_coerce() would not interpret ORM elements with a __clause_element__() method properly.



  • [sql] [bug] The Enum and Boolean types now bypass any custom (e.g. TypeDecorator) type in use when producing the CHECK constraint for the “non native” type. 这样自定义类型不会被包含在CHECK中的表达式中,因为这个表达式违背了“impl”的值而不是“装饰的”值。



  • [sql] [bug] The .unique flag on Index could be produced as None if it was generated from a Column that didn’t specify unique (where it defaults to None). 该标志现在总是TrueFalse



  • [sql] [bug] Fixed bug in default compiler plus those of postgresql, mysql, and mssql to ensure that any literal SQL expression values are rendered directly as literals, instead of as bound parameters, within a CREATE INDEX statement. 这也改变了其他DDL的渲染方案,如约束。



  • [sql] [bug] A select() that is made to refer to itself in its FROM clause, typically via in-place mutation, will raise an informative error message rather than causing a recursion overflow.



  • [sql] [bug] Fixed bug where using the column_reflect event to change the .key of the incoming Column would prevent primary key constraints, indexes, and foreign key constraints from being correctly reflected.



  • [sql] [bug] The ColumnOperators.notin_() operator added in 0.8 now properly produces the negation of the expression “IN” returns when used against an empty collection.


  • [sql] [bug] [postgresql] Fixed bug where the expression system relied upon the str() form of a some expressions when referring to the .c collection on a select() construct, but the str() form isn’t available since the element relies on dialect-specific compilation constructs, notably the __getitem__() operator as used with a Postgresql ARRAY element. 该修补程序还添加了一个新的异常类UnsupportedCompilationError,这是在编译器被要求编译不知道如何编译的东西时引发的。



  • [sql] [bug] 对于Select结构的相关行为的多个修复,在0.8.0中首次引入:

    • 为了满足这样的用例,其中FROM条目应该向外关联到一个包含另一个的SELECT,然后包含这个SELECT,现在通过Select.correlate()建立显式关联时,前提是目标选择位于WHERE / ORDER BY / columns子句所包含的链中,而不仅仅是嵌套的FROM子句。This makes Select.correlate() act more compatibly to that of 0.7 again while still maintaining the new “smart” correlation.
    • 当不使用显式关联时,通常的“隐式”关联将其行为限制为仅包含即时封闭的SELECT,以最大化与0.7应用程序的兼容性,并且在此情况下也防止在嵌套FROM之间的相关性,保持与0.8.0 / 0.8的兼容性。 1。
    • The Select.correlate_except() method was not preventing the given FROM clauses from correlation in all cases, and also would cause FROM clauses to be incorrectly omitted entirely (more like what 0.7 would do), this has been fixed.
    • 调用select.correlate_except(None)将会按照预期将所有FROM子句输入到相关中。



  • [sql] [bug] Fixed bug whereby joining a select() of a table “A” with multiple foreign key paths to a table “B”, to that table “B”, would fail to produce the “ambiguous join condition” error that would be reported if you join table “A” directly to “B”; it would instead produce a join condition with multiple criteria.



  • [sql] [bug] [reflection] Fixed bug whereby using MetaData.reflect() across a remote schema as well as a local schema could produce wrong results in the case where both schemas had a table of the same name.



  • [sql] [bug] Removed the “not implemented” __iter__() call from the base ColumnOperators class, while this was introduced in 0.8.0 to prevent an endless, memory-growing loop when one also implements a __getitem__() method on a custom operator and then calls erroneously list() on that object, it had the effect of causing column elements to report that they were in fact iterable types which then throw an error when you try to iterate. 没有真正的方法让双方都在这里,所以我们坚持使用Python的最佳实践。仔细在你的自定义操作符上实现__getitem__()



  • [sql] [bug] Fixed regression dating back to 0.7.9 whereby the name of a CTE might not be properly quoted if it was referred to in multiple FROM clauses.

    This change is also backported to: 0.8.3, 0.7.11


  • [sql] [bug] [cte] Fixed bug in common table expression system where if the CTE were used only as an alias() construct, it would not render using the WITH keyword.

    This change is also backported to: 0.8.3, 0.7.11


  • [sql] [bug] Fixed bug in CheckConstraint DDL where the “quote” flag from a Column object would not be propagated.

    This change is also backported to: 0.8.3, 0.7.11


  • [sql] [bug] 在调用“attach”事件之前,“name”属性在Index上设置,以便可以使用附件事件动态生成名称为基于父表和/或列的索引。


  • [sql] [bug] 错误的kw arg“schema”已经从ForeignKey对象中删除。这是一个无所事事的意外事件;当使用这个kw arg时,会在0.8.3中发出警告。


  • [sql] [bug] 处理“带引号”标识符的方式的重写,不是依赖传递的各种quote=True标志,这些标志被转换为丰富的字符串对象,其中包含在传递给公共模式结构(如TableColumn等)的引用信息。这解决了不正确地遵守“quote”标志的各种方法的问题,例如Engine.has_table()和相关的方法。quoted_name对象是一个字符串子类,如果需要也可以明确使用;该对象将保持传递的引用偏好,并且也将绕过标准化为大写符号的方言(如Oracle,Firebird和DB2)执行的“名称规范化”。结果是,“大写”后端现在可以使用强制引用的名称,如小写引用的名称和新的保留字。


  • [sql] [bug] The resolution of ForeignKey objects to their target Column has been reworked to be as immediate as possible, based on the moment that the target Column is associated with the same MetaData as this ForeignKey, rather than waiting for the first time a join is constructed, or similar. 这与其他改进一起允许更早地检测一些外键配置问题。Also included here is a rework of the type-propagation system, so that it should be reliable now to set the type as None on any Column that refers to another via ForeignKey - the type will be copied from the target column as soon as that other column is associated, and now works for composite foreign keys as well.


的PostgreSQL ¶ T0>

  • [postgresql] [feature] 增加了对Postgresql 9.2范围类型的支持。目前没有提供类型转换,因此可以直接使用字符串或psycopg2 2.5范围扩展类型。Chris Withers提供的补丁。


  • [postgresql] [feature] 在使用psycopg2 DBAPI时增加了对“AUTOCOMMIT”隔离的支持。关键字可通过isolation_level执行选项使用。罗马Podolyaka提供的补丁。



  • [postgresql] [feature] Added support for rendering SMALLSERIAL when a SmallInteger type is used on a primary key autoincrement column, based on server version detection of Postgresql version 9.2 or greater.


  • [postgresql] [bug] 从列的服务器默认值的反射中删除了128个字符的截断;这个代码是PG系统视图的原始代码,为了可读性而截断了字符串。



  • [postgresql] [bug] 圆括号将应用于在CREATE INDEX语句的列表中呈现的复合SQL表达式



  • [postgresql] [bug] Fixed bug where Postgresql version strings that had a prefix preceding the words “Postgresql” or “EnterpriseDB” would not parse. 感谢Scott Schaefer。



  • [postgresql] [bug] The behavior of extract() has been simplified on the Postgresql dialect to no longer inject a hardcoded ::timestamp or similar cast into the given expression, as this interfered with types such as timezone-aware datetimes, but also does not appear to be at all necessary with modern versions of psycopg2.



  • [postgresql] [bug] Fixed bug in HSTORE type where keys/values that contained backslashed quotes would not be escaped correctly when using the “non native” (i.e. non-psycopg2) means of translating HSTORE data. 补丁礼貌Ryan Kelly。



  • [postgresql] [bug] Fixed bug where the order of columns in a multi-column Postgresql index would be reflected in the wrong order. 礼貌罗马Podolyaka。



MySQL的¶ T0>

  • [mysql] [feature] The mysql_length parameter used with Index can now be passed as a dictionary of column names/lengths, for use with composite indexes. 非常感谢罗马Podolyaka的补丁。



  • [mysql] [feature] The MySQL mysql.SET type now features the same auto-quoting behavior as that of mysql.ENUM. 设置值时不需要引号,但是存在的引号会自动检测并伴随警告。这也有助于Alembic,其中SET类型不会用引号渲染。


  • [mysql] [bug] The change in #2721, which is that the deferrable keyword of ForeignKeyConstraint is silently ignored on the MySQL backend, will be reverted as of 0.9; this keyword will now render again, raising errors on MySQL as it is not understood - the same behavior will also apply to the initially keyword. 在0.8中,关键字将保持忽略,但会发出警告。此外,match关键字现在会在0.9上产生一个CompileError,并在0.8上发出警告;这个关键字不仅被MySQL默默地忽略,而且打破了ON UPDATE / ON DELETE选项。

    要使用在MySQL上不呈现或呈现不同的ForeignKeyConstraint,请使用自定义编译选项。这个用法的一个例子已经被添加到文档中,参见MySQL Foreign Keys



  • [mysql] [bug] MySQL-connector dialect now allows options in the create_engine query string to override those defaults set up in the connect, including “buffered” and “raise_on_warnings”.



  • [mysql] [bug] Fixed bug when using multi-table UPDATE where a supplemental table is a SELECT with its own bound parameters, where the positioning of the bound parameters would be reversed versus the statement itself when using MySQL’s special syntax.



  • [mysql] [bug] Added another conditional to the mysql+gaerdbms dialect to detect so-called “development” mode, where we should use the rdbms_mysqldb DBAPI. 补丁由Brett Slatkin提供。



  • [mysql] [bug] The deferrable keyword argument on ForeignKey and ForeignKeyConstraint will not render the DEFERRABLE keyword on the MySQL dialect. 很长一段时间,我们放弃了这一点,因为一个不可延迟的外键与延迟的外键的行为是不一样的,但是一些环境只是禁用了MySQL上的FK,所以我们在这里就不那么自以为是。 t0 >



  • [mysql] [bug] 版本5.5,5.6的MySQL保留字的更新Hanno Schlichting

    This change is also backported to: 0.8.3, 0.7.11


  • [mysql] [bug] 修复和测试反射中的MySQL外键选项的解析;这补充了#2183中的工作,我们开始支持外部关键选项的反映,例如ON UPDATE / ON DELETE cascade。


  • [mysql] [bug] 改进了对cymysql驱动程序的支持,支持版本0.6.5,由Hajime Nakagami提供

源码¶ T0>

  • [sqlite] [bug] The newly added SQLite DATETIME arguments storage_format and regexp apparently were not fully implemented correctly; while the arguments were accepted, in practice they would have no effect; this has been fixed.



  • [sqlite] [bug] Added sqlalchemy.types.BIGINT to the list of type names that can be reflected by the SQLite dialect; courtesy Russell Stuart.




  • [mssql] [bug] When querying the information schema on SQL Server 2000, removed a CAST call that was added in 0.8.1 to help with driver issues, which apparently is not compatible on 2000. CAST保持适用于SQL Server 2005及更高版本。



  • [mssql] [bug] [pyodbc] 使用Python 3 + pyodbc修复MSSQL,包括正确传递语句


预言¶ T0>

  • [oracle] [feature] [py3k] The Oracle unit tests with cx_oracle now pass fully under Python 3.

  • [oracle] [bug] Fixed bug where Oracle table reflection using synonyms would fail if the synonym and the table were in different remote schemas. 补丁修复Kyle Derr。



火鸟¶ T0>

  • [firebird] [feature] Added new flag retaining=True to the kinterbasdb and fdb dialects. 这将控制发送到DBAPI连接的commit()rollback()方法的retaining标志的值。由于历史原因,这个标志在0.8.2中默认为True,然而在0.9.0b1中这个标志默认为False



  • [firebird] [feature] The fdb dialect is now the default dialect when specified without a dialect qualifier, i.e. firebird://, per the Firebird project publishing fdb as their official Python driver.


  • [firebird] [bug] Type lookup when reflecting the Firebird types LONG and INT64 has been fixed so that LONG is treated as INTEGER, INT64 treated as BIGINT, unless the type has a “precision” in which case it’s treated as NUMERIC. 补丁由Russell Stuart提供。



杂项¶ T0>

  • [feature] system=True添加到Column中,将列标记为“系统”列,数据库(如Postgresql oidxmin)。该列将从CREATE TABLE语句中被省略,否则可用于查询。另外,可以通过生成返回None的规则来将CreateColumn结构应用于允许跳过列的自定义编译规则。


  • [feature] [examples] Improved the examples in examples/generic_associations, including that discriminator_on_association.py makes use of single table inheritance do the work with the “discriminator”. 还添加了一个真正的“通用外键”示例,该示例与其他流行的框架类似,因为它使用开放式整数指向任何其他表,前面提到了传统的参照完整性。虽然我们不推荐这种模式,但信息要自由。


  • [feature] [core] UpdateBase.returning()中增加了一个名为ValuesBase.return_defaults()这允许将任意列添加到语句的RETURNING子句中,而不会干扰编译器通常的“隐式返回”功能,该功能用于有效地提取新生成的主键值。为支持后端,所有获取的值的字典存在于ResultProxy.returned_defaults


  • [feature] [pool] 添加了“rollback-on-return”的池日志记录和较少使用的“commit-on-return”。这是启用其余的池“调试”日志。


  • [bug] [examples] 在版本化示例中创建的历史记录表中添加了“autoincrement = False”,因为在任何情况下,此表都不应该有autoinc,Patrick Schmid提供¶ T2>


  • [bug] [ext] Fixed bug whereby if a composite type were set up with a function instead of a class, the mutable extension would trip up when it tried to check that column for being a MutableComposite (which it isn’t). 礼貌asldevi。


  • [bug] [examples] Fixed an issue with the “versioning” recipe whereby a many-to-one reference could produce a meaningless version for the target, even though it was not changed, when backrefs were present. 补丁由Matt Chisholm提供。


  • [requirements] The Python mock library is now required in order to run the unit test suite. 虽然Python 3.3是标准库的一部分,但以前的Python安装将需要安装它,以便运行单元测试或使用外部方言的sqlalchemy.testing包。 T2>