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

SQLAlchemy 1.1文档


0.8.7 ¶ T0>


ORM ¶ T0>

  • [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. 属性/键错误的捕获已被更具体化,不包括配置步骤。


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] 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()的一致。


的PostgreSQL ¶ T0>

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


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


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.


  • [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] 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. 这个参数不需要继续。


杂项¶ T0>

  • [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

0.8.6 ¶ T0>


一般¶ T0>

  • [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是否可用,此变量都可以工作。


ORM ¶ T0>

  • [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 > *从这个模块再次工作。


SQL ¶ T0>

  • [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.


的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。


杂项¶ 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.


0.8.5 ¶ T0>


ORM ¶ T0>

  • [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] 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] 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.


发动机¶ 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 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] [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.

的PostgreSQL ¶ T0>

  • [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.


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方言的一些缺失方法,包括_get_server_version_info()和_detect_charset()。Pullreq礼貌Hajime Nakagami。


源码¶ T0>

  • [sqlite] [bug] 将唯一约束反射的backport中错过的更改还原为0.8,如果名称中包含保留关键字,则带有SQLite的UniqueConstraint列。拉请求罗马Podolyaka。



  • [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提供。


火鸟¶ 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.

杂项¶ T0>

  • [bug] [py3k] Fixed Py3K bug where a missing import would cause “literal binary” mode to fail to import “util.binary_type” when rendering a bound parameter. 0.9处理方式不同。请求Andreas Zeidler提供。


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


0.8.4 ¶ T0>


ORM ¶ T0>

  • [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.


发动机¶ T0>

  • [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它现在以与执行过程中发生的相同的方式传播。


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


  • [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中首次引入的逻辑的扩展,这个问题偶尔在压力测试中被观察到。


  • [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中,从而避免编码错误。


SQL ¶ T0>

的PostgreSQL ¶ T0>

  • [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.



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


预言¶ T0>

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


  • [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.


杂项¶ T0>

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


0.8.3 ¶ T0>


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] [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.7.11


  • [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] Backported a change from 0.9 whereby the iteration of a hierarchy of mappers used in polymorphic inheritance loads is sorted, which allows the SELECT statements generated for polymorphic queries to have deterministic rendering, which in turn helps with caching schemes that cache on the SQL string itself.


  • [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 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.

发动机¶ T0>

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


  • [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.7.11


  • [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.


SQL ¶ T0>

  • [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 ...


  • [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] [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.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.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.7.11


  • [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] 不推荐使用ForeignKey上的非工作“模式”参数;提出警告。在0.9中删除


  • [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,这是在编译器被要求编译不知道如何编译的东西时引发的。


的PostgreSQL ¶ T0>

  • [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。


MySQL的¶ T0>

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

    This change is also backported to: 0.7.11


  • [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”.


源码¶ 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.


预言¶ T0>

  • [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>

  • [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”. 还添加了一个真正的“通用外键”示例,该示例与其他流行的框架类似,因为它使用开放式整数指向任何其他表,前面提到了传统的参照完整性。虽然我们不推荐这种模式,但信息要自由。

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

0.8.2 ¶ T0>


ORM ¶ T0>

  • [orm] [feature] Added a new method Query.select_entity_from() which will in 0.9 replace part of the functionality of Query.select_from(). 在0.8中,这两个方法执行相同的功能,以便代码可以根据需要进行迁移以使用Query.select_entity_from()方法。有关详细信息,请参阅0.9迁移指南。


  • [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 a regression caused by #2682 whereby the evaluation invoked by Query.update() and Query.delete() would hit upon unsupported True and False symbols which now appear due to the usage of IS.


  • [orm] [bug] Fixed a regression from 0.7 caused by this ticket, which made the check for recursion overflow in self-referential eager joining too loose, missing a particular circumstance where a subclass had lazy=”joined” or “subquery” configured and the load was a “with_polymorphic” against the base.


  • [orm] [bug] Fixed a regression from 0.7 where the contextmanager feature of Session.begin_nested() would fail to correctly roll back the transaction when a flush error occurred, instead raising its own exception while leaving the session still pending a rollback.


orm declarative

  • [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] [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] [sybase] Fixed a bug where the routine to detect the correct kwargs being sent to create_engine() would fail in some cases, such as with the Sybase dialect.


SQL ¶ T0>

  • [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] [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] [mssql] 从这个票据返回导致不支持的关键字“true”渲染,添加逻辑将其转换为1/0为SQL服务器。¶ t2 >


的PostgreSQL ¶ T0>

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

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


  • [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。


  • [postgresql] [bug] 修正了HSTORE类型为unicode正确编码/解码。这一直是开启的,因为hstore是一个文本类型,并且在使用Python 3时匹配psycopg2的行为。礼貌德米特里Mugtasimov。


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] [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] 更新了mysqlconnector方言,根据异常中发送的明显字符串消息检查断开连接;针对mysqlconnector 1.0.9进行了测试。

源码¶ T0>

  • [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及更高版本。


火鸟¶ 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] [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>

  • [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提供。

  • [bug] [examples] Fixed a small bug in the dogpile example where the generation of SQL cache keys wasn’t applying deduping labels to the statement the same way Query normally does.

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

0.8.1 ¶ T0>


ORM ¶ T0>

  • [orm] [feature] Added a convenience method to Query that turns a query into an EXISTS subquery of the form EXISTS (SELECT 1 FROM ... WHERE ...).


  • [orm] [bug] Fixed bug when a query of the form: query(SubClass).options(subqueryload(Baseclass.attrname)), where SubClass is a joined inh of BaseClass, would fail to apply the JOIN inside the subquery on the attribute load, producing a cartesian product. 填充的结果仍然是正确的,因为额外的行被忽略,所以这个问题可能会出现性能下降,否则应用程序正常工作。

    This change is also backported to: 0.7.11


  • [orm] [bug] Fixed bug in unit of work whereby a joined-inheritance subclass could insert the row for the “sub” table before the parent table, if the two tables had no ForeignKey constraints set up between them.

    This change is also backported to: 0.7.11


  • [orm] [bug] Fixes to the sqlalchemy.ext.serializer extension, including that the “id” passed from the pickler is turned into a string to prevent against bytes being parsed on Py3K, as well as that relationship() and orm.join() constructs are now properly serialized.


  • [orm] [bug] A significant improvement to the inner workings of query.join(), such that the decisionmaking involved on how to join has been dramatically simplified. 现在,新的测试用例通过了多个连接,这些连接从已经涉及继承的已经复杂的一系列连接的中间延伸而来。从深度嵌套子查询结构中加入仍然是复杂的,并非没有警告,但是通过这些改进,边缘案例有望被推到更远的边缘。


  • [orm] [bug] Added a conditional to the unpickling process for ORM mapped objects, such that if the reference to the object were lost when the object was pickled, we don’t erroneously try to set up _sa_instance_state - fixes a NoneType error.

  • [orm] [bug] Fixed bug where many-to-many relationship with uselist=False would fail to delete the association row and raise an error if the scalar attribute were set to None. 这是由#2229


  • [orm] [bug] Improved the behavior of instance management regarding the creation of strong references within the Session; an object will no longer have an internal reference cycle created if it’s in the transient state or moves into the detached state - the strong ref is created only when the object is attached to a Session and is removed when the object is detached. 这使得一个对象拥有一个__ del __()方法更为安全,即使这不被推荐,因为与backrefs的关系也会产生循环。当带有__ del __()方法的类被映射时,警告被添加。


  • [orm] [bug] Fixed bug whereby ORM would run the wrong kind of query when refreshing an inheritance-mapped class where the superclass was mapped to a non-Table object, like a custom join() or a select(), running a query that assumed a hierarchy that’s mapped to individual Table-per-class.


  • [orm] [bug] Fixed __repr__() on mapper property constructs to work before the object is initialized, so that Sphinx builds with recent Sphinx versions can read them.

orm declarative

  • [bug] [orm] [declarative] Fixed indirect regression regarding has_inherited_table(), where since it considers the current class’ __table__, was sensitive to when it was called. 这也是0.7的行为,但是在0.7之类的事情往往在像__mapper_args__()这样的事件中“解决”。has_inherited_table()现在只考虑超类,所以无论什么时候被调用(显然假设超类的状态),都应该返回与当前类相同的答案。


SQL ¶ T0>

  • [sql] [feature] 松散地检查传递给Table()的特定于方言的参数名称;因为我们想支持外部方言,也想支持没有安装某种方言的参数,所以现在只检查参数的格式,而不是在sqlalchemy.dialects中查找那个方言。

  • [sql] [bug] [mysql] Fully implemented the IS and IS NOT operators with regards to the True/False constants. col.is_(True)这样的表达式现在将呈现col tr> IS true在目标平台上,而不是将True / False常量转换为整数绑定参数。这允许在给定True / False常量时,is_()运算符在MySQL上工作。


  • [sql] [bug] A major fix to the way in which a select() object produces labeled columns when apply_labels() is used; this mode produces a SELECT where each column is labeled as in _, to remove column name collisions for a multiple table select. 解决方法是,如果两个标签在与表名(即“foo.bar_id”和“foo_bar.id”)结合时发生冲突,匿名别名将应用于其中一个欺骗。这允许ORM独立处理两个列;以前,在某些情况下,0.7会在默认情况下为被“duped”的列发出第二个SELECT,在0.8中会发出不明确的列错误。应用于.c的“键”select()的集合也将被删除,所以“被替换的列”警告将不再发出任何指定use_labels的select(),尽管这个dupe键会被赋予一个匿名标签,友好。¶ T0>


  • [sql] [bug] Fixed bug where disconnect detect on error would raise an attribute error if the error were being raised after the Connection object had already been closed.


  • [sql] [bug] Reworked internal exception raises that emit a rollback() before re-raising, so that the stack trace is preserved from sys.exc_info() before entering the rollback. 这样当使用在回滚函数返回之前可能已经切换上下文的协程框架时,回溯被保留。


  • [sql] [bug] [postgresql] The _Binary base type now converts values through the bytes() callable when run on Python 3; in particular psycopg2 2.5 with Python 3.3 seems to now be returning the “memoryview” type, so this is converted to bytes before return.

  • [sql] [bug] 改进了连接自动失效处理。如果发生非断开连接错误,但会导致错误处理中的延迟断开连接错误(发生在MySQL上),则检测到断开连接条件。Connection现在也可以在处于无效状态时被关闭,这意味着在下次使用时它会提高“关闭”,另外,即使错误处理例程中的自动回退失败,并且“close with result”条件是否断开。


  • [sql] [bug] Fixed bug whereby a DBAPI that can return “0” for cursor.lastrowid would not function correctly in conjunction with ResultProxy.inserted_primary_key.

的PostgreSQL ¶ T0>

  • [postgresql] [bug] 打开psycopg2 / libpq的“disconnect”检查,检查完整的异常层次结构中的所有“disconnect”消息。具体来说,现在已经在至少三种不同的异常类型中看到“意外关闭连接”消息。礼貌Eli Collins。


  • [postgresql] [bug] Postgresql ARRAY类型的运算符支持输入类型的集合,生成器等。即使未指定维度,也可以无条件地将给定的迭代转换为集合。


  • [postgresql] [bug] 添加缺少HSTORE类型到postgresql类型名称,以便可以反映类型。


MySQL的¶ T0>

  • [mysql] [bug] 修复了最新的cymysql DBAPI,由Hajime Nakagami提供

  • [mysql] [bug] 改进了Python 3中pymysql方言的操作,包括一些重要的解码/字节步骤。由于驱动程序问题,BLOB类型仍然存在问题。礼貌Ben Trofatter。


  • [mysql] [bug] 更新了正则表达式,以正确提取谷歌应用程序引擎v1.7.5和更新的错误代码。礼貌Dan Ring。


  • [mssql] [bug] Part of a longer series of fixes needed for pyodbc+ mssql, a CAST to NVARCHAR(max) has been added to the bound parameter for the table name and schema name in all information schema queries to avoid the issue of comparing NVARCHAR to NTEXT, which seems to be rejected by the ODBC driver in some cases, such as FreeTDS (0.91 only?) 加上传递的unicode绑定参数。这个问题似乎是特定于SQL Server信息模式表的,对于那些问题不存在的情况,解决方法是无害的。


  • [mssql] [bug] 增加了对pymssql方言附加“断开”消息的支持。John Anderson提供。

  • [mssql] [bug] Fixed Py3K bug regarding “binary” types and pymssql. 感谢Marc Abramowitz。


杂项¶ T0>

  • [bug] [examples] 修正了缓存示例中长期存在的一个bug,在计算缓存密钥时,不会考虑limit / offset参数值。_key_from_query()函数被简化为直接从最终的编译语句开始工作,以便获得完整语句以及完全处理的参数列表。

0.8.0 ¶ T0>


ORM ¶ T0>

  • [orm] [feature] A meaningful QueryableAttribute.info attribute is added, which proxies down to the .info attribute on either the schema.Column object if directly present, or the MapperProperty otherwise. 完整的行为被记录下来,并通过测试来保证它们保持稳定。


  • [orm] [feature] 可以在relationship()构造已经构建之后设置/更改“级联”属性。这不是正常使用的模式,但我们希望在教程中改变设置以便演示。

  • [orm] [feature] Added new helper function was_deleted(), returns True if the given object was the subject of a Session.delete() operation.


  • [orm] [feature] Extended the Runtime Inspection API system so that all Python descriptors associated with the ORM or its extensions can be retrieved. 这满足了除了诸如hybrid_propertyAssociationProxy之类的扩展类型之外还能够检查所有QueryableAttribute描述符的通常要求。参见Mapper.all_orm_descriptors

  • [orm] [removed] The undocumented (and hopefully unused) system of producing custom collections using an __instrumentation__ datastructure associated with the collection has been removed, as this was a complex and untested feature which was also essentially redundant versus the decorator approach. 其他内部简化到orm.collections模块也已经完成。

  • [orm] [bug] 改进了在映射器配置期间检查现有的backref名称冲突;现在将测试超类和子类名称冲突,除了当前的映射器,因为这些冲突同样破坏了事物。这是0.8的新功能,但请参阅下面的警告,也会在0.7.11中触发。


  • [orm] [bug] Improved the error message emitted when a “backref loop” is detected, that is when an attribute event triggers a bidirectional assignment between two other attributes with no end. 这种情况不仅发生在分配了错误类型的对象时,而且当属性被错误地配置为反向引用到现有的后向对中时也会发生。也在0.7.11.


  • [orm] [bug] A warning is emitted when a MapperProperty is assigned to a mapper that replaces an existing property, if the properties in question aren’t plain column-based properties. 关系属性的替换很少(从来没有?)意图是什么,通常是指映射器的错误配置。也在0.7.11.


  • [orm] [bug] A clear error message is emitted if an event handler attempts to emit SQL on a Session within the after_commit() handler, where there is not a viable transaction in progress.


  • [orm] [bug] 在级联自然主键更新的过程中检测到主键更改将会成功,即使键是复合的并且只有一些属性发生更改¶ T2>


  • [orm] [bug] 事务被提交之后,从会话中删除的对象将完全与该会话关联,即object_session()函数将返回None。


  • [orm] [bug] Fixed bug whereby Query.yield_per() would set the execution options incorrectly, thereby breaking subsequent usage of the Query.execution_options() method. 礼貌Ryan Kelly。


  • [orm] [bug] Fixed the consideration of the between() operator so that it works correctly with the new relationship local/remote system.


  • [orm] [bug] the consideration of a pending object as an “orphan” has been modified to more closely match the behavior as that of persistent objects, which is that the object is expunged from the Session as soon as it is de-associated from any of its orphan-enabled parents. 以前,挂起的对象只有在与所有孤立启用父项关联的情况下才会被清除。新标志legacy_is_orphan被添加到orm.mapper()中,以重新建立传统行为。

    请参阅The consideration of a “pending” object as an “orphan” has been made more aggressive,以便详细讨论此更改。


  • [orm] [bug] Fixed the (most likely never used) “@collection.link” collection method, which fires off each time the collection is associated or de-associated with a mapped object - the decorator was not tested or functional. 装饰器方法现在被命名为collection.linker(),尽管名称“link”保持向后兼容。礼貌Luca Wehrstedt。


  • [orm] [bug] Made some fixes to the system of producing custom instrumented collections, mainly that the usage of the @collection decorators will now honor the __mro__ of the given class, applying the logic of the sub-most classes’ version of a particular collection method. 以前,当对一个现有的工具类(如MappedCollection)进行子类化时,无论自定义方法是否能正确解析,都是不可预测的。


  • [orm] [bug] Fixed potential memory leak which could occur if an arbitrary number of sessionmaker objects were created. 由sessionmaker创建的匿名子类在被解除引用时不会被垃圾收集,因为事件包中剩余的类级引用。此问题也适用于任何使用ad-hoc子类与事件分派器结合使用的自定义系统。也在0.7.10.


  • [orm] [bug] Query.merge_result() can now load rows from an outer join where an entity may be None without throwing an error. 也在0.7.10.


  • [orm] [bug] Fixes to the “dynamic” loader on relationship(), includes that backrefs will work properly even when autoflush is disabled, history events are more accurate in scenarios where multiple add/remove of the same object occurs.


SQL ¶ T0>

  • [sql] [feature] Added a new argument to Enum and its base SchemaType inherit_schema. When set to True, the type will set its schema attribute of that of the Table to which it is associated. 这也发生在Table.tometadata()操作中;当Table.tometadata()发生时,SchemaType现在被复制,如果inherit_schema=True,类型将采用新模式名称传递给方法。The schema is important when used with the Postgresql backend, as the type results in a CREATE TYPE statement.


  • [sql] [feature] Index now supports arbitrary SQL expressions and/or functions, in addition to straight columns. Common modifiers include using somecolumn.desc() for a descending index and func.lower(somecolumn) for a case-insensitive index, depending on the capabilities of the target backend.


  • [sql] [bug] The behavior of SELECT correlation has been improved such that the Select.correlate() and Select.correlate_except() methods, as well as their ORM analogues, will still retain “auto-correlation” behavior in that the FROM clause is modified only if the output would be legal SQL; that is, the FROM clause is left intact if the correlated SELECT is not used in the context of an enclosing SELECT inside of the WHERE, columns, or HAVING clause. 这两种方法现在只是将条件指定为默认的“自动关联”,而不是绝对的FROM列表。


  • [sql] [bug] Fixed a bug regarding column annotations which in particular could impact some usages of the new orm.remote() and orm.local() annotation functions, where annotations could be lost when the column were used in a subsequent expression.


  • [sql] [bug] The ColumnOperators.in_() operator will now coerce values of None to null().


  • [sql] [bug] Fixed bug where Table.tometadata() would fail if a Column had both a foreign key as well as an alternate ”.key” name for the column. 也在0.7.10.


  • [sql] [bug] insert().returning() raises an informative CompileError if attempted to compile on a dialect that doesn’t support RETURNING.


  • [sql] [bug] Tweaked the “REQUIRED” symbol used by the compiler to identify INSERT/UPDATE bound parameters that need to be passed, so that it’s more easily identifiable when writing custom bind-handling code.


架构¶ T0>

的PostgreSQL ¶ T0>

  • [postgresql] [feature] Added support for Postgresql’s traditional SUBSTRING function syntax, renders as “SUBSTRING(x FROM y FOR z)” when regular func.substring() is used. Courtesy GunnlaugurÞórBriem。

    This change is also backported to: 0.7.11


  • 添加了postgresql.ARRAY.Comparator.any()postgresql.ARRAY.Comparator.all()方法,作为[postgresql] [feature] 非常感谢AudriusKažukauskas在这里的出色工作。

  • [postgresql] [bug] Fixed bug in array() construct whereby using it inside of an expression.insert() construct would produce an error regarding a parameter issue in the self_group() method.

MySQL的¶ T0>

  • [mysql] [feature] 添加了CyMySQL的新方言,由Hajime Nakagami提供

  • [mysql] [feature] GAE方言现在接受URL中的用户名/密码参数,由Owen Nelson提供

  • [mysql] [bug] [gae] Added a conditional import to the gaerdbms dialect which attempts to import rdbms_apiproxy vs. rdbms_googleapi to work on both dev and production platforms. 现在也尊重instance属性。礼貌肖恩林奇。也在0.7.10.


  • [mysql] [bug] 如果错误代码不能从异常抛出中提取,GAE方言将不会失败。礼貌Owen Nelson。


  • [mssql] [feature] Added mssql_include and mssql_clustered options to Index, renders the INCLUDE and CLUSTERED keywords, respectively. Courtesy Derek Harland。

  • [mssql] [feature] DDL for IDENTITY columns is now supported on non-primary key columns, by establishing a Sequence construct on any integer column. Courtesy Derek Harland。


  • [mssql] [bug] Added a py3K conditional around unnecessary .decode() call in mssql information schema, fixes reflection in Py3K. 也在0.7.10.


  • [mssql] [bug] Fixed a regression whereby the “collation” parameter of the character types CHAR, NCHAR, etc. 停止工作,因为基本字符串类型现在支持“归类”。MSSQL方言中的TEXT,NCHAR,CHAR,VARCHAR类型现在是基本类型的同义词。

预言¶ T0>

  • [oracle] [bug] cx_oracle方言将不再通过encode()运行绑定参数名称,因为这在Python 3中是无效的,并且阻止了语句的运行正确的Python 3。我们现在只在supports_unicode_binds为False的情况下进行编码,至少在使用cx_oracle的版本5时cx_oracle不是这种情况。

杂项¶ T0>

  • [bug] [tests] 修正了在某些linux平台上无法正常工作的test_execute导入“logging”的问题。也在0.7.11.


  • [bug] [examples] Fixed a regression in the examples/dogpile_caching example which was due to the change in #2614.

0.8.0b2 ¶ T0>


ORM ¶ T0>

  • [orm] [feature] Added KeyedTuple._asdict() and KeyedTuple._fields to the KeyedTuple class to provide some degree of compatibility with the Python standard library collections.namedtuple().


  • [orm] [feature] 在定义关系的主要和次要连接时允许使用同义词。

  • [orm] [feature] [extensions] The sqlalchemy.ext.mutable extension now includes the example MutableDict class as part of the extension.

  • [orm] [bug] The Query.select_from() method can now be used with a aliased() construct without it interfering with the entities being selected. 基本上这样的陈述:

    ua = aliased(User)
    session.query(User.name).select_from(ua).join(User, User.name > ua.name)

    将维护SELECT的列子句作为来自未指定的“用户”,如指定; select_from只发生在FROM子句中:

    SELECT users.name AS users_name FROM users AS users_1
    JOIN users ON users.name < users_1.name


      select_from(user_table.select().where(user_table.c.id > 5))


    SELECT anon_1.name AS anon_1_name FROM (SELECT users.id AS id,
    users.name AS name FROM users WHERE users.id > :id_1) AS anon_1



  • [orm] [bug] The MutableComposite type did not allow for the MutableBase.coerce() method to be used, even though the code seemed to indicate this intent, so this now works and a brief example is added. 作为一个副作用,这个事件处理程序的机制已经被改变,所以新的MutableComposite类型不再添加每个类型的全局事件处理程序。也在0.7.10.


  • [orm] [bug] A second overhaul of aliasing/internal pathing mechanics now allows two subclasses to have different relationships of the same name, supported with subquery or joined eager loading on both simultaneously when a full polymorphic load is used.


  • [orm] [bug] Fixed bug whereby a multi-hop subqueryload within a particular with_polymorphic load would produce a KeyError. 利用与#2614相同的内部路径检修。


  • [orm] [bug] Fixed regression where query.update() would produce an error if an object matched by the “fetch” synchronization strategy wasn’t locally present. 感谢Scott Torborg。


发动机¶ T0>

SQL ¶ T0>

  • [sql] [feature] The Insert construct now supports multi-valued inserts, that is, an INSERT that renders like “INSERT INTO table VALUES (...), (...), ...”. 由Postgresql,SQLite和MySQL支持。非常感谢Idan Kamara在这一项上做了修改。


  • [sql] [bug] Fixed bug where using server_onupdate= without passing the “for_update=True” flag would apply the default object to the server_default, blowing away whatever was there. 显式的for_update = True参数不应该被这个用法需要(特别是因为文档显示了一个没有被使用的例子),所以现在使用给定的默认对象的副本在内部安排,如果标志没有被设置为什么对应于这个参数。

    This change is also backported to: 0.7.10


  • [sql] [bug] Fixed a regression caused by #2410 whereby a CheckConstraint would apply itself back to the original table during a Table.tometadata() operation, as it would parse the SQL expression for a parent table. 该操作现在复制给定的表达式以对应于新的表。


  • [sql] [bug] Fixed bug whereby using a label_length on dialect that was smaller than the size of actual column identifiers would fail to render the columns correctly in a SELECT statement.


  • [sql] [bug] The DECIMAL type now honors the “precision” and “scale” arguments when rendering DDL.


  • [sql] [bug] Made an adjustment to the “boolean”, (i.e. __nonzero__) evaluation of binary expressions, i.e. x1 == x2, such that the “auto-grouping” applied by BinaryExpression in some cases won’t get in the way of this comparison. 以前,表达式如下:

    expr1 = mycolumn > 2
    bool(expr1 == expr1)

    Would evaluate as False, even though this is an identity comparison, because mycolumn > 2 would be “grouped” before being placed into the BinaryExpression, thus changing its identity. BinaryExpression now keeps track of the “original” objects passed in. Additionally the __nonzero__ method now only returns if the operator is == or != - all others raise TypeError.


  • [sql] [bug] Fixed a gotcha where inadvertently calling list() on a ColumnElement would go into an endless loop, if ColumnOperators.__getitem__() were implemented. 一个新的NotImplementedError通过__iter__()发出。

  • [sql] [bug] Fixed bug in type_coerce() whereby typing information could be lost if the statement were used as a subquery inside of another statement, as well as other similar situations. 除此之外,当Oracle / mssql方言应用限制/偏移量包装时,会导致输入信息丢失。


  • [sql] [bug] Fixed bug whereby the ”.key” of a Column wasn’t being used when producing a “proxy” of the column against a selectable. 这在0.7中可能不会发生,因为0.7在更广泛的场景中并不尊重“.key”。


的PostgreSQL ¶ T0>

  • [postgresql] [feature] HSTORE is now available in the Postgresql dialect. 如果可用,也将使用psycopg2的扩展。Courtesy AudriusKažukauskas。


源码¶ T0>

  • [sqlite] [bug] More adjustment to this SQLite related issue which was released in 0.7.9, to intercept legacy SQLite quoting characters when reflecting foreign keys. 除了截取双引号外,其他引号字符(如括号,反引号和单引号)现在也被拦截。

    This change is also backported to: 0.7.10



  • [mssql] [feature] 支持反射主键约束的“名称”,由Dave Moore提供


  • [mssql] [bug] Fixed bug whereby using “key” with Column in conjunction with “schema” for the owning Table would fail to locate result rows due to the MSSQL dialect’s “schema rendering” logic’s failure to take .key into account.

    This change is also backported to: 0.7.10

预言¶ T0>

  • [oracle] [bug] Fixed table reflection for Oracle when accessing a synonym that refers to a DBLINK remote database; while the syntax has been present in the Oracle dialect for some time, up until now it has never been tested. 该语法已经针对链接到自身的示例数据库进行了测试,但是在查询远程数据库查询表信息时,对于“所有者”应该使用什么还有一些不确定性。目前,来自user_db_links的“用户名”的值被用于匹配“所有者”。


  • [oracle] [bug] The Oracle LONG type, while an unbounded text type, does not appear to use the cx_Oracle.LOB type when result rows are returned, so the dialect has been repaired to exclude LONG from having cx_Oracle.LOB filtering applied. 也在0.7.10.


  • [oracle] [bug] Repaired the usage of .prepare() in conjunction with cx_Oracle so that a return value of False will result in no call to connection.commit(), hence avoiding “no transaction” errors. 现在,两阶段事务已经被证明可以用SQLAlchemy和cx_oracle这种基本的方式工作,但是在驱动程序中却要注意一些警告。检查文档的细节。也在0.7.10.


火鸟¶ T0>

  • [firebird] [bug] 在实验性的“firebird + fdb”方言中添加了“fdb”缺少的导入。


杂项¶ T0>

  • [feature] [sybase] 反射支持已被添加到Sybase方言中。非常感谢Ben Trofatter所有的开发和测试工作。


  • [feature] [pool] The Pool will now log all connection.close() operations equally, including closes which occur for invalidated connections, detached connections, and connections beyond the pool capacity.

  • [feature] [pool] The Pool now consults the Dialect for functionality regarding how the connection should be “auto rolled back”, as well as closed. 这使得对方言的事务范围有了更多的控制,所以我们能够更好地实现像pysqlite和cx_oracle那样可能需要的事务变通方法。


  • [feature] [pool] Added new PoolEvents.reset() hook to capture the event before a connection is auto-rolled back, upon return to the pool. ConnectionEvents.rollback()一起,这允许拦截所有的回滚事件。

  • [informix] Some cruft regarding informix transaction handling has been removed, including a feature that would skip calling commit()/rollback() as well as some hardcoded isolation level assumptions on begin().. 由于我们没有任何用户使用它,也没有任何对Informix数据库的访问,所以这种方言的地位还没有很好的理解。如果有人访问Informix想要帮助测试这个方言,请告诉我们。

0.8.0b1 ¶ T0>


一般¶ T0>

  • [general] [removed] “sqlalchemy.exceptions”的同义词“sqlalchemy.exc”被完全删除。


  • [general] SQLAlchemy 0.8现在的目标是Python 2.5及以上版本。Python 2.4不再支持。

ORM ¶ T0>

  • [orm] [feature] Major rewrite of relationship() internals now allow join conditions which include columns pointing to themselves within composite foreign keys. 添加了一个用于非常专业的主要连接条件的新API,允许基于SQL函数,CAST等的条件。通过在注释表达式中将注释函数remote()和foreign()嵌入到表达式中进行处理。以前使用半私人_local_remote_pairs方法的食谱可以升级到这种新方法。


  • [orm] [feature] New standalone function with_polymorphic() provides the functionality of query.with_polymorphic() in a standalone form. 它可以应用于查询中的任何实体,包括作为“of_type()”修饰符的连接目标。


  • [orm] [feature] The of_type() construct on attributes now accepts aliased() class constructs as well as with_polymorphic constructs, and works with query.join(), any(), has(), and also eager loaders subqueryload(), joinedload(), contains_eager()


  • [orm] [feature] 对映射类进行事件监听的改进允许为实例和映射器事件指定未映射的类。当propagate = True标志被传递时,已建立的事件将自动建立在该类的子类上,并且如果它最终被映射的话,事件将被设置为该类本身。


  • [orm] [feature] 使用新的DeferredReflection类,“延迟声明性反射”系统已经移入声明性扩展本身。这个类现在用单个和联合表继承用例进行测试。


  • [orm] [feature] Added new core function “inspect()”, which serves as a generic gateway to introspection into mappers, objects, others. Mapper和InstanceState对象已经使用公共API进行了增强,允许检查映射的属性,包括列绑定或关系绑定属性的过滤器,当前对象状态的检查,属性的历史记录等。 t0 >


  • [orm] [feature] Calling rollback() within a session.begin_nested() will now only expire those objects that had net changes within the scope of that transaction, that is objects which were dirty or were modified on a flush. 这就允许begin_nested()的典型用例,即修改一小部分对象的子对象,从那些在该子事务中没有被修改的更大的封闭对象集中留下数据。 T0>


  • [orm] [feature] Added utility feature Session.enable_relationship_loading(), supersedes relationship.load_on_pending. 但是,这两个功能都应该避免。


  • [orm] [feature] 增加了对column_property(),relationship(),composite()的.info字典参数的支持。所有的MapperProperty类都有一个自动创建的.info字典。

  • [orm] [feature] 现在,从映射集合中添加/删除无将生成属性事件。以前,在某些情况下,无追加将被忽略。与。相关


  • [orm] [feature] 在映射集合中存在None现在在刷新期间引发错误。以前,集合中的None值将被忽略。


  • [orm] [feature] The Query.update() method is now more lenient as to the table being updated. Plain Table对象现在得到了更好的支持,并且可以使用update()方法使用附加的继承子类。子类表将成为更新的目标,如果在WHERE子句中引用父表,则编译器将调用UPDATE..FROM语法,如方言所允许的,以满足WHERE子句。MySQL的多表更新功能也受支持,如果列是由“价值”dicitionary对象指定的。PG的DELETE.USING在Core中也不可用。

  • [orm] [feature] New session events after_transaction_create and after_transaction_end allows tracking of new SessionTransaction objects. 如果对象被检查,可以用来确定一个会话何时首先变为活动状态以及何时停用。

  • [orm] [feature] The Query can now load entity/scalar-mixed “tuple” rows that contain types which aren’t hashable, by setting the flag “hashable=False” on the corresponding TypeEngine object in use. 返回不可互换类型(通常为列表)的自定义类型可以将此标志设置为False。


  • [orm] [feature] Query now “auto correlates” by default in the same way as select() does. 以前,在另一个查询中用作子查询将需要显式调用correlate()方法,以将内部表与外部关联起来。一如往常,关联(None)禁用关联。


  • [orm] [feature] The after_attach event is now emitted after the object is established in Session.new or Session.identity_map upon Session.add(), Session.merge(), etc., so that the object is represented in these collections when the event is called. 添加before_attach事件以适应需要自动刷新预连接对象的用例。


  • [orm] [feature] The Session will produce warnings when unsupported methods are used inside the “execute” portion of the flush. 这些是熟悉的方法add(),delete()等以及像在after_insert(),after_update()等mapper级别的刷新事件中调用的集合和相关对象操作。很长一段时间,SQLAlchemy不能保证在执行flush计划的Session时保证结果,但是用户仍在使用它,所以现在有一个警告。也许有一天会话会被增强,以支持这些在flush内部的操作,但现在,结果不能得到保证。

  • [orm] [feature] ORM entities can be passed to the core select() construct as well as to the select_from(), correlate(), and correlate_except() methods of select(), where they will be unwrapped into selectables.


  • [orm] [feature] 支持基于映射属性自动呈现关系连接条件,并使用核心SQL构造。例如。 select(SomeClass)),其中(SomeClass.somerelationship)将从“someclass”呈现SELECT,并使用“somerelationship”的主要连接作为WHERE子句。当在核心SQL上下文中使用时,这改变了“SomeClass.somerelationship”的以前的含义;以前,它会“解决”到父母选择,这通常不是有用的。也适用于query.filter()。与。相关


  • [orm] [feature] The registry of classes in declarative_base() is now a WeakValueDictionary. 因此,被取消引用的“Base”的子类将被垃圾收集,如果它们没有被其他mappers / superclass mappers引用,那么就是请参阅此票证的下一个注释。


  • [orm] [feature] Conflicts between columns on single-inheritance declarative subclasses, with or without using a mixin, can be resolved using a new @declared_attr usage described in the documentation.


  • [orm] [feature] declared_attr现在可以在非mixin类上使用,即使这通常只对单继承子类的列冲突解决有用


  • [orm] [feature] declared_attr can now be used with attributes that are not Column or MapperProperty; including any user-defined value as well as association proxy objects.


  • [orm] [feature] Very limited support for inheriting mappers to be GC’ed when the class itself is deferenced. 映射器不能有其自己的表(即只有单个表inh),没有多态属性。这允许创建声明性映射类的临时子类的用例,在没有表或映射指令的情况下,通过单元测试解除引用时,垃圾回收。


  • [orm] [feature] Declarative now maintains a registry of classes by string name as well as by full module-qualified name. 现在可以根据relationship()中的模块限定字符串来查找多个具有相同名称的类。简单的类名称查找,其中多个类共享相同的名称现在引发一个信息错误消息


  • [orm] [feature] 现在可以提供覆盖任何非ORM类型列的类绑定属性,而不仅仅是描述符。


  • [orm] [feature] Added with_labels and reduce_columns keyword arguments to Query.subquery(), to provide two alternate strategies for producing queries with uniquely- named columns. ¶ T0>


  • [orm] [feature] 由于过期/属性刷新/收集替换而导致对已插装的集合的引用不再与父类关联时发出警告,但接收到附加或删除操作在现在分离的集合上。


  • [orm] [removed] The legacy “mutable” system of the ORM, including the MutableType class as well as the mutable=True flag on PickleType and postgresql.ARRAY has been removed. ORM使用0.7中引入的sqlalchemy.ext.mutable扩展来检测就地突变。删除MutableType和相关的结构从SQLAlchemy的内部消除了很大的复杂性。这个方法表现不佳,因为它会在使用时扫描整个Session的内容。


  • [orm] [removed] 已删除的标识符已被删除:

    • allow_null_pks mapper()参数(使用allow_partial_pks)
    • _get_col_to_prop()映射器方法(使用get_property_by_column())
    • Session.merge()的dont_load参数(使用load = True)
    • sqlalchemy.orm.shard模块(使用sqlalchemy.ext.horizo​​ntal_shard)

  • [orm] [bug] ORM will perform extra effort to determine that an FK dependency between two tables is not significant during flush if the tables are related via joined inheritance and the FK dependency is not part of the inherit_condition, saves the user a use_alter directive.


  • [orm] [bug] 以前,无论传递的“target”参数是什么,都会分配一个事件监听器来监听所有的类。


  • [orm] [bug] with_polymorphic() produces JOINs in the correct order and with correct inheriting tables in the case of sending multi-level subclasses in an arbitrary order or with intermediary classes missing.


  • [orm] [bug] Improvements to joined/subquery eager loading dealing with chains of subclass entities sharing a common base, with no specific “join depth” provided. 在检测到一个“循环”之前,会分别链接到每个子类映射器,而不是将基类视为“循环”的源。


  • [orm] [bug] Session.is_modified()上的“被动”标志不再有任何作用。在任何情况下,is_modified()都只会查看本地内存中已修改的标志,不会发出任何SQL或调用加载程序可调用/初始化程序。


  • [orm] [bug] The warning emitted when using delete-orphan cascade with one-to-many or many-to-many without single-parent=True is now an error. 在任何情况下,ORM将无法在此警告之后运行。


  • [orm] [bug] Lazy loads emitted within flush events such as before_flush(), before_update(), etc. 现在将像在非事件代码中那样起作用,考虑在惰性发射查询中使用的PK / FK值。以前,特殊的标志将被建立,这将导致延迟加载基于父PK / FK值的“先前”值载入相关项目,特别是当在刷新内被调用时;以这种方式加载的信号现在被本地化到工作单元实际需要以这种方式加载的地方。请注意,UOW有时会在before_update()事件被调用之前加载这些集合,因此,“passive_updates”的使用与否可能会影响集合是否代表“旧”或“新”数据,刷新事件,基于何时发生延迟加载。用户事件代码依赖于旧行为的机会极小,这种变化是不可逆转的。


  • [orm] [bug] Continuing regarding extra state post-flush due to event listeners; any states that are marked as “dirty” from an attribute perspective, usually via column-attribute set events within after_insert(), after_update(), etc., will get the “history” flag reset in all cases, instead of only those instances that were part of the flush. 这样做的结果是这个“脏”状态不会在flush之后继续,并且不会导致UPDATE语句。为此发出警告;可以使用set_committed_state()方法在对象上分配属性而不产生历史事件。


  • [orm] [bug] Fixed a disconnect that slowly evolved between a @declared_attr Column and a directly-defined Column on a mixin. 在这两种情况下,列将被应用到声明的类表中,但不会被应用到已连接的继承子类中。以前,直接定义的列将被放置在基本表和子表上,这通常不是我们想要的。


  • [orm] [bug] Declarative can now propagate a column declared on a single-table inheritance subclass up to the parent class’ table, when the parent class is itself mapped to a join() or select() statement, directly or via joined inheritance, and not just a Table.


  • [orm] [bug] 当uselist = False与“动态”加载器结合时会发出错误。这是0.7.9中的一个警告。

  • [orm] [moved] The InstrumentationManager interface and the entire related system of alternate class implementation is now moved out to sqlalchemy.ext.instrumentation. 这是一个很少使用的系统,它增加了类仪器机制的复杂性和开销。新的体系结构允许它在InstrumentationManager实际导入之前保持未使用状态,此时它将被引导到内核中。

发动机¶ T0>

  • [engine] [feature] Connection event listeners can now be associated with individual Connection objects, not just Engine objects.


  • [engine] [feature] The before_cursor_execute event fires off for so-called “_cursor_execute” events, which are usually special-case executions of primary-key bound sequences and default-generation SQL phrases that invoke separately when RETURNING is not used with INSERT.


  • [engine] [feature] 测试套件所使用的库已经被移动了一些,以便它们再次成为SQLAlchemy安装的一部分。另外,在新的sqlalchemy.testing.suite包中提供了一套新的测试。这是一个开发不足的系统,希望为外部方言提供一个通用的测试套件。在SQLAlchemy之外维护的方言可以使用新的测试夹具作为自己的测试框架,并且可以免费获得一套“合规性”的方言集中测试,包括改进的“需求”系统,其中特定的功能和特性可以启用或禁用测试。

  • [engine] [feature] 增加了一个新的系统,用于在线注册新的方言而不使用入口点。请参阅“注册新方言”的文档。


  • [engine] [feature] 如果没有传递“value”或“callable”参数,则“required”标志默认设置为True,如果没有显式传递,则在bindparam()上。这将导致语句执行检查绑定参数的最终集合中存在的参数,而不是隐式地分配None。


  • [engine] [feature] Various API tweaks to the “dialect” API to better support highly specialized systems such as the Akiban database, including more hooks to allow an execution context to access type processors.

  • [engine] [feature] Inspector.get_primary_keys() is deprecated; use Inspector.get_pk_constraint(). 礼貌戴安娜克拉克。


  • [engine] [feature] 新增了C扩展模块“utils”,用于额外的功能加速,因为我们有时间实现。

  • [engine] [bug] The Inspector.get_table_names() order_by=”foreign_key” feature now sorts tables by dependee first, to be consistent with util.sort_tables and metadata.sorted_tables.

  • [engine] [bug] Fixed bug whereby if a database restart affected multiple connections, each connection would individually invoke a new disposal of the pool, even though only one disposal is needed.


  • [engine] [bug] .c中的列名称。对于那些明确命名为.key的列,apply_labels()现在基于_ 而不是_ T3> T2> T1> T0>


  • [engine] [bug] The autoload_replace flag on Table, when False, will cause any reflected foreign key constraints which refer to already-declared columns to be skipped, assuming that the in-Python declared column will take over the task of specifying in-Python ForeignKey or ForeignKeyConstraint declarations.

  • [engine] [bug] The ResultProxy methods inserted_primary_key, last_updated_params(), last_inserted_params(), postfetch_cols(), prefetch_cols() all assert that the given statement is a compiled construct, and is an insert() or update() statement as is appropriate, else raise InvalidRequestError.


  • [engine] ResultProxy.last_inserted_ids被移除,替换为inserted_primary_key

SQL ¶ T0>

  • [sql] [feature] 添加了一个新的方法Engine.execution_options()Engine这个方法与Connection.execution_options()类似,它创建了一个父对象的副本,它将引用新的选项集。该方法可用于构建分片方案,其中每个引擎共享相同的基础连接池。该方法已经在ORM中针对水平碎片配方进行了测试。

  • [sql] [feature] Major rework of operator system in Core, to allow redefinition of existing operators as well as addition of new operators at the type level. 新的类型可以从现有的类型创建,添加或重新定义将输出到列表达式的操作,类似于ORM如何允许comparator_factory。新的体系结构把这个功能移到了Core中,这样它就可以在所有情况下一致地使用,使用现有的类型传播行为干净地传播。


  • [sql] [feature] To complement, types can now provide “bind expressions” and “column expressions” which allow compile-time injection of SQL expressions into statements on a per-column or per-bind level. 这是为了适应需要在SQL级别增加绑定和结果行为的类型的用例,而不是在Python级别。允许透明加密/解密,使用Postgis函数等。


  • [sql] [feature] The Core oeprator system now includes the getitem operator, i.e. the bracket operator in Python. 这首先用于为Postgresql ARRAY类型提供索引和切片行为,还为定制__getitem__方案的最终用户定义提供了一个钩子,可以在类型级别以及在ORM级别的自定义运算符方案中应用这些方案。lshift (<<) and rshift (>>) are also supported as optional operators.


  • [sql] [feature] Revised the rules used to determine the operator precedence for the user-defined operator, i.e. that granted using the op() method. 以前,在所有情况下都应用了最小的优先级,现在默认优先级为零,低于除“逗号”以外的所有运算符(例如,在func调用的参数列表中使用)和“AS “,也可以通过op()方法的”precedence“参数进行定制。


  • [sql] [feature] 将“排序规则”参数添加到所有字符串类型。当存在时,呈现为COLLATE 。 T0>这支持COLLATE关键字现在支持包括MySQL,SQLite和Postgresql在内的数据库。


  • [sql] [feature] Custom unary operators can now be used by combining operators.custom_op() with UnaryExpression().

  • [sql] [feature] Enhanced GenericFunction and func. *允许通过func使用用户定义的GenericFunction子类。*名称空间自动按类名,可选地使用一个包名称,以及能够使得被渲染的名称与func中识别的名称不同。* ¶ T0>

  • [sql] [feature] The cast() and extract() constructs will now be produced via the func. *访问者,因为用户自然会尝试从func访问这些名称。*尽管返回的对象不是FunctionElement,他们也可以做预期的事情。


  • 现在可以使用新的inspect()服务来获取Inspector对象,它是的一部分。[sql] [feature]


  • [sql] [feature] The column_reflect event now accepts the Inspector object as the first argument, preceding “table”. 使用这个新事件的0.7版本的代码将需要修改以添加“检查器”对象作为第一个参数。


  • [sql] [feature] 默认情况下,结果集中列定位的行为现在是区分大小写的。SQLAlchemy多年来会对这些值执行不区分大小写的转换,可能会缓解Oracle和Firebird等方言早期的大小写敏感问题。这些问题已经在更现代的版本中得到了更清晰的解决,所以在标识符上调用lower()的性能降低了。不区分大小写的比较可以通过在create_engine()上设置“case_insensitive = False”来重新启用。


  • [sql] [feature] The “unconsumed column names” warning emitted when keys are present in insert.values() or update.values() that aren’t in the target table is now an exception.


  • [sql] [feature] 将“MATCH”子句添加到ForeignKey,ForeignKeyConstraint,礼貌Ryan Kelly。


  • [sql] [feature] 增加了对一个表的别名的DELETE和UPDATE的支持,假定这个表的别名与查询中的其他地方相关,Ryan Kelly提供。


  • [sql] [feature] select() features a correlate_except() method, auto correlates all selectables except those passed.

  • [sql] [feature] The prefix_with() method is now available on each of select(), insert(), update(), delete(), all with the same API, accepting multiple prefix calls, as well as a “dialect name” so that the prefix can be limited to one kind of dialect.


  • [sql] [feature] Added reduce_columns() method to select() construct, replaces columns inline using the util.reduce_columns utility function to remove equivalent columns. reduce_columns()还增加了“with_only_synonyms”,以限制只有那些具有相同名称的列。弃用的fold_equivalents()功能被删除。


  • [sql] [feature] Reworked the startswith(), endswith(), contains() operators to do a better job with negation (NOT LIKE), and also to assemble them at compilation time so that their rendered SQL can be altered, such as in the case for Firebird STARTING WITH


  • [sql] [feature] Added a hook to the system of rendering CREATE TABLE that provides access to the render for each Column individually, by constructing a @compiles function against the new schema.CreateColumn construct.


  • [sql] [feature] “scalar” selects now have a WHERE method to help with generative building. 关于SS如何“关联”列也稍作调整;新的方法不再适用于所选的底层表列。这改善了一些相当深奥的情况,而那里的逻辑似乎没有任何目的。

  • [sql] [feature] 首次使用构造成引用多个远程表的ForeignKeyConstraint()时,会引发一个显式错误。


  • [sql] [feature] Added ColumnOperators.notin_(), ColumnOperators.notlike(), ColumnOperators.notilike() to ColumnOperators.


  • [sql] [changed] Most classes in expression.sql are no longer preceded with an underscore, i.e. Label, SelectBase, Generative, CompareMixin. _BindParamClause也被重命名为BindParameter。这些类的旧下划线名称在可预见的未来仍然是可用的同义词。

  • [sql] [removed] The long-deprecated and non-functional assert_unicode flag on create_engine() as well as String is removed.

  • [sql] [bug] Fixed bug where keyword arguments passed to Compiler.process() wouldn’t get propagated to the column expressions present in the columns clause of a SELECT statement. 特别是当依靠特殊标志的自定义编译方案使用时会出现。


  • [sql] [bug] [orm] The auto-correlation feature of select(), and by proxy that of Query, will not take effect for a SELECT statement that is being rendered directly in the FROM list of the enclosing SELECT. SQL中的关联仅适用于列表达式,例如WHERE,ORDER BY,columns子句中的表达式。


  • [sql] [bug] A tweak to column precedence which moves the “concat” and “match” operators to be the same as that of “is”, “like”, and others; this helps with parenthesization rendering when used in conjunction with “IS”.


  • [sql] [bug] Applying a column expression to a select statement using a label with or without other modifying constructs will no longer “target” that expression to the underlying Column; this affects ORM operations that rely upon Column targeting in order to retrieve results. 也就是说,查询(User.id,User.id.label('foo'))这样的查询现在将分别跟踪每个“User.id”表达式的值,而不是将它们一起进行管理。预计任何用户都不会受到这个影响;然而,如果select()命名的Column对象具有任意的.label()名称,则使用select()与query.from_statement()一起使用并尝试加载完全组合的ORM实体的功能可能无法正常工作,对该实体映射的Column对象更长的目标。


  • [sql] [bug] 修复了Column“default”参数的解释,因为不能将ExecutionContext传递给关键字参数参数。


  • [sql] [bug] All of UniqueConstraint, ForeignKeyConstraint, CheckConstraint, and PrimaryKeyConstraint will attach themselves to their parent table automatically when they refer to a Table-bound Column object directly (i.e. not just string column name), and refer to one and only one Table. 在0.8之前,此行为发生在UniqueConstraint和PrimaryKeyConstraint,而不是ForeignKeyConstraint或CheckConstraint。


  • [sql] [bug] TypeDecorator now includes a generic repr() that works in terms of the “impl” type by default. 这是指定自定义__init__方法的TypeDecorator类的行为更改;如果需要__repr __()来提供忠实的构造函数表示,那么这些类型将需要重新定义__repr __()。


  • [sql] [bug] column.label(None) now produces an anonymous label, instead of returning the column object itself, consistent with the behavior of label(column, None).


  • [sql] [change] 如果指定了长度,则Text()类型将呈现给定的长度。

的PostgreSQL ¶ T0>

  • [postgresql] [feature] postgresql.ARRAY features an optional “dimension” argument, will assign a specific number of dimensions to the array which will render in DDL as ARRAY[][]..., also improves performance of bind/result processing.


  • [postgresql] [feature] postgresql.ARRAY now supports indexing and slicing. Python []运算符在所有类型为ARRAY的SQL表达式上可用;可以传递整数或简单的切片。这些片也可以在UPDATE语句的SET子句的赋值端使用,并将它们传入Update.values();看例子的文档。

  • [postgresql] [feature] 添加了新的“数组字面量”结构postgresql.array()。基本上是一个“元组”,呈现为ARRAY [1,2,3]。

  • [postgresql] [feature] 增加了对Postgresql ONLY关键字的支持,该关键字可以对应于SELECT,UPDATE或DELETE语句中的表。该短语是使用with_hint()建立的。礼貌Ryan Kelly


  • [postgresql] [feature] The “ischema_names” dictionary of the Postgresql dialect is “unofficially” customizable. 这意味着,新的类型,如PostGIS类型可以被添加到这个字典中,PG类型的反射代码应该能够处理具有可变数目的参数的简单类型。这里的功能是“非官方的”,原因有三:

    1. 这不是一个“官方”的API。理想情况下,“官方”API将允许在方言或全局级别以通用方式自定义类型处理可调用。
    2. 这只适用于PG方言,特别是因为PG对自定义类型与其他数据库后端有广泛的支持。一个真正的API将在默认的方言级别执行。
    3. 这里的反射代码只是针对简单的类型进行测试,并可能有更多的组合类型的问题。


MySQL的¶ T0>

  • [mysql] [feature] Added TIME type to mysql dialect, accepts “fst” argument which is the new “fractional seconds” specifier for recent MySQL versions. 数据类型将解释从驱动程序接收到的微秒部分,但请注意,此时大多数/所有MySQL DBAPI都不支持返回此值。


  • [mysql] [bug] 在第一次连接时,Dialect不再会发出昂贵的服务器排序规则查询以及服务器封套。这些功能仍然是半专用的。


源码¶ T0>

  • [sqlite] [feature] the SQLite date and time types have been overhauled to support a more open ended format for input and output, using name based format strings and regexps. 一个新的参数“微秒”也提供了省略时间戳的“微秒”部分的选项。感谢Nathan Wright的工作和测试。


  • [sqlite] Added types.NCHAR, types.NVARCHAR to the SQLite dialect’s list of recognized type names for reflection. SQLite以返回的名字返回给定类型的名字。



  • [mssql] [feature] SQL Server dialect can be given database-qualified schema names, i.e. “schema=’mydatabase.dbo’”; reflection operations will detect this, split the schema among the ”.” to get the owner separately, and emit a “USE mydatabase” statement before reflecting targets within the “dbo” owner; the existing database returned from DB_NAME() is then restored.

  • [mssql] [feature] updated support for the mxodbc driver; mxodbc 3.2.1 is recommended for full compatibility.

  • [mssql] [bug] removed legacy behavior whereby a column comparison to a scalar SELECT via == would coerce to an IN with the SQL server dialect. 这是隐含的行为,在其他情况下失败,因此被删除。依赖于这个的代码需要被修改以显式地使用column.in_(select)。


预言¶ T0>

  • [oracle] [feature] The types of columns excluded from the setinputsizes() set can be customized by sending a list of string DBAPI type names to exclude, using the exclude_setinputsizes dialect parameter. 这个清单以前是固定的。该列表现在默认为STRING,UNICODE,从列表中删除CLOB,NCLOB。


  • [oracle] [bug] Quoting information is now passed along from a Column with quote=True when generating a same-named bound parameter to the bindparam() object, as is the case in generated INSERT and UPDATE statements, so that unknown reserved names can be fully supported.


  • [oracle] [bug] The CreateIndex construct in Oracle will now schema-qualify the name of the index to be that of the parent table. 以前这个名字被省略了,这显然是在默认模式下创建索引,而不是在表中创建索引。

火鸟¶ T0>

  • [firebird] [feature] The “startswith()” operator renders as “STARTING WITH”, “~startswith()” renders as “NOT STARTING WITH”, using FB’s more efficient operator.


  • [firebird] [feature] 添加了一个用于fdb驱动程序的实验性方言,但未经测试,因为我无法获取fdb程序包来构建。


  • [firebird] [bug] 如果尝试以与MySQL相同的方式发出没有长度的VARCHAR,则会引发CompileError


  • [firebird] [bug] Firebird now uses strict “ansi bind rules” so that bound parameters don’t render in the columns clause of a statement - they render literally instead.

  • [firebird] [bug] Support for passing datetime as date when using the DateTime type with Firebird; other dialects support this.

杂项¶ T0>

  • [feature] [access] the MS Access dialect has been moved to its own project on Bitbucket, taking advantage of the new SQLAlchemy dialect compliance suite. The dialect is still in very rough shape and probably not ready for general use yet, however it does have extremely rudimental functionality now. https://bitbucket.org/zzzeek/sqlalchemy-access T0> ¶ T1>

  • [moved] [maxdb] 几年前未运行的MaxDB方言被移出到一个未决的bitbucket项目中,https://bitbucket.org/zzzeek/sqlalchemy -maxdb T2> ¶ T3>

  • [examples] 烧杯缓存示例已被转换为使用dogpile.cache这是一个由Beaker的缓存内部创建者编写的新的缓存库,代表了一个大大改进,简化和现代化的缓存系统。


    Dogpile Caching