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

SQLAlchemy 1.1文档


0.7.11 ¶ T0>


ORM ¶ T0>

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


  • [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. 填充的结果仍然是正确的,因为额外的行被忽略,所以这个问题可能会出现性能下降,否则应用程序正常工作。


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


  • [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. 这种情况不仅发生在分配了错误类型的对象时,而且当某个属性被错误地配置为反向引用到现有的后端参照对时。


  • [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. 关系属性的替换很少(从来没有?)意图是什么,通常是指映射器的错误配置。这也会警告,如果一个backref在一个继承关系(在0.8中是一个错误)配置一个现有的backref


发动机¶ T0>

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


SQL ¶ T0>

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


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


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


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


MySQL的¶ T0>

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


杂项¶ T0>

  • [bug] [tests] 修正了test_execute中的“日志记录”导入问题,该问题在某些linux平台上不起作用。


0.7.10 ¶ T0>


ORM ¶ T0>

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


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


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


  • [orm] [bug] Fixed Session accounting bug whereby replacing a deleted object in the identity map with another object of the same primary key would raise a “conflicting state” error on rollback(), if the replaced primary key were established either via non-unitofwork-established INSERT statement or by primary key switch of another instance.


发动机¶ T0>

SQL ¶ T0>

  • [sql] [bug] Backported adjustment to __repr__ for TypeDecorator to 0.7, allows PickleType to produce a clean repr() to help with Alembic.


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


  • [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参数不应该被这个用法需要(特别是因为文档显示了一个没有被使用的例子),所以现在使用给定的默认对象的副本在内部安排,如果标志没有被设置为什么对应于这个参数。


  • [sql] [gae] [mysql] 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.8开始的错误代码解释。


MySQL的¶ T0>

  • [mysql] [feature] 在OurSQL方言中增加了“raise_on_warnings”标志。


  • [mysql] [feature] 为MySQLdb方言添加了“read_timeout”标志。


源码¶ 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. 除了截取双引号外,其他引号字符(如括号,反引号和单引号)现在也被拦截。



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

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


预言¶ T0>

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


  • [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这种基本的方式工作,但是在驱动程序中却要注意一些警告。检查文档的细节。


  • [oracle] [bug] 将setinputsizes()步骤中排除的cx_oracle类型列表更改为仅包含STRING和UNICODE; CLOB和NCLOB被删除。这是为了解决executemany()调用中破坏的cx_oracle行为。在0.8中,也应用了相同的更改,但也可以通过exclude_setinputsizes参数进行配置。


0.7.9 ¶ T0>


ORM ¶ T0>

  • [orm] [bug] Fixed bug mostly local to new AbstractConcreteBase helper where the “type” attribute from the superclass would not be overridden on the subclass to produce the “reserved for base” error message, instead placing a do-nothing attribute there. 这与使用ConcreteBase以及古典具体映射的所有行为是不一致的,在这种情况下,除非显式重写,否则多态基的“类型”列将在子类中显式禁用。

  • [orm] [bug] 当lazy ='dynamic'与uselist = False组合时,会发出警告。这是0.8中的一个异常。

  • [orm] [bug] Fixed bug whereby user error in related-object assignment could cause recursion overflow if the assignment triggered a backref of the same name as a bi-directional attribute on the incorrect class to the same target. 现在提出一个信息错误。

  • [orm] [bug] Fixed bug where incorrect type information would be passed when the ORM would bind the “version” column, when using the “version” feature. Tests courtesy Daniel Miller.


  • [orm] [bug] Extra logic has been added to the “flush” that occurs within Session.commit(), such that the extra state added by an after_flush() or after_flush_postexec() hook is also flushed in a subsequent flush, before the “commit” completes. 后续调用flush()将继续,直到after_flush挂钩停止添加新状态。100的“溢出”计数器也是适当的,如果每次都有一个中断的after_flush()挂钩添加新的内容。


发动机¶ T0>

  • [engine] [feature] 事件系统内存使用量的显着改善;实例级集合不再为特定类型的事件创建,直到为该事件建立实例级侦听器。


  • [engine] [bug] Fixed bug whereby a disconnect detect + dispose that occurs when the QueuePool has threads waiting for connections would leave those threads waiting for the duration of the timeout on the old pool (or indefinitely if timeout was disabled). 现在修正案通知那些服务员有一个特殊的例外情况,并让他们移动到新的池中。


  • [engine] [bug] 新增了gaerdbms导入到mysql / __ init__.py,缺少这个功能可以阻止加载新的GAE方言。


  • [engine] [bug] Fixed cextension bug whereby the “ambiguous column error” would fail to function properly if the given index were a Column object and not a string. 请注意,这里仍然存在一些列定位问题,这些问题在0.8中得到修复。


  • [engine] [bug] Fixed the repr() of Enum to include the “name” and “native_enum” flags. 帮助Alembic自动生成。

SQL ¶ T0>

  • [sql] [bug] Fixed the DropIndex construct to support an Index associated with a Table in a remote schema.


  • [sql] [bug] Fixed bug in over() construct whereby passing an empty list for either partition_by or order_by, as opposed to None, would fail to generate correctly. Courtesy GunnlaugurÞórBriem。


  • [sql] [bug] Fixed CTE bug whereby positional bound parameters present in the CTEs themselves would corrupt the overall ordering of bound parameters. 这主要影响SQL Server作为具有位置绑定+ CTE支持的平台。


  • [sql] [bug] Fixed more un-intuitivenesses in CTEs which prevented referring to a CTE in a union of itself without it being aliased. 现在,CTE只能渲染名称,只渲染给定名称的最外面的CTE - 所有其他引用的名称都被渲染出来。这甚至包括引用同一CTE对象的不同版本的其他CTE / SELECT,例如SELECT或SELECT的UNION ALL。在这种情况下,我们在某种程度上放松了对象身份和词汇身份之间的通常联系。两个不相关的CTE之间的真实姓名冲突现在引发了一个错误。

  • [sql] [bug] quoting is applied to the column names inside the WITH RECURSIVE clause of a common table expression according to the quoting rules for the originating Column.


  • [sql] [bug] Fixed regression introduced in 0.7.6 whereby the FROM list of a SELECT statement could be incorrect in certain “clone+replace” scenarios.


  • [sql] [bug] Fixed bug whereby usage of a UNION or similar inside of an embedded subquery would interfere with result-column targeting, in the case that a result-column had the same ultimate name as a name inside the embedded UNION.


  • [sql] [bug] 修复了自0.6开始的有关结果行定位的回归。应该可以使用select()语句和基于字符串的列,即select(['id','name'])。select_from('mytable'),并且让这个语句可以被Column对象定位那些名字;这是查询(MyClass).from_statement(some_statement)工作的机制。At some point the specific case of using select([‘id’]), which is equivalent to select([literal_column(‘id’)]), stopped working here, so this has been re-instated and of course tested.


  • [sql] [bug] 在ColumnOperators基础中添加了缺少的运算符is_(),isnot(),以便这些可用的运算符像所有其他运算符一样存在于方法中。/ T2>


的PostgreSQL ¶ T0>

  • [postgresql] [bug] Columns in reflected primary key constraint are now returned in the order in which the constraint itself defines them, rather than how the table orders them. Courtesy GunnlaugurÞórBriem ..


  • [postgresql] [bug] Added ‘terminating connection’ to the list of messages we use to detect a disconnect with PG, which appears to be present in some versions when the server is restarted.


MySQL的¶ T0>

  • [mysql] [bug] 更新了mysqlconnector接口,使用更新的“client flag”和“charset”API,由David McNelis提供

源码¶ T0>

  • [sqlite] [feature] 新增了对SQLite中实现的localtimestamp()SQL函数的支持,由Richard Mitchell提供

  • [sqlite] [bug] Adjusted a very old bugfix which attempted to work around a SQLite issue that itself was “fixed” as of sqlite 3.6.14, regarding quotes surrounding a table name when using the “foreign_key_list” pragma. The fix has been adjusted to not interfere with quotes that are actually in the name of a column or table, to as much a degree as possible; sqlite still doesn’t return the correct result for foreign_key_list() if the target table actually has quotes surrounding its name, as part of its name (i.e. “”“mytable”“”).


  • [sqlite] [bug] 调整列默认反射代码,将非字符串值转换为字符串,以适应不提供默认信息的旧SQLite版本作为字符串。¶ t2 >



  • [mssql] [bug] Fixed compiler bug whereby using a correlated subquery within an ORDER BY would fail to render correctly if the stament also used LIMIT/OFFSET, due to mis-rendering within the ROW_NUMBER() OVER clause. 修正礼貌sayap


  • [mssql] [bug] Fixed compiler bug whereby a given select() would be modified if it had an “offset” attribute, causing the construct to not compile correctly a second time.


  • [mssql] [bug] Fixed bug where reflection of primary key constraint would double up columns if the same constraint/table existed in multiple schemas.

0.7.8 ¶ T0>


ORM ¶ T0>

  • [orm] [feature] flush()的'objects'参数不再被废弃,因为已经确定了一些有效的用例。

  • [orm] [bug] Fixed bug whereby subqueryload() from a polymorphic mapping to a target would incur a new invocation of the query for each distinct class encountered in the polymorphic result.


  • [orm] [bug] Fixed bug in declarative whereby the precedence of columns in a joined-table, composite column (typically for id) would fail to be correct if the columns contained names distinct from their attribute names. 这会导致对实体属性的初级联接条件不正确。相关的,因为这应该是其中的一部分,这是。


  • [orm] [bug] 修正了不接受标识参数的identity_key()函数。¶ T0>


  • [orm] [bug] Fixed bug whereby populate_existing option would not propagate to subquery eager loaders. ¶ T0>


发动机¶ T0>

  • [engine] [bug] Fixed memory leak in C version of result proxy whereby DBAPIs which don’t deliver pure Python tuples for result rows would fail to decrement refcounts correctly. 最受关注的DBAPI是pyodbc。


  • [engine] [bug] Fixed bug affecting Py3K whereby string positional parameters passed to engine/connection execute() would fail to be interpreted correctly, due to __iter__ being present on Py3K string..


SQL ¶ T0>

  • [sql] [bug] 将BIGINT添加到sqlalchemy模块名称空间的类型.__ all__,BIGINT,BINARY,VARBINARY,并加上测试以确保不再发生这种破坏。


  • [sql] [bug] Repaired common table expression rendering to function correctly when the SELECT statement contains UNION or other compound expressions, courtesy btbuilder.


  • [sql] [bug] Fixed bug whereby append_column() wouldn’t function correctly on a cloned select() construct, courtesy Gunnlaugur Þór Briem.


的PostgreSQL ¶ T0>

  • [postgresql] [bug] removed unnecessary table clause when reflecting enums,. Courtesy GunnlaugurÞórBriem。


MySQL的¶ T0>

  • [mysql] [feature] 为Google App Engine添加了一种新的方言。礼貌Richie Foreman。


预言¶ T0>

  • [oracle] [bug] 在oracle中添加了ROWID。* ¶ T0>


0.7.7 ¶ T0>


ORM ¶ T0>

  • [orm] [feature] Added prefix_with() method to Query, calls upon select().prefix_with() to allow placement of MySQL SELECT directives in statements. 礼貌戴安娜克拉克


  • [orm] [feature] 为@validates include_removes添加新标志。如果为True,那么集合remove和属性del事件也将被发送到验证函数,当使用这个标记时,验证函数接受一个额外的参数“is_remove”。

  • [orm] [bug] Fixed issue in unit of work whereby setting a non-None self-referential many-to-one relationship to None would fail to persist the change if the former value was not already loaded..


  • [orm] [bug] Fixed bug in 0.7.6 introduced by whereby column_mapped_collection used against columns that were mapped as joins or other indirect selectables would fail to function.


  • [orm] [bug] Fixed bug whereby polymorphic_on column that’s not otherwise mapped on the class would be incorrectly included in a merge() operation, raising an error.


  • [orm] [bug] Fixed bug in expression annotation mechanics which could lead to incorrect rendering of SELECT statements with aliases and joins, particularly when using column_property().


  • [orm] [bug] Fixed bug which would prevent OrderingList from being pickleable. Jeff Dairiki


  • [orm] [bug] Fixed bug in relationship comparisons whereby calling unimplemented methods like SomeClass.somerelationship.like() would produce a recursion overflow, instead of NotImplementedError.

SQL ¶ T0>

  • [sql] [feature] 增加了新的连接事件dbapi_error()。在SQLAlchemy修改游标状态之前调用所有DBAPI级别的错误传递原始DBAPI异常。

  • [sql] [bug] 在没有列的情况下创建索引时删除警告;虽然这可能不是用户所期望的,但它是一个有效的用例,因为索引可能只是某个特定名称索引的占位符。

  • [sql] [bug] If conn.begin() fails when calling “with engine.begin()”, the newly acquired Connection is closed explicitly before propagating the exception onward normally.

  • [sql] [bug] 将BINARY,VARBINARY添加到类型.__ all __。


的PostgreSQL ¶ T0>

  • [postgresql] [feature] Added new for_update/with_lockmode() options for Postgresql: for_update=”read”/ with_lockmode(“read”), for_update=”read_nowait”/ with_lockmode(“read_nowait”). 这些分别发出“FOR SHARE”和“FOR NOWAREAIT”。礼貌戴安娜克拉克


  • [postgresql] [bug] 在反映域时删除了不必要的表子句。


MySQL的¶ T0>

  • [mysql] [bug] Fixed bug whereby column name inside of “KEY” clause for autoincrement composite column with InnoDB would double quote a name that’s a reserved word. Jeff Dairiki提供。


  • [mysql] [bug] Fixed bug whereby get_view_names() for “information_schema” schema would fail to retrieve views marked as “SYSTEM VIEW”. 由Matthew Turland提供。

  • [mysql] [bug] Fixed bug whereby if cast() is used on a SQL expression whose type is not supported by cast() and therefore CAST isn’t rendered by the dialect, the order of evaluation could change if the casted expression required that it be grouped; grouping is now applied to those expressions.


源码¶ T0>

  • [sqlite] [feature] Added SQLite execution option “sqlite_raw_colnames=True”, will bypass attempts to remove ”.” from column names returned by SQLite cursor.description.


  • [sqlite] [bug] When the primary key column of a Table is replaced, such as via extend_existing, the “auto increment” column used by insert() constructs is reset. 以前它会继续引用前一个主键列。



  • [mssql] [feature] 在PyODBC方言中添加了临时create_engine标志supports_unicode_binds,以强制方言是否将Python unicode文字传递给PyODBC。

  • [mssql] [bug] Repaired the use_scope_identity create_engine() flag when using the pyodbc dialect. 如果设置为False,以前该标志将被忽略。设置为False时,在每个INSERT之后,您将在“implicit_returning”设置为False的表中获得最后一个插入的ID“SELECT @@ identity”。

  • [mssql] [bug] UPDATE..FROM syntax with SQL Server requires that the updated table be present in the FROM clause when an alias of that table is also present in the FROM clause. 当FROM出现在第一位时,更新的表现在总是出现在FROM中。礼貌sayap。


0.7.6 ¶ T0>


ORM ¶ T0>

  • [orm] [feature] Added “no_autoflush” context manager to Session, used with with: will temporarily disable autoflush.

  • [orm] [feature] 向Query添加了cte()方法,从Core调用公共表表达式支持(见下文)。


  • [orm] [feature] Added the ability to query for Table-bound column names when using query(sometable).filter_by(colname=value).


  • [orm] [bug] Fixed event registration bug which would primarily show up as events not being registered with sessionmaker() instances created after the event was associated with the Session class.


  • [orm] [bug] Fixed bug whereby a primaryjoin condition with a “literal” in it would raise an error on compile with certain kinds of deeply nested expressions which also needed to render the same bound parameter name more than once.


  • [orm] [bug] 删除对映射对象进行多重删除时受影响的行数的检查。如果在两行之间存在ON DELETE CASCADE,我们无法从DBAPI获得准确的行计数;在大多数DBAPI上,这个特定的计数在任何情况下都不被支持,MySQLdb是值得注意的情况。


  • [orm] [bug] Fixed bug whereby objects using attribute_mapped_collection or column_mapped_collection could not be pickled.


  • [orm] [bug] Fixed bug whereby MappedCollection would not get the appropriate collection instrumentation if it were only used in a custom subclass that used @collection.internally_instrumented.


  • [orm] [bug] Fixed bug whereby SQL adaption mechanics would fail in a very nested scenario involving joined-inheritance, joinedload(), limit(), and a derived function in the columns clause.


  • [orm] [bug] Fixed the repr() for CascadeOptions to include refresh-expire. 还重做了CascadeOptions成为


  • [orm] [bug] Improved the “declarative reflection” example to support single-table inheritance, multiple calls to prepare(), tables that are present in alternate schemas, establishing only a subset of classes as reflected.

  • [orm] [bug] Scaled back the test applied within flush() to check for UPDATE against partially NULL PK within one table to only actually happen if there’s really an UPDATE to occur.


  • [orm] [bug] Fixed bug whereby if a method name conflicted with a column name, a TypeError would be raised when the mapper tried to inspect the __get__() method on the method object.


发动机¶ T0>

  • [engine] [feature] 为连接添加“no_parameters = True”执行选项。如果不存在任何参数,则会将该语句作为cursor.execute(语句)传递,从而在不存在参数收集时调用DBAPIs行为;对于psycopg2和mysql-python,这意味着不能解释字符串中的%符号。这只会发生在这个选项,而不仅仅是如果参数列表是空白的,否则这将产生不一致的SQL表达式的行为,通常转义百分号(和编译时,不能提前知道,如果参数将出现在一些情况)。


  • [engine] [feature] 将create_engine的pool_reset_on_return参数加入,允许控制“连接返回”行为。还添加了新的参数'rollback','commit',None to pool.reset_on_return以允许更多的控制连接返回活动。


  • [engine] [feature] 为引擎,连接添加了一些体面的上下文管理器:

    with engine.begin() as conn:
        <work with conn in a transaction>


    with engine.connect() as conn:
        <work with conn>


  • [engine] [bug] 添加了对MockConnection(即与strategy =“mock”一起使用)的execution_options()调用,它充当参数传递。

SQL ¶ T0>

  • [sql] [feature] Added support for SQL standard common table expressions (CTE), allowing SELECT objects as the CTE source (DML not yet supported). 这是通过任何select()结构的cte()方法调用的。


  • [sql] [bug] Fixed memory leak in core which would occur when C extensions were used with particular types of result fetches, in particular when orm query.count() were called.


  • [sql] [bug] Fixed issue whereby attribute-based column access on a row would raise AttributeError with non-C version, NoSuchColumnError with C version. 现在在这两种情况下引发AttributeError。


  • [sql] [bug] 新增支持将Column的.key作为结果集行中的字符串标识符使用。.key当前被列为列的“备用”名称,并被具有该常规名称的该键值的列的名称取代。对于SQLAlchemy的下一个主要版本,我们可以反转这个优先级,以便.key优先,但是这还没有确定。


  • [sql] [bug] A warning is emitted when a not-present column is stated in the values() clause of an insert() or update() construct. 将在0.8中移动到异常。


  • [sql] [bug] A significant change to how labeling is applied to columns in SELECT statements allows “truncated” labels, that is label names that are generated in Python which exceed the maximum identifier length (note this is configurable via label_length on create_engine()), to be properly referenced when rendered inside of a subquery, as well as to be present in a result set row using their original in-Python names.


  • [sql] [bug] Fixed bug in new “autoload_replace” flag which would fail to preserve the primary key constraint of the reflected table.


  • [sql] [bug] 当传递的参数不能被解释为列或表达式时,索引将会引发。当没有列创建索引时,会发出警告。


MySQL的¶ T0>

  • [mysql] [feature] 增加了对MySQL索引和主键约束类型的支持。USING)通过新的mysql_using参数索引和PrimaryKeyConstraint,由Diana Clarke提供


  • [mysql] [feature] 增加了对所有MySQL方言的“isolation_level”参数的支持。感谢这里的补丁mu_mind


源码¶ T0>

  • [sqlite] [bug] Fixed bug in C extensions whereby string format would not be applied to a Numeric value returned as integer; this affected primarily SQLite which does not maintain numeric scale settings.



  • [mssql] [feature] 在UpdateBase上使用新的with_hint()方法增加了对MSSQL INSERT,UPDATE和DELETE表提示的支持。


预言¶ T0>

  • [oracle] [feature] 添加了一个新的create_engine()标志,coerce_to_decimal = False,禁用精度数值处理,通过将所有数值转换为Decimal可以增加大量开销。 t2 >


  • [oracle] [bug] 增加了对LONG 缺少的编译支持¶


  • [oracle] [bug] 在Oracle的保留字列表中增加了'LEVEL'。


杂项¶ T0>

  • [bug] [examples] Altered _params_from_query() function in Beaker example to pull bindparams from the fully compiled statement, as a quick means to get everything including subqueries in the columns clause, etc.

0.7.5 ¶ T0>


ORM ¶ T0>

  • [orm] [feature] 在declarative_base()中添加了“class_registry”参数。允许两个或两个以上的声明式库共享相同类名的注册表。

  • [orm] [feature] query.filter() accepts multiple criteria which will join via AND, i.e. query.filter(x==y, z>q, ...)

  • [orm] [feature] Added new capability to relationship loader options to allow “default” loader strategies. 将'*'传递给joinedload(),lazyload(),subqueryload()或noload()中的任何一个,并成为用于所有关系的加载器策略,除了在查询中明确声明的那些策略。Thanks to up-and-coming contributor Kent Bower for an exhaustive and well written test suite !


  • [orm] [feature] 添加了新的声明性反射示例,说明如何最好地将表反射与声明混合以及使用一些新的特性。


  • [orm] [bug] Fixed issue where modified session state established after a failed flush would be committed as part of the subsequent transaction that begins automatically after manual call to rollback(). 在rollback()中检查会话的状态,如果存在新的状态,则发出警告,第二次调用restore_snapshot(),放弃这些更改。


  • [orm] [bug] Fixed regression from 0.7.4 whereby using an already instrumented column from a superclass as “polymorphic_on” failed to resolve the underlying Column.


  • [orm] [bug] 如果xyzload_all()与两个非连接关系不正确地使用,引发异常


  • [orm] [bug] Fixed bug whereby event.listen(SomeClass) forced an entirely unnecessary compile of the mapper, making events very hard to set up at module import time (nobody noticed this ??)


  • [orm] [bug] Fixed bug whereby hybrid_property didn’t work as a kw arg in any(), has().

  • [orm] [bug] ensure pickleability of all ORM exceptions for multiprocessing compatibility.


  • [orm] [bug] implemented standard “can’t set attribute” / “can’t delete attribute” AttributeError when setattr/delattr used on a hybrid that doesn’t define fset or fdel.


  • [orm] [bug] Fixed bug where unpickled object didn’t have enough of its state set up to work correctly within the unpickle() event established by the mutable object extension, if the object needed ORM attribute access within __eq__() or similar.


  • [orm] [bug] Fixed bug where “merge” cascade could mis-interpret an unloaded attribute, if the load_on_pending flag were used with relationship(). 感谢Kent Bower进行测试。


  • [orm] Fixed regression from 0.6 whereby if “load_on_pending” relationship() flag were used where a non-“get()” lazy clause needed to be emitted on a pending object, it would fail to load.

发动机¶ T0>

  • [engine] [bug] 将__reduce__添加到StatementError,DBAPIError列错误,以便使用多处理时异常是可选的。但是,并不是所有的DBAPI都支持这个,比如psycopg2.


  • [engine] [bug] Improved error messages when a non-string or invalid string is passed to any of the date/time processors used by SQLite, including C and Python versions.


  • [engine] [bug] Fixed bug whereby a table-bound Column object named “_” which matched a column labeled as “_” could match inappropriately when targeting in a result set row.


  • [engine] [bug] Fixed bug in “mock” strategy whereby correct DDL visit method wasn’t called, resulting in “CREATE/DROP SEQUENCE” statements being duplicated


SQL ¶ T0>

  • [sql] [feature] New reflection feature “autoload_replace”; when set to False on Table, the Table can be autoloaded without existing columns being replaced. 允许构建更灵活的表结构/反射链,包括将声明与表反射相结合。在wiki上看到新的例子


  • [sql] [feature] 在sqlalchemy.sql命名空间中添加了“false()”和“true()”表达式结构,尽管不是__all__的一部分。

  • [sql] [feature] Dialect-specific compilers now raise CompileError for all type/statement compilation issues, instead of InvalidRequestError or ArgumentError. 用于CREATE TABLE的DDL将重新引发CompileError,以包含有问题的列的表/列信息。


  • [sql] [bug] Improved the API for add_column() such that if the same column is added to its own table, an error is not raised and the constraints don’t get doubled up. 还有一些反射/声明模式。


  • [sql] [bug] Fixed issue where the “required” exception would not be raised for bindparam() with required=True, if the statement were given no parameters at all.


MySQL的¶ T0>

  • [mysql] [bug] fixed regexp that filters out warnings for non-reflected “PARTITION” directives, thanks to George Reilly


源码¶ T0>

  • [sqlite] [bug] the “name” of an FK constraint in SQLite is reflected as “None”, not “0” or other integer value. 在任何情况下,SQLite似乎都不支持约束命名。


  • [sqlite] [bug] sql.false() and sql.true() compile to 0 and 1, respectively in sqlite


  • [sqlite] [bug] removed an erroneous “raise” in the SQLite dialect when getting table names and view names, where logic is in place to fall back to an older version of SQLite that doesn’t have the “sqlite_temp_master” table.


  • [mssql] [bug] Adjusted the regexp used in the mssql.TIME type to ensure only six digits are received for the “microseconds” portion of the value, which is expected by Python’s datetime.time(). 请注意,对于发送微秒的支持至少在pyodbc中是不可能的。


  • [mssql] [bug] 在pymssql上删除了“30个字符”的限制,根据报告说现在它做的更好。pymssql没有得到很好的测试,因为DBAPI变得不稳定,所以目前还不清楚这个驱动程序的状态是什么,以及SQLAlchemy的实现应该如何调整。


预言¶ T0>

  • [oracle] [bug] 添加ORA-03135到oracle“连接丢失”错误永不停息的列表


杂项¶ T0>

  • [feature] [examples] 简化版本示例,使用声明性混合以及事件监听器,而不是元类+ SessionExtension。


  • [bug] [core] Changed LRUCache, used by the mapper to cache INSERT/UPDATE/DELETE statements, to use an incrementing counter instead of a timestamp to track entries, for greater reliability versus using time.time(), which can cause test failures on some platforms.


  • [bug] [core] Added a boolean check for the “finalize” function within the pool connection proxy’s weakref callback before calling it, so that a warning isn’t emitted that this function is None when the application is exiting and gc has removed the function from the module before the weakref callback was invoked.


  • [bug] [py3k] Fixed inappropriate usage of util.py3k flag and renamed it to util.py3k_warning, since this flag is intended to detect the -3 flag series of import restrictions only.


  • [bug] [examples] 修正large_collection.py在删除表之前关闭会话


0.7.4 ¶ T0>


ORM ¶ T0>

  • [orm] [feature] polymorphic_on now accepts many new kinds of values:

    • 未映射的独立表达式
    • column_property()对象
    • 任何column_property()的字符串名称或映射列的属性名称


    polymorphic_on中的独立表达式传播到单表继承子类,以便它们在WHERE / JOIN子句中使用,以便像往常一样将行限制到该子类。


  • [orm] [feature] 在处理Session.dirty等时,IdentitySet支持 - 操作符与difference()相同。


  • [orm] [feature] Added new value for Column autoincrement called “ignore_fk”, can be used to force autoincrement on a column that’s still part of a ForeignKeyConstraint. 关系文档中的新例子说明了它的用法。

  • [orm] [bug] Fixed backref behavior when “popping” the value off of a many-to-one in response to a removal from a stale one-to-many - the operation is skipped, since the many-to-one has since been updated.


  • [orm] [bug] After some years of not doing this, added more granularity to the “is X a parent of Y” functionality, which is used when determining if the FK on “Y” needs to be “nulled out” as well as if “Y” should be deleted with delete-orphan cascade. 现在测试考虑了父母的Python身份以及它的身份密钥,以查看Y的最后已知父母是否肯定是X.如果无法作出决定,则会引发StaleDataError。出现此错误的条件相当罕见,要求先前的父项是垃圾收集,以前可能会非常不恰当地更新/删除已迁移到新父项的记录,但可能会出现某些情况,即“无声成功”之前发生的这种情况将在模棱两可的情况下出现。过期的“Y”会重置“父”跟踪器,这意味着即使X过时,X.remove(Y)也可能会删除Y,但这与之前的行为相同。在这种情况下,建议还要过期X.


  • [orm] [bug] fixed inappropriate evaluation of user-mapped object in a boolean context within query.get(). 也在0.6.9.


  • [orm] [bug] 添加缺少逗号给PASSIVE_RETURN_NEVER_SET符号


  • [orm] [bug] Cls.column.collate(“some collation”) now works. 也在0.6.9


  • [orm] [bug] the value of a composite attribute is now expired after an insert or update operation, instead of regenerated in place. 这可以确保在使用该值重新生成组合之前,将先载入在刷新内过期的列值。


  • [orm] [bug] The fix in also emits the “refresh” event when the composite value is loaded on access, even if all column values were already present, as is appropriate. 这修复了依赖于“加载”事件的“可变”扩展,以确保_parents字典是最新的修复。感谢Scott Torborg在这里的测试案例。


  • [orm] [bug] Fixed bug whereby a subclass of a subclass using concrete inheritance in conjunction with the new ConcreteBase or AbstractConcreteBase would fail to apply the subclasses deeper than one level to the “polymorphic loader” of each base


  • [orm] [bug] Fixed bug whereby a subclass of a subclass using the new AbstractConcreteBase would fail to acquire the correct “base_mapper” attribute when the “base” mapper was generated, thereby causing failures later on.


  • [orm] [bug] Fixed bug whereby column_property() created against ORM-level column could be treated as a distinct entity when producing certain kinds of joined-inh joins.


  • [orm] [bug] Fixed the error formatting raised when a tuple is inadvertently passed to session.query(). 也在0.6.9.


  • [orm] [bug] Calls to query.join() to a single-table inheritance subclass are now tracked, and are used to eliminate the additional WHERE.. IN标准通常使用单个表继承,因为连接应该适应它。这允许OUTER JOIN到单个表子类来产生正确的结果,并且在处理单个表继承联接时总体上会产生更少的WHERE标准。


  • [orm] [bug] __table_args__ can now be passed as an empty tuple as well as an empty dict.. 感谢Fayaz Yusuf Khan的补丁。


  • [orm] [bug] Updated warning message when setting delete-orphan without delete to no longer refer to 0.6, as we never got around to upgrading this to an exception. 理想情况下,这可能是一个更好的例外,但这并不重要。


  • [orm] [bug] Fixed bug in get_history() when referring to a composite attribute that has no value; added coverage for get_history() regarding composites which is otherwise just a userland function.

发动机¶ T0>

  • [engine] [bug] Fixed bug whereby transaction.rollback() would throw an error on an invalidated connection if the transaction were a two-phase or savepoint transaction. 对于普通的事务来说,如果连接失效,rollback()是一个no-op,所以虽然不是100%清楚它是否应该是一个no-op,至少现在这个接口是一致的。 T0>


SQL ¶ T0>

  • [sql] [feature] The update() construct can now accommodate multiple tables in the WHERE clause, which will render an “UPDATE..FROM” construct, recognized by Postgresql and MSSQL. 在MySQL上编译时,将会生成“UPDATE t1,t2,..”。如果Column对象在“values”参数或生成方法中用作关键字,则MySQL还可以在SET子句中针对多个表进行渲染。


  • [sql] [feature] Added accessor to types called “python_type”, returns the rudimentary Python type object for a particular TypeEngine instance, if known, else raises NotImplementedError.


  • [sql] [bug] related to, made some adjustments to the change from regarding the “from” list on a select(). _froms集合不再被记忆,因为这简化了各种用例,并且在列已经被用在表达式中时,如果列被附加到表上,则不需要“警告”--select()构造现在总是产生正确的表达。这里可能没有现实世界的表现。 select()对象几乎总是临时的,希望优化select()的重用的系统将使用“compiled_cache”特性。调用select.bind时发生的命中已经减少,但绝大多数用户不应该使用“绑定元数据”:)。


  • [sql] [bug] further tweak to the fix from, so that generative methods work a bit better off of cloned (this is almost a non-use case though). 特别是这允许with_only_columns()表现得更加一致。向with_only_columns()添加了额外的文档,以阐明预期的行为,这些行为是由于。


架构¶ T0>

  • [schema] [feature] 新增了对远程“模式”的支持:

  • [schema] [feature] The “extend_existing” flag on Table now allows for the reflection process to take effect for a Table object that’s already been defined; when autoload=True and extend_existing=True are both set, the full set of columns will be reflected from the Table which will then overwrite those columns already present, rather than no activity occurring. 直接存在于自动加载运行中的列将一如既往地使用。


  • [schema] [bug] Fixed bug whereby TypeDecorator would return a stale value for _type_affinity, when using a TypeDecorator that “switches” types, like the CHAR/UUID type.

  • [schema] [bug] Fixed bug whereby “order_by=’foreign_key’” option to Inspector.get_table_names wasn’t implementing the sort properly, replaced with the existing sort algorithm

  • [schema] [bug] the “name” of a column-level CHECK constraint, if present, is now rendered in the CREATE TABLE statement using “CONSTRAINT CHECK ”.


  • [schema] MetaData() accepts “schema” and “quote_schema” arguments, which will be applied to the same-named arguments of a Table or Sequence which leaves these at their default of None.

  • [schema] Sequence接受“quote_schema”参数

  • [schema] tometadata() for Table will use the “schema” of the incoming MetaData for the new Table if the schema argument is explicitly “None”

  • [schema] 添加了CreateSchema和DropSchema DDL结构 - 它们只接受模式的字符串名称和“quote”标志。

  • [schema] When using default “schema” with MetaData, ForeignKey will also assume the “default” schema when locating remote table. 这允许元数据上的“模式”参数应用于任何没有“模式”的表对象集合。

  • [schema] a “has_schema” method has been implemented on dialect, but only works on Postgresql so far. 礼貌Manlio Perillo。


的PostgreSQL ¶ T0>

  • [postgresql] [feature] 添加了pg.ENUM的create_type构造函数参数。如果为False,则不会执行CREATE / DROP或检查类型作为表创建/删除事件的一部分;只有直接调用的create()/ drop)()方法才能做到这一点。帮助Alembic“离线”脚本。

  • [postgresql] [bug] Postgresql dialect memoizes that an ENUM of a particular name was processed during a create/drop sequence. 这允许创建/删除序列在没有任何对“checkfirst”的调用的情况下工作,并且也意味着在打开“checkfirst”的情况下它只需要检查ENUM一次。


MySQL的¶ T0>

  • [mysql] [bug] Unicode adjustments allow latest pymysql (post 0.4) to pass 100% on Python 2.


  • [mssql] [feature] 解除了SQL Server的SAVEPOINT限制。所有测试都使用它,但是不知道是否有更深的问题。


  • [mssql] [bug] repaired the with_hint() feature which wasn’t implemented correctly on MSSQL - usually used for the “WITH (NOLOCK)” hint (which you shouldn’t be using anyway ! 使用快照隔离来代替:))


  • [mssql] [bug] 对_need_decimal_fix选项使用新的pyodbc版本检测。


  • [mssql] [bug] 在SQL Server 2000上不要将“表名”转换为NVARCHAR。Still mostly in the dark what incantations are needed to make PyODBC work fully with FreeTDS 0.91 here, however.


  • [mssql] [bug] 在检索索引名称列表和索引内的列名时解码传入的值


杂项¶ T0>

  • [feature] [ext] 为“变换器”的混合文档添加了一个示例,该变换器返回一个可与查询转换相结合的自定义比较器。在调用with_transformation()的Query上使用新方法。这里的用例是相当实验性的,但是仅向Query添加一行代码。

  • [bug] [pyodbc] pyodbc-based dialects now parse the pyodbc accurately as far as observed pyodbc strings, including such gems as “py3-3.0.1-beta4”


  • [bug] [ext] the @compiles decorator raises an informative error message when no “default” compilation handler is present, rather than KeyError.

  • [bug] [examples] Fixed bug in history_meta.py example where the “unique” flag was not removed from a single-table-inheritance subclass which generates columns to put up onto the base.

0.7.3 ¶ T0>


一般¶ T0>

  • [general] Adjusted the “importlater” mechanism, which is used internally to resolve import cycles, such that the usage of __import__ is completed when the import of sqlalchemy or sqlalchemy.orm is done, thereby avoiding any usage of __import__ after the application starts new threads, fixes. 也在0.6.9.


ORM ¶ T0>

  • [orm] Improved query.join() such that the “left” side can more flexibly be a non-ORM selectable, such as a subquery. select_from()中的可选项现在将用作左侧,偏向于映射实体的隐式使用。如果连接仍然因缺少外键而失败,则错误消息包含此详细信息。感谢IRC上的brianrhude测试用例。


  • [orm] 添加after_soft_rollback()会话事件。只要调用rollback(),无论是否发生实际的DBAPI级别回滚,都会无条件触发此事件。此事件专门设计用于在Session.is_active为True时允许在Session回滚后继续操作。


  • [orm] added “adapt_on_names” boolean flag to orm.aliased() construct. 如果名称与实体映射列的名称相同,则允许别名()构造将ORM实体链接到包含特定属性的聚集或其他派生形式的可选项。

  • [orm] Added new flag expire_on_flush=False to column_property(), marks those properties that would otherwise be considered to be “readonly”, i.e. derived from SQL expressions, to retain their value after a flush has occurred, including if the parent object itself was involved in an update.

  • [orm] Enhanced the instrumentation in the ORM to support Py3K’s new argument style of “required kw arguments”, i.e. fn(a, b, *, c, d), fn(a, b, *args, c, d). 映射对象的__init__方法的参数签名将被保留,包括所需的kw规则。


  • [orm] Fixed bug in unit of work whereby detection of “cycles” among classes in highly interlinked patterns would not produce a deterministic result; thereby sometimes missing some nodes that should be considered cycles and causing further issues down the road. 注意这个bug也是0.6;目前没有反向移动。


  • [orm] Fixed a variety of synonym()-related regressions from 0.6:

    • 使同义词的同义词现在的作品。
    • 对一个关系()所做的同义词可以传递给query.join(),发送给query.options()的选项,通过名字传递给query.with_parent()。

  • [orm] Fixed bug whereby mapper.order_by attribute would be ignored in the “inner” query within a subquery eager load. . 也在0.6.9.


  • [orm] Identity map .discard() uses dict.pop(,None) internally instead of “del” to avoid KeyError/warning during a non-determinate gc teardown


  • [orm] Fixed regression in new composite rewrite where deferred=True option failed due to missing import


  • [orm] 复制了“comparator_factory”参数到composite(),当0.7被释放时被移除。


  • [orm] Fixed bug in query.join() which would occur in a complex multiple-overlapping path scenario, where the same table could be joined to twice. Thanks much to Dave Vitek for the excellent fix here.


  • [orm] 当切片为None时,查询会将OFFSET转换为零,这样就不会调用无用的OFFSET子句。

  • [orm] Repaired edge case where mapper would fail to fully update internal state when a relationship on a new mapper would establish a backref on the first mapper.

  • [orm] Fixed bug whereby if __eq__() was redefined, a relationship many-to-one lazyload would hit the __eq__() and fail. 不适用于0.6.9.


  • [orm] Calling class_mapper() and passing in an object that is not a “type” (i.e. a class that could potentially be mapped) now raises an informative ArgumentError, rather than UnmappedClassError.


  • [orm] 新的事件钩子MapperEvents.after_configured()。在configure()步骤完成之后调用,映射器实际上受到影响。从理论上讲,这个事件在每个应用程序中被调用一次,除非已经使用已经存在的新的映射。

  • [orm] When an open Session is garbage collected, the objects within it which remain are considered detached again when they are add()-ed to a new Session. 这是通过额外的检查来实现的,即前一个“session_key”实际上并不存在于会话池中。


  • [orm] 新的声明性特征:

    • __declare_last __()方法为类方法建立一个事件监听器,当映射器通过最后的“configure”步骤完成时将被调用。
    • __abstract__标志。当这个标记出现在类上时,这个类将不会被映射。
    • 新的帮助类ConcreteBase,AbstractConcreteBase。允许使用声明的具体映射,当调用“configure”映射器步骤时,声明会自动设置“polymorphic_union”。
    • 映射器本身具有半私有的方法,可以在已经配置完成后将“with_polymorphic”分配给映射器。


  • [orm] Declarative will warn when a subclass’ base uses @declared_attr for a regular column - this attribute does not propagate to subclasses.


  • [orm] The integer “id” used to link a mapped instance with its owning Session is now generated by a sequence generation function rather than id(Session), to eliminate the possibility of recycled id() values causing an incorrect result, no need to check that object actually in the session.


  • [orm] Behavioral improvement: empty conjunctions such as and_() and or_() will be flattened in the context of an enclosing conjunction, i.e. and_(x, or_()) will produce ‘X’ and not ‘X AND ()’..


  • [orm] Fixed bug regarding calculation of “from” list for a select() element. “from”calc现在被延迟,所以如果构造使用尚未附加到表的对象,但稍后与表关联,则它将使用表生成SQL作为FROM。这种改变深深地影响了FROM列表以及“相关”集合的计算机制,因为一些“子句适应”方案(这些在ORM中使用得非常严重)依赖于“from”通常在适应完成之前缓存集合。返工允许它可以随时清除和重新生成“from”集合。


  • [orm] Fixed bug whereby with_only_columns() method of Select would fail if a selectable were passed.. Also in 0.6.9.


发动机¶ T0>

  • [engine] The recreate() method in all pool classes uses self.__class__ to get at the type of pool to produce, in the case of subclassing. 请注意,通常不需要为池创建子类。


  • [engine] Improvement to multi-param statement logging, long lists of bound parameter sets will be compressed with an informative indicator of the compression taking place. 异常消息使用相同的改进格式。


  • [engine] 为pool.manage(dbapi).connect()添加了可选的“sa_pool_key”参数,以便不需要args的序列化

  • [engine] The entry point resolution supported by create_engine() now supports resolution of individual DBAPI drivers on top of a built-in or entry point-resolved dialect, using the standard ‘+’ notation - it’s converted to a ‘.’ before being resolved as an entry point.


  • [engine] 为连接中的“return unicode detection”步骤添加了一个异常catch +警告,允许在NVARCHAR上崩溃的数据库继续初始化,假设没有实现NVARCHAR类型。¶ t2 >


架构¶ T0>

  • [schema] Modified Column.copy() to use _constructor(), which defaults to self.__class__, in order to create the new object. 这允许更容易支持Column的子类。


  • [schema] Added a slightly nicer __repr__() to SchemaItem classes. 注意这里的repr不能完全支持“repr是构造函数”的思想,因为schema项目可以是非常深的嵌套/循环的,有些事情的后期初始化等等。


的PostgreSQL ¶ T0>

  • [postgresql] 为Index()添加了“postgresql_using”参数,产生USING子句来指定PG的索引实现。. 感谢Ryan P. Kelly的补丁。


  • [postgresql] Added client_encoding parameter to create_engine() when the postgresql+psycopg2 dialect is used; calls the psycopg2 set_client_encoding() method with the value upon connect.


  • [postgresql] Fixed bug related to whereby the same modified index behavior in PG 9 affected primary key reflection on a renamed column.. Also in 0.6.9.


  • [postgresql] Reflection functions for Table, Sequence no longer case insensitive. 名字只有在大小写不同的情况下才会有所区别。


  • [postgresql] 使用原子计数器作为服务器端游标名称的“随机数”来源;在极少数情况下,报道了冲突。

  • [postgresql] 缩小了在当前搜索路径中使用模式反映外键引用表时所做的假设;一个显式模式将被应用到被引用的表,只有当它实际上与引用表相匹配时,它也有一个明确的模式。以前,假定“当前”模式与完整的search_path是同义词。


MySQL的¶ T0>

  • [mysql] a CREATE TABLE will put the COLLATE option after CHARSET, which appears to be part of MySQL’s arbitrary rules regarding if it will actually work or not. 也在0.6.9.


  • [mysql] 在Index构造中增加了mysql_length参数,为索引指定了“length”。


源码¶ T0>

  • [sqlite] Ensured that the same ValueError is raised for illegal date/time/datetime string parsed from the database regardless of whether C extensions are in use or not.


  • [mssql] Changes to attempt support of FreeTDS 0.91 with Pyodbc. 这包括当检测到FreeTDS 0.91时字符串绑定以Python unicode对象的形式发送,而CAST(?AS NVARCHAR)用于检测表格。然而,我仍然将Pyodbc + FreeTDS 0.91的行为描述为非常糟糕,仍然有很多查询,比如反射中使用的引起Linux上的核心转储的问题,在OSX上它根本不可用,MemoryErrors比较多,只是简单的unicode支持。


  • [mssql] The behavior of =/!= when comparing a scalar select to a value will no longer produce IN/NOT IN as of 0.8; this behavior is a little too heavy handed (use in_() if you want to emit IN) and now emits a deprecation warning. 要立即获得0.8行为并删除警告,请在http://www.sqlalchemy.org/docs/07/dialects_mssql.html#scalar-select-comparisons处提供编译器配方以覆盖visit_binary()的行为。


  • [mssql] 接受“0”作为limit()的参数,这将产生“TOP 0”。


预言¶ T0>

  • [oracle] 固定的ReturningResultProxy为zxjdbc方言。从0.6开始回归。


  • [oracle] 字符串类型现在在Oracle上生成VARCHAR2,推荐作为默认的VARCHAR。也为Oracle方言增加了显式的VARCHAR2和NVARCHAR2。使用NVARCHAR仍然会生成“NVARCHAR2” - 在Oracle上没有“NVARCHAR” - 这仍然是“大写字母总是正好给出”策略的轻微破坏。VARCHAR仍然会生成“VARCHAR”,与政策保持一致。如果Oracle将“VARCHAR”定义为与他们声称的不同的东西(恕我直言,这种情况永远不会发生),那么类型就可以使用。


杂项¶ T0>

  • [types] 超出“precision”和“asdecimal”的浮点类型将被忽略;在这里添加了一个弃用警告以及与有关的其他文档


  • [ext] SQLSoup will not be included in version 0.8 of SQLAlchemy; while useful, we would like to keep SQLAlchemy itself focused on one ORM usage paradigm. SQLSoup很快会被第三方项目所取代。


  • [ext] 向AssociationProxy添加了local_attr,remote_attr,attr访问器,提供对类级别的代理属性的快速访问。


  • [ext] Changed the update() method on association proxy dictionary to use a duck typing approach, i.e. checks for “keys”, to discern between update({}) and update((a, b)). 以前,传递一个有元组作为关键字的字典会被误解为一个序列。


  • [examples] Adjusted dictlike-polymorphic.py example to apply the CAST such that it works on PG, other databases. 也在0.6.9.


0.7.2 ¶ T0>


ORM ¶ T0>

  • [orm] Feature enhancement: joined and subquery loading will now traverse already-present related objects and collections in search of unpopulated attributes throughout the scope of the eager load being defined, so that the eager loading that is specified via mappings or query options unconditionally takes place for the full depth, populating whatever is not already populated. 以前,如果相关对象或集合已经存在导致不一致的行为(尽管可以节省已经加载的图的加载/周期),则该遍历将停止。对于子查询,这意味着子查询所发出的额外的SELECT语句将无条件地调用,无论现有的图有多少(因此是有争议的)。当查询是属性启动的lazyload的结果时,“停止”的先前行为仍然有效,否则当重复遇到相同的相关对象时,“N + 1”风格的集合迭代可能变得不必要地昂贵。There’s also an as-yet-not-public generative Query method _with_invoke_all_eagers() which selects old/new behavior


  • [orm] A rework of “replacement traversal” within the ORM as it alters selectables to be against aliases of things (i.e. clause adaption) includes a fix for multiply-nested any()/has() constructs against a joined table structure.


  • [orm] Fixed bug where query.join() + aliased=True from a joined-inh structure to itself on relationship() with join condition on the child table would convert the lead entity into the joined one inappropriately. 也在0.6.9.


  • [orm] Fixed regression from 0.6 where Session.add() against an object which contained None in a collection would raise an internal exception. 把这个恢复到0.6的行为就是接受None,但显然没有任何东西是坚持的。理想情况下,带有None或append()的集合至少应该发出一个警告,这个警告被认为是0.8.


  • [orm] Load of a deferred() attribute on an object where row can’t be located raises ObjectDeletedError instead of failing later on; improved the message in ObjectDeletedError to include other conditions besides a simple “delete”.


  • [orm] Fixed regression from 0.6 where a get history operation on some relationship() based attributes would fail when a lazyload would emit; this could trigger within a flush() under certain conditions. 感谢提交这个伟大测试的用户。


  • [orm] Fixed bug apparent only in Python 3 whereby sorting of persistent + pending objects during flush would produce an illegal comparison, if the persistent object primary key is not a single integer. 也在0.6.9


  • [orm] Fixed bug whereby the source clause used by query.join() would be inconsistent if against a column expression that combined multiple entities together. 也在0.6.9


  • [orm] Fixed bug whereby if a mapped class redefined __hash__() or __eq__() to something non-standard, which is a supported use case as SQLA should never consult these, the methods would be consulted if the class was part of a “composite” (i.e. non-single-entity) result set. 也在0.6.9.


  • [orm] Added public attribute ”.validators” to Mapper, an immutable dictionary view of all attributes that have been decorated with the @validates decorator. 礼貌Stefano Fontanelli


  • [orm] Fixed subtle bug that caused SQL to blow up if: column_property() against subquery + joinedload + LIMIT + order by the column property() occurred. . 也在0.6.9


  • [orm] The join condition produced by with_parent as well as when using a “dynamic” relationship against a parent will generate unique bindparams, rather than incorrectly repeating the same bindparam. . 也在0.6.9.


  • [orm] Added the same “columns-only” check to mapper.polymorphic_on as used when receiving user arguments to relationship.order_by, foreign_keys, remote_side, etc.

  • [orm] Fixed bug whereby comparison of column expression to a Query() would not call as_scalar() on the underlying SELECT statement to produce a scalar subquery, in the way that occurs if you called it on Query().subquery().


  • [orm] Fixed declarative bug where a class inheriting from a superclass of the same name would fail due to an unnecessary lookup of the name in the _decl_class_registry.


  • [orm] Repaired the “no statement condition” assertion in Query which would attempt to raise if a generative method were called after from_statement() were called.. Also in 0.6.9.


发动机¶ T0>

  • [engine] Context manager provided by Connection.begin() will issue rollback() if the commit() fails, not just if an exception occurs.

  • [engine] Use urllib.parse_qsl() in Python 2.6 and above, no deprecation warning about cgi.parse_qsl()


  • [engine] 添加了mixin类sqlalchemy.ext.DontWrapMixin。用户定义的这种类型的异常在语句执行的上下文中不会被包装在StatementException中。

  • [engine] StatementException wrapping will display the original exception class in the message.

  • [engine] Failures on connect which raise dbapi.Error will forward the error to dialect.is_disconnect() and set the “connection_invalidated” flag if the dialect knows this to be a potentially “retryable” condition. 目前只有Oracle ORA-01033被执行。


SQL ¶ T0>

  • [sql] Fixed two subtle bugs involving column correspondence in a selectable, one with the same labeled subquery repeated, the other when the label has been “grouped” and loses itself. 影响。¶ T0>


架构¶ T0>

  • [schema] 新特性:所有类型的with_variant()方法。产生Variant()的一个实例,这是一个特殊的TypeDecorator,它将根据使用的方言选择不同类型的用法。


  • [schema] Added an informative error message when ForeignKeyConstraint refers to a column name in the parent that is not found. 也在0.6.9.

  • [schema] Fixed bug whereby adaptation of old append_ddl_listener() function was passing unexpected **kw through to the Table event. Table没有获取kws,0.6中的MetaData事件会得到“tables = somecollection”,这个行为被保留。


  • [schema] Fixed bug where “autoincrement” detection on Table would fail if the type had no “affinity” value, in particular this would occur when using the UUID example on the site that uses TypeEngine as the “impl”.

  • [schema] 为TypeEngine对象添加了一个改进的repr(),它将只显示构造函数的参数,这些参数是位置或kwargs偏离默认值的。


的PostgreSQL ¶ T0>

  • [postgresql] 为Index添加了新的“postgresql_ops”参数,允许为索引列指定PostgreSQL操作符类。Courtesy Filip Zyzniewski。


MySQL的¶ T0>

  • [mysql] 修正了OurSQL方言的XA命令使用ANSI中性引用符号“'”而不是“”。. 也在0.6.9.


源码¶ T0>

  • [sqlite] SQLite dialect no longer strips quotes off of reflected default value, allowing a round trip CREATE TABLE to work. 这与其他方言也是一致的,这些方言也保持默认的确切形式。



  • [mssql] Adjusted the pyodbc dialect such that bound values are passed as bytes and not unicode if the “Easysoft” unix drivers are detected. 这与FreeTDS发生的情况是一样的。如果在某些情况下传递了Python unicode,Easysoft似乎是segfault。

预言¶ T0>

  • [oracle] 添加ORA-00028断开代码,使用cx_oracle _Error.code获取代码。也在0.6.9.


  • [oracle] 添加了ORA-01033来断开连接事件中可以捕获的代码。


  • [oracle] repaired the oracle.RAW type which did not generate the correct DDL. 也在0.6.9.


  • [oracle] 将CURRENT添加到保留字列表中。也在0.6.9.


  • [oracle] Fixed bug in the mutable extension whereby if the same type were used twice in one mapping, the attributes beyond the first would not get instrumented.

  • [oracle] Fixed bug in the mutable extension whereby if None or a non-corresponding type were set, an error would be raised. 现在没有人接受将所有属性赋值为None的值,非法值将引发ValueError。

杂项¶ T0>

  • [examples] 修复了示例/版本控制测试运行器,不依赖于SQLAlchemy测试库,nosetests必须从examples / versioning中运行,以避免setup.cfg破坏它。 t2 >

  • [examples] 对示例/版本进行调整,以在多级继承情况下选择正确的外键

  • [examples] 修正了属性shard的例子,以0.7样式正确调用绑定参数。

0.7.1 ¶ T0>


一般¶ T0>

  • [general] 为Python错误7511添加了一个解决方法,C扩展构建失败并没有在Windows 64 + VC express上引发适当的异常


ORM ¶ T0>

  • [orm] “delete-orphan” cascade is now allowed on self-referential relationships - this since SQLA 0.7 no longer enforces “parent with no child” at the ORM level; this check is left up to foreign key nullability. 有关


  • [orm] Repaired new “mutable” extension to propagate events to subclasses correctly; don’t create multiple event listeners for subclasses either.


  • [orm] Modify the text of the message which occurs when the “identity” key isn’t detected on flush, to include the common cause that the Column isn’t set up to detect auto-increment correctly;. 也在0.6.8.


  • [orm] Fixed bug where transaction-level “deleted” collection wouldn’t be cleared of expunged states, raising an error if they later became transient. 也在0.6.8.


发动机¶ T0>

  • [engine] Deprecate schema/SQL-oriented methods on Connection/Engine that were never well known and are redundant: reflecttable(), create(), drop(), text(), engine.func

  • [engine] Adjusted the __contains__() method of a RowProxy result row such that no exception throw is generated internally; NoSuchColumnError() also will generate its message regardless of whether or not the column construct can be coerced to a string.. Also in 0.6.8.


SQL ¶ T0>

  • [sql] Fixed bug whereby metadata.reflect(bind) would close a Connection passed as a bind argument. 0.6的回归。

  • [sql] Streamlined the process by which a Select determines what’s in its ‘.c’ collection. 除了传递给select([])的原始的ClauseList()(它现在还没有记录的情况)之外,现在将被扩展到它的各个列元素中,而不是被忽略。除此之外,它的行为是一致的。

的PostgreSQL ¶ T0>

  • [postgresql] 关于数组数组MATCH运算符的一些单元测试修正。一个潜在的浮点错误问题是固定的,MATCH运算符的某些测试现在只能在面向EN的语言环境中执行。. 也在0.6.8.


MySQL的¶ T0>

  • [mysql] 单元测试在安装在windows上的MySQL上通过100%。

  • [mysql] 删除了在混合大小写名称的窗口上反映MySQL上的表时将失败的“调整大小写”步骤。经过对一个Windows MySQL服务器的一些实验,已经确定这一步并没有真正帮助到这个情况。 MySQL在非Windows平台上不会返回FK名称,并且至少删除这个步骤可以让反射的行为更像在其他操作系统上。这里已经提出了一个警告,但是很难确定在什么情况下可以提出这样的警告,所以现在就这么说了 - 增加了一些文档。


  • [mysql] supports_sane_rowcount will be set to False if using MySQLdb and the DBAPI doesn’t provide the constants.CLIENT module.

源码¶ T0>

  • [sqlite] Accept None from cursor.fetchone() when “PRAGMA read_uncommitted” is called to determine current isolation mode at connect time and default to SERIALIZABLE; this to support SQLite versions pre-3.3.0 that did not have this feature.


0.7.0 ¶ T0>


ORM ¶ T0>

  • [orm] Fixed regression introduced in 0.7b4 (!) 由此query.options(someoption(“不存在的名称”))将不会引发错误。还增加了额外的错误捕获的情况下,选项将尝试构建一个基于列的元素,进一步修复了一些在定制的错误消息


  • [orm] query.count() emits “count(*)” instead of “count(1)”.


  • [orm] Fine tuning of Query clause adaptation when from_self(), union(), or other “select from myself” operation, such that plain SQL expression elements added to filter(), order_by() etc. which are present in the nested “from myself” query will be adapted in the same way an ORM expression element will, since these elements are otherwise not easily accessible.


  • [orm] Fixed bug where determination of “self referential” relationship would fail with no workaround for joined-inh subclass related to itself, or joined-inh subclass related to a subclass of that with no cols in the sub-sub class in the join condition. 也在0.6.8.


  • [orm] mapper() will ignore non-configured foreign keys to unrelated tables when determining inherit condition between parent and child class, but will raise as usual for unresolved columns and table names regarding the inherited table. 这是以前已经应用于声明的行为的增强泛化。0.6.8有一个更保守的版本,它并没有从根本上改变连接条件的确定方式。


  • [orm] 当给定实体不是单个完整的类实体或映射器(即列)时调用query.get()是错误的。这是0.6.8中的弃用警告。


  • [orm] Fixed a potential KeyError which under some circumstances could occur with the identity map, part of


  • [orm] 增加了Query.with_session()方法,切换Query使用不同的会话。

  • [orm] horizontal shard query should use execution options per connection as per


  • [orm] 非主映射器将继承主映射器的_identity_class。这样一来,对一个通常在继承映射中的类建立的non_primary将产生与主映射器(也在0.6.8中)的identity-map兼容的结果。


  • [orm] Fixed the error message emitted for “can’t execute syncrule for destination column ‘q’; mapper ‘X’ does not map this column” to reference the correct mapper. . 也在0.6.8.


  • [orm] polymorphic_union() gets a “cast_nulls” option, disables the usage of CAST when it renders the labeled NULL columns.


  • [orm] polymorphic_union() renders the columns in their original table order, as according to the first table/selectable in the list of polymorphic unions in which they appear. (除非传递OrderedDict,否则它本身就是一个无序的映射)。

  • [orm] Fixed bug whereby mapper mapped to an anonymous alias would fail if logging were used, due to unescaped % sign in the alias name. 也在0.6.8.


SQL ¶ T0>

  • [sql] Fixed bug whereby nesting a label of a select() with another label in it would produce incorrect exported columns. 除此之外,这将破坏另一个column_property()的ORM column_property()映射。. 也在0.6.8


  • [sql] 在确定连接条件时更改了处理,以便仅在两个给定表之间考虑外键错误。也就是说,t1.join(t2)将报告涉及“t1”或“t2”的FK错误,但是涉及“t3”的任何错误都将被跳过。这会影响join(),以及ORM关系和继承条件逻辑。

  • [sql] Some improvements to error handling inside of the execute procedure to ensure auto-close connections are really closed when very unusual DBAPI errors occur.

  • [sql] metadata.reflect() and reflection.Inspector() had some reliance on GC to close connections which were internally procured, fixed this.

  • [sql] 新增显式检查Column .name是否被指定为空字符串


  • [sql] Fixed bug whereby if FetchedValue was passed to column server_onupdate, it would not have its parent “column” assigned, added test coverage for all column default assignment patterns. 也在0.6.8


的PostgreSQL ¶ T0>

  • [postgresql] 修正psycopg2方言中的psycopg2_version解析

  • [postgresql] Fixed bug affecting PG 9 whereby index reflection would fail if against a column whose name had changed. . 也在0.6.8.



  • [mssql] Fixed bug in MSSQL dialect whereby the aliasing applied to a schema-qualified table would leak into enclosing select statements. 也在0.6.8.


杂项¶ T0>

  • 本节记录了从0.7b4到0.7.0的变化。有关SQLAlchemy 0.7中新增功能的概述,请参阅http://docs.sqlalchemy.org/en/latest/changelog_migration_07.html

  • [documentation] 从ext.mutable文档中删除了“collections.MutableMapping”abc的用法,因为它被错误地使用,并且使得例子在任何情况下都更难以理解。/ T2>


  • [examples] removed the ancient “polymorphic association” examples and replaced with an updated set of examples that use declarative mixins, “generic_associations”. 每个提供一个替代表格布局。

  • [ext] Fixed bugs in sqlalchemy.ext.mutable extension where None was not appropriately handled, replacement events were not appropriately handled.


0.7.0b4 ¶ T0>


一般¶ T0>

  • [general] 更改CHANGES格式,此文件。格式更改已经应用到0.7版本。

  • [general] “-claclarative”的变化现在直接列在“-orm”部分下面,因为它们是密切相关的。

  • [general] 0.5系列的更改已经被移动到文件CHANGES_PRE_06,该文件取代了CHANGES_PRE_05.

  • [general] 在0.6系列中0.6.7及以后版本的更新日志现在只在0.6分支中的CHANGES文件中列出。在0.7的CHANGES文件(即这个文件)中,所有0.6的变化都在它们所在的0.7节中内联列出(因为所有的0.6变化都在0.7中)。如果在实现/行为方面存在任何差异,则会注意到适用于0.6版本的更改。

ORM ¶ T0>

  • [orm] Some fixes to “evaluate” and “fetch” evaluation when query.update(), query.delete() are called. The retrieval of records is done after autoflush in all cases, and before update/delete is emitted, guarding against unflushed data present as well as expired objects failing during the evaluation.


  • [orm] Reworded the exception raised when a flush is attempted of a subclass that is not polymorphic against the supertype.


  • [orm] 当查询选项无法找到目标实体时,还会进行更多措辞调整。解释路径必须来自一个根实体。

  • [orm] Some fixes to the state handling regarding backrefs, typically when autoflush=False, where the back-referenced collection wouldn’t properly handle add/removes with no net change. 感谢Richard Murri提供的测试案例+补丁。(也在0.6.7)。


  • [orm] Added checks inside the UOW to detect the unusual condition of being asked to UPDATE or DELETE on a primary key value that contains NULL in it.


  • [orm] Some refinements to attribute history. 在0.8版本中可能会有更多的变化,但是现在历史已经被修改,标量历史没有一个“非”现象的“副作用”。这允许稍微更好的区分None集合和没有实际的变化的能力,影响也是如此。


  • [orm] a “having” clause would be copied from the inside to the outside query if from_self() were used; in particular this would break an 0.7 style count() query. (也在0.6.7)


  • [orm] the Query.execution_options() method now passes those options to the Connection rather than the SELECT statement, so that all available options including isolation level and compiled cache may be used.


发动机¶ T0>

  • [engine] 如果CPython 2.x默认启用了C扩展,如果编译失败,它将会退化为纯Python。


SQL ¶ T0>

  • [sql] The “compiled_cache” execution option now raises an error when passed to a SELECT statement rather than a Connection. 以前它被完全忽略。我们可能会考虑在某个时候在每个语句级别上使用这个选项。


  • [sql] 还原基础TypeEngine类中的“catchall”构造函数,并带有弃用警告。这样,像Integer(11)那样的代码仍然成功。

  • [sql] Fixed regression whereby MetaData() coming back from unpickling did not keep track of new things it keeps track of now, i.e. collection of Sequence objects, list of schema names.


  • [sql] The limit/offset keywords to select() as well as the value passed to select.limit()/offset() will be coerced to integer. (也在0.6.7)


  • [sql] fixed bug where “from” clause gathering from an over() clause would be an itertools.chain() and not a list, causing “can only concatenate list” TypeError when combined with other clauses.

  • [sql] Fixed incorrect usage of ”,” in over() clause being placed between the “partition” and “order by” clauses.


  • [sql] 为PrimaryKeyConstraint now函数附加事件之前/之后,为所有约束类型的事件之前/之后添加的测试


  • [sql] Added explicit true()/false() constructs to expression lib - coercion rules will intercept “False”/”True” into these constructs. 在0.6中,构造通常直接转换为字符串,这在0.7中不再被接受。


架构¶ T0>

  • [schema] The ‘useexisting’ flag on Table has been superseded by a new pair of flags ‘keep_existing’ and ‘extend_existing’. 'extend_existing'相当于'useexisting' - 返回现有的表,并添加额外的构造函数元素。使用'keep_existing',返回现有的表格,但不添加额外的构造函数元素 - 这些元素仅在新创建表格时应用。


的PostgreSQL ¶ T0>

  • [postgresql] 现在支持Python 3的Psycopg2.

  • [postgresql] 固定支持使用pg8000的精确数字。


源码¶ T0>

  • [sqlite] Fixed bug where reflection of foreign key created as “REFERENCES ” without col name would fail. (也在0.6.7)


预言¶ T0>

  • [oracle] Using column names that would require quotes for the column itself or for a name-generated bind parameter, such as names with special characters, underscores, non-ascii characters, now properly translate bind parameter keys when talking to cx_oracle. (也在0.6.7)


  • [oracle] Oracle dialect adds use_binds_for_limits=False create_engine() flag, will render the LIMIT/OFFSET values inline instead of as binds, reported to modify the execution plan used by Oracle. (也在0.6.7)


杂项¶ T0>

  • [types] REAL has been added to the core types. 由Postgresql,SQL Server,MySQL,SQLite支持。请注意,SQL Server和MySQL版本中添加了额外的参数,这些方言也是可用的。


  • [types] 添加了@ event.listens_for()装饰器,给定目标+事件名称,将装饰的函数作为侦听器应用。


  • [pool] AssertionPool now stores the traceback indicating where the currently checked out connection was acquired; this traceback is reported within the assertion raised upon a second concurrent checkout; courtesy Gunnlaugur Briem


  • [pool] The “pool.manage” feature doesn’t use pickle anymore to hash the arguments for each pool.

  • [documentation] 记录的SQLite日期/时间/日期时间类型。(也在0.6.7)


  • [documentation] Fixed mutable extension docs to show the correct type-association methods.


0.7.0b3 ¶ T0>


一般¶ T0>

  • [general] 在Pypy下运行时对单元测试有很多修正(Alex Gaynor提供)

ORM ¶ T0>

  • [orm] 更改了query.count()的底层方法。query.count()现在在所有情况下都是正确的:


    即“从()”选择计数(1)。 T0>这在所有情况下都会产生一个子查询,但是大大简化了之前尝试过的所有猜测count(),在许多情况下仍会失败,特别是当涉及到表连接和其他连接时。如果为其他非常简单的计数生成的子查询确实是一个问题,请使用query(func.count())作为优化。


  • [orm] some changes to the identity map regarding rare weakref callbacks during iterations. 互斥体已被删除,因为它显然可能导致重入(即在一个线程中)死锁,也许当gc在迭代点收集对象以获得更多的内存时。希望“迭代期间字典改变”将会非常罕见,因为迭代方法在内部获取单个values()调用中的完整对象列表。注意0.6.7有一个更保守的解决方法,它仍然保持互斥体。


  • [orm] A tweak to the unit of work causes it to order the flush along relationship() dependencies even if the given objects don’t have any inter-attribute references in memory, which was the behavior in 0.5 and earlier, so a flush of Parent/Child with only foreign key/primary key set will succeed. 在保持0.6或更高版本的同时,在flush内部不会产生大量无用的内部依赖性结构,而这些内部依赖性结构并不对应于当前flush中的状态。


  • [orm] 改进了对仅列实体查询时发出的错误消息,并且使用加载器选项(通常不正确)使用加载器选项,其中父实体不完全存在¶ t2 >


  • [orm] Fixed bug in query.options() whereby a path applied to a lazyload using string keys could overlap a same named attribute on the wrong entity. 注意0.6.7有一个更保守的解决方法。


发动机¶ T0>

  • [engine] Fixed AssertionPool regression bug.


  • [engine] 当指定了一个无效的方言时,改变引发到ArgumentError的异常


SQL ¶ T0>

  • [sql] Added a fully descriptive error message for the case where Column is subclassed and _make_proxy() fails to make a copy due to TypeError on the constructor. 在这种情况下应该实现_constructor方法。

  • [sql] 添加了表格对象的新事件“column_reflect”。在反射中生成对象之前接收关于Column的信息字典,并允许对字典进行修改以控制生成的Column的大部分方面,包括键,名称,类型,信息字典。


  • [sql] To help with the “column_reflect” event being used with specific Table objects instead of all instances of Table, listeners can be added to a Table object inline with its construction using a new argument “listeners”, a list of tuples of the form (, ), which are applied to the Table before the reflection process begins.

  • [sql] Added new generic function “next_value()”, accepts a Sequence object as its argument and renders the appropriate “next value” generation string on the target platform, if supported. 还在Sequence本身提供“.next_value()”方法。


  • [sql] func.next_value() or other SQL expression can be embedded directly into an insert() construct, and if implicit or explicit “returning” is used in conjunction with a primary key column, the newly generated value will be present in result.inserted_primary_key.


  • [sql] 为ResultProxy添加访问器“returns_rows”,“is_insert”(也在0.6.7中)


的PostgreSQL ¶ T0>

  • [postgresql] 为postgresql方言增加了RESERVED_WORDS。(也在0.6.7)


  • [postgresql] 固定BIT类型允许“长度”参数,“变化”参数。反思也是固定的。(也在0.6.7)



  • [mssql] Rewrote the query used to get the definition of a view, typically when using the Inspector interface, to use sys.sql_modules instead of the information schema, thereby allowing views definitions longer than 4000 characters to be fully returned. (也在0.6.7)


火鸟¶ T0>

  • [firebird] The “implicit_returning” flag on create_engine() is honored if set to False. (也在0.6.7)


杂项¶ T0>

  • [declarative] Arguments in __mapper_args__ that aren’t “hashable” aren’t mistaken for always-hashable, possibly-column arguments. (也在0.6.7)


  • [informix] 新增了RESERVED_WORDS的informix方言。(也在0.6.7)


  • [ext] The horizontal_shard ShardedSession class accepts the common Session argument “query_cls” as a constructor argument, to enable further subclassing of ShardedQuery. (也在0.6.7)


  • [examples] 更新了关联,关联代理示例以使用声明式,添加了一个新例子dict_of_sets_with_default.py,这是一个“推送关联代理”的例子

  • [examples] The Beaker caching example allows a “query_cls” argument to the query_callable() function. (也在0.6.7)


0.7.0b2 ¶ T0>


ORM ¶ T0>

  • [orm] Fixed bug whereby Session.merge() would call the load() event with one too few arguments.


  • [orm] 添加了一些逻辑,用于阻止MapperExtension或SessionExtension中的事件生成,为所有未覆盖的方法生成无事件事件。


SQL ¶ T0>

  • [sql] 将EngineEvents事件类重命名为ConnectionEvents。由于这些类永远不会被最终用户代码直接访问,所以这严格地是对最终用户的文档更改。还简化了事件如何链接到内部的引擎和连接。


  • [sql] The Sequence() construct, when passed a MetaData() object via its ‘metadata’ argument, will be included in CREATE/DROP statements within metadata.create_all() and metadata.drop_all(), including “checkfirst” logic.


  • [sql] 如果Column.references()方法有一个外键准确地引用给定的列,而不仅仅是它的父表,则返回True。


的PostgreSQL ¶ T0>

  • [postgresql] Fixed regression from 0.6 where SMALLINT and BIGINT types would both generate SERIAL on an integer PK column, instead of SMALLINT and BIGSERIAL


杂项¶ T0>

  • [declarative] Fixed regression whereby composite() with Column objects placed inline would fail to initialize. 现在,Column对象可以与composite()或external(外部)内联,并通过name或object引用。


  • [declarative] Fix error message referencing old @classproperty name to reference @declared_attr (also in 0.6.7)


  • [declarative] __table_args__元组末尾的字典现在是可选的。


  • [ext] Association proxy now has correct behavior for any(), has(), and contains() when proxying a many-to-one scalar attribute to a one-to-many collection (i.e. the reverse of the ‘typical’ association proxy use case)


  • [examples] Beaker example now takes into account ‘limit’ and ‘offset’, bind params within embedded FROM clauses (like when you use union() or from_self()) when generating a cache key.

0.7.0b1 ¶ T0>


一般¶ T0>

  • [general] 新的事件系统,取代所有扩展名,侦听器等。


  • [general] 记录增强


  • [general] 安装程序不再安装一个Nose插件


  • [general] sys.modules中的“sqlalchemy.exceptions”别名已被删除。基本的SQLA异常可以通过“from sqlalchemy import exc”获得。“exc”的“exceptions”别名现在仍然保留在“sqlalchemy”中,而不是修补到sys.modules中。

ORM ¶ T0>

  • [orm] 更简洁的query.join形式(target,onclause)


  • [orm] 混合属性,implements / supersedes synonym()


  • [orm] 重写组合


  • [orm] 突变事件扩展,取代“mutable = True”

  • [orm] 默认关闭PickleType和ARRAY可变性


  • [orm] 简化的polymorphic_on赋值


  • [orm] 允许没有父母的孤儿进行冲洗


  • [orm] Adjusted flush accounting step to occur before the commit in the case of autocommit=True. 这允许autocommit = True与expire_on_commit = True一起工作,同时允许post-flush会话钩子在与autocommit = False相同的事务上下文中操作。


  • [orm] 收集成员时产生的警告,标量指示不属于flush


  • [orm] 可以映射非 - 衍生的结构


  • [orm] 查询改进中的元组标签名称


  • [orm] 映​​射列属性首先引用最具体的列


  • [orm] 映​​射到两个或多个同名列的连接需要显式声明


  • [orm] Mapper requires that polymorphic_on column be present in the mapped selectable


  • [orm] compile_mappers() renamed configure_mappers(), simplified configuration internals


  • [orm] the aliased() function, if passed a SQL FromClause element (i.e. not a mapped class), will return element.alias() instead of raising an error on AliasedClass.


  • [orm] Session.merge() will check the version id of the incoming state against that of the database, assuming the mapping uses version ids and incoming state has a version_id assigned, and raise StaleDataError if they don’t match.


  • [orm] Session.connection(), Session.execute() accept ‘bind’, to allow execute/connection operations to participate in the open transaction of an engine explicitly.


  • [orm] Query.join(), Query.outerjoin(), eagerload(), eagerload_all(), others no longer allow lists of attributes as arguments (i.e. option([x, y, z]) form, deprecated since 0.5)

  • [orm] 删除了ScopedSession.mapper(从0.5开始弃用)

  • [orm] Horizontal shard query places ‘shard_id’ in context.attributes where it’s accessible by the “load()” event.


  • [orm] A single contains_eager() call across multiple entities will indicate all collections along that path should load, instead of requiring distinct contains_eager() calls for each endpoint (which was never correctly documented).


  • [orm] The “name” field used in orm.aliased() now renders in the resulting SQL statement.

  • [orm] 会话weak_instance_dict = False不推荐使用


  • [orm] An exception is raised in the unusual case that an append or similar event on a collection occurs after the parent object has been dereferenced, which prevents the parent from being marked as “dirty” in the session. 是0.6.6中的一个警告。


  • [orm] Query.distinct() now accepts column expressions as *args, interpreted by the Postgresql dialect as DISTINCT ON ().


  • [orm] Additional tuning to “many-to-one” relationship loads during a flush(). 版本0.6.6([ticket:2002])的更改要求在刷新期间可能会发生更多“不必要”的m2o加载。额外的加载模式已被添加,以便在这个特定的用例中发出的SQL被修剪回来,同时仍然检索flush所需的信息,以便不会错过任何东西。


  • [orm] the value of “passive” as passed to attributes.get_history() should be one of the constants defined in the attributes package. 发送True或False不推荐使用。

  • [orm] Query.subquery()添加了一个名称参数,以允许将固定名称分配给别名对象。(也在0.6.7)


  • [orm] A warning is emitted when a joined-table inheriting mapper has no primary keys on the locally mapped table (but has pks on the superclass table). (也在0.6.7)


  • [orm] Fixed bug where “middle” class in a polymorphic hierarchy would have no ‘polymorphic_on’ column if it didn’t also specify a ‘polymorphic_identity’, leading to strange errors upon refresh, wrong class loaded when querying from that target. 当使用单个表继承时,也会发出正确的WHERE标准。(也在0.6.7)


  • [orm] Fixed bug where a column with a SQL or server side default that was excluded from a mapping with include_properties or exclude_properties would result in UnmappedColumnError. (也在0.6.7)


  • [orm] 在异常情况下,在父对象被解除引用后发生集合上的附加事件或类似事件时,会发出警告,这会阻止父会话在会话中被标记为“脏” 。这将是0.7的例外。(也在0.6.7)


SQL ¶ T0>

  • [sql] Added over() function, method to FunctionElement classes, produces the _Over() construct which in turn generates “window functions”, i.e. “ OVER (PARTITION BY , ORDER BY )”.


  • [sql] LIMIT/OFFSET clauses now use bind parameters


  • [sql] select.distinct() now accepts column expressions as *args, interpreted by the Postgresql dialect as DISTINCT ON (). 请注意,通过向distinct关键字参数传递一个列表,以便select()。


  • [sql] select.prefix_with() accepts multiple expressions (i.e. *expr), ‘prefix’ keyword argument to select() accepts a list or tuple.

  • [sql] Passing a string to the distinct keyword argument of select() for the purpose of emitting special MySQL keywords (DISTINCTROW etc.) 已被弃用 - 为此使用prefix_with()

  • [sql] TypeDecorator works with primary key columns


  • [sql] DDL()构造现在转义百分号


  • [sql] Table.c / MetaData.tables refined a bit, don’t allow direct mutation


  • [sql] Callables passed to bindparam() don’t get evaluated


  • [sql] types.type_map现在是private,types._type_map


  • [sql] 强调非公有池方法


  • [sql] 添加了NULLS FIRST和NULLS LAST支持。它作为asc()和desc()运算符的扩展实现,称为nullsfirst()和nullslast()。


  • [sql] 可以使用字符串作为列名,以Table内定义的方式创建Index()构造,作为在表外创建索引的替代方法。T2>

  • [sql] execution_options() on Connection accepts “isolation_level” argument, sets transaction isolation level for that connection only until returned to the connection pool, for those backends which support it (SQLite, Postgresql)


  • [sql] A TypeDecorator of Integer can be used with a primary key column, and the “autoincrement” feature of various dialects as well as the “sqlite_autoincrement” flag will honor the underlying database type as being Integer-based.


  • [sql] 在Integer PK列上存在server_default时建立一致性。SQLA不会预取这些,也不会返回到cursor.lastrowid(DBAPI)中。确保所有后端始终在result.inserted_primary_key中返回None。关于这种情况的反思,除了在我们检测到序列默认值的PG SERIAL col的情况下,对server_default的int PK col的反映将“autoincrement”标志设置为False。

    References: #2020, #2021

  • [sql] Result-row processors are applied to pre-executed SQL defaults, as well as cursor.lastrowid, when determining the contents of result.inserted_primary_key.


  • [sql] Bind parameters present in the “columns clause” of a select are now auto-labeled like other “anonymous” clauses, which among other things allows their “type” to be meaningful when the row is fetched, as in result row processors.

  • [sql] TypeDecorator is present in the “sqlalchemy” import space.

  • [sql] Non-DBAPI errors which occur in the scope of an execute() call are now wrapped in sqlalchemy.exc.StatementError, and the text of the SQL statement and repr() of params is included. 这使得更容易识别在DBAPI涉及之前失败的语句执行。


  • [sql] The concept of associating a ”.bind” directly with a ClauseElement has been explicitly moved to Executable, i.e. the mixin that describes ClauseElements which represent engine-executable constructs. 这种改变是对内部组织的改进,不太可能影响现实世界的使用。


  • [sql] Column.copy(), as used in table.tometadata(), copies the ‘doc’ attribute. (也在0.6.7)


  • [sql] Added some defs to the resultproxy.c extension so that the extension compiles and runs on Python 2.4. (也在0.6.7)


  • [sql] The compiler extension now supports overriding the default compilation of expression._BindParamClause including that the auto-generated binds within the VALUES/SET clause of an insert()/update() statement will also use the new compilation rules. (也在0.6.7)


  • [sql] SQLite dialect now uses NullPool for file-based databases


  • [sql] The path given as the location of a sqlite database is now normalized via os.path.abspath(), so that directory changes within the process don’t affect the ultimate location of a relative file path.


的PostgreSQL ¶ T0>

  • [postgresql] When explicit sequence execution derives the name of the auto-generated sequence of a SERIAL column, which currently only occurs if implicit_returning=False, now accommodates if the table + column name is greater than 63 characters using the same logic Postgresql uses. (也在0.6.7)


  • [postgresql] 在“disconnect”异常列表中添加了额外的libpq消息,“无法从服务器接收数据”(同样在0.6.7中)


MySQL的¶ T0>

  • [mysql] pymysql的新的DBAPI支持,它是MySQL-python的纯Python端口。


  • [mysql] oursql dialect accepts the same “ssl” arguments in create_engine() as that of MySQLdb. (也在0.6.7)



  • [mssql] the String/Unicode types, and their counterparts VARCHAR/ NVARCHAR, emit “max” as the length when no length is specified, so that the default length, normally ‘1’ as per SQL server documentation, is instead ‘unbounded’. VARBINARY类型也会发生这种情况。



火鸟¶ T0>

  • [firebird] 一些调整,以便支持Interbase。FB / Interbase版本的标识符被解析成一个结构,例如(8,1,1,'interbase')或者(2,1,588,'firebird'),这样就可以区分它们。


杂项¶ T0>