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

SQLAlchemy 1.1文档

0.6更新日志

0.6.9 ¶ T0>

发布时间:2012年5月5日星期六

一般¶ 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.

    参考文献:#2279

ORM ¶ T0>

  • [orm] [bug] 修复了query.get()中布尔上下文中用户映射对象的不恰当评估。

    参考文献:#2310

  • [orm] [bug] 修正了元组无意中传递给session.query()时引发的错误格式。

    参考文献:#2297

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

    参考文献:#2197

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

    参考文献:#2228

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

    参考文献:#2234

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

    参考文献:#2287

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

    参考文献:#2215

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

    参考文献:#2188

  • [orm] with_parent产生的连接条件以及对父代使用“动态”关系时将生成唯一的bindparams,而不是错误地重复相同的bindparam。¶ T0>

    参考文献:#2207

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

    参考文献:#2199

  • [orm] Cls.column.collat​​e(“some collat​​ion”)现在可用。

    参考文献:#1776

发动机¶ T0>

  • [engine] Backported the fix for introduced in 0.7.4, which ensures that the connection is in a valid state before attempting to call rollback()/prepare()/release() on savepoint and two-phase transactions.

    参考文献:#2317

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>

    参考文献:#2188

  • [sql] Fixed bug whereby “warn on unicode” flag would get set for the String type when used with certain dialects. 这个bug不在0.7.

  • [sql] 修正了select中的with_only_columns()方法失败,如果通过了selectable的话。但是,FROM行为在这里仍然不正确,因此在任何情况下,您都需要0.7来使用该用例。

    参考文献:#2270

架构¶ T0>

  • [schema] 当ForeignKeyConstraint引用父级中未找到的列名称时,添加了一条信息性错误消息。

的PostgreSQL ¶ T0>

  • [postgresql] 修正了与PG9中相同的修改索引行为影响重命名列上的主键反射的bug。

    参考文献:#2291#2141

MySQL的¶ T0>

  • [mysql] 修正了OurSQL方言使用ANSI中性引用符号“'”作为XA命令而不是'“'。¶ T0>

    参考文献:#2186

  • [mysql] CREATE TABLE会将COLLATE选项放在CHARSET之后,这看起来是MySQL的任意规则的一部分,关于它是否会真正起作用。

    参考文献:#2225

MSSQL ¶ T0>

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

    参考文献:#2269

预言¶ T0>

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

    参考文献:#2200

  • [oracle] 修复了没有生成正确DDL的oracle.RAW类型。

    参考文献:#2220

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

    参考文献:#2212

杂项¶ T0>

  • [examples] 调整了dictlike-polymorphic.py示例以应用CAST,使其可以在PG,其他数据库上工作。

    参考文献:#2266

0.6.8 ¶ T0>

发布:2011年6月15日

ORM ¶ T0>

  • [orm] 针对基于列的实体调用query.get()是无效的,这种情况现在引发了弃用警告。

    参考文献:#2144

  • [orm] 非主映射器将继承主映射器的_identity_class。这样一来,针对通常在继承映射中的类建立的non_primary将生成与主映射器的标识映射兼容的结果

    参考文献:#2151

  • [orm] Backported 0.7的身份映射实现,它在去除时不使用互斥锁。这是因为尽管0.6.7的调整,一些用户仍然陷入僵局;不使用互斥锁的0.7方法似乎不会产生“字典改变大小”问题,这是互斥体的原始基础。

    参考文献:#2148

  • [orm] 修复了针对“无法为目标列q执行syncrule”发出的错误消息;映射器'X'不映射此列“以引用正确的映射器。¶ T0>

    参考文献:#2163

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

    参考文献:#2149

  • [orm] mapper() will ignore non-configured foreign keys to unrelated tables when determining inherit condition between parent and child class. 这相当于已经应用于声明的行为。请注意,0.7有一个更全面的解决方案,改变了join()本身如何确定FK错误。

    参考文献:#2153

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

    参考文献:#2171

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

    参考文献:#2170

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

    参考文献:#2182

发动机¶ T0>

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

    参考文献:#2178

SQL ¶ T0>

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

    参考文献:#2147

  • [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()映射。¶ T0>

    参考文献:#2167

的PostgreSQL ¶ T0>

  • [postgresql] 修正了影响PG9的错误,因此如果针对名称已更改的列,索引反射将失败。¶ T0>

    参考文献:#2141

  • [postgresql] 有关数值数组MATCH运算符的一些单元测试修正。一个潜在的浮点不准确问题已经修复,MATCH运算符的某些测试目前只能在面向EN的语言环境中执行。¶ T0>

    参考文献:#2175

MSSQL ¶ T0>

  • [mssql] 修正了MSSQL方言中的错误,因此应用于模式限定表的别名会泄漏到封闭的select语句中。

    参考文献:#2169

  • [mssql] 修正了在结果集或绑定参数中使用DATETIME2类型在“适应”步骤中失败的错误。这个问题不在0.7中。

    参考文献:#2159

0.6.7 ¶ T0>

发布于:2011年4月13日

ORM ¶ T0>

  • [orm] 收紧迭代与围绕身份映射迭代删除互斥体,试图减少导致死锁的(非常罕见的)可重入gc操作的机会。可以在0.7中删除互斥锁。

    参考文献:#2087

  • [orm] Query.subquery()添加了name参数,以允许将固定名称分配给别名对象。¶ T4>

    参考文献:#2030

  • [orm] 当连接表继承映射器在本地映射表上没有主键时(但在超类表上有pks)时,会发出警告。

    参考文献:#2019

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

    参考文献:#2038

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

    参考文献:#1995

  • [orm] 在异常情况下发生警告,即在取消引用父对象后发生集合上的附加事件或类似事件,这会阻止父会话在会话中被标记为“脏” 。这在0.7中是个例外。

    参考文献:#2046

  • [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.7具有此修正的更新版本。

    参考文献:#2098

  • [orm] 重写了在尝试刷新非超类型的子类时发生的异常。

    参考文献:#2063

  • [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提供的测试案例+补丁。

    参考文献:#2123

  • [orm] 如果使用from_self(),那么“having”子句将从内部复制到外部查询中。

    参考文献:#2130

发动机¶ T0>

  • [engine] Fixed bug in QueuePool, SingletonThreadPool whereby connections that were discarded via overflow or periodic cleanup() were not explicitly closed, leaving garbage collection to the task instead. 这通常只影响像Jython和Pypy这样的非引用计数后端。感谢Jaimy Azle发现这一点。

    参考文献:#2102

SQL ¶ T0>

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

    参考文献:#2028

  • [sql] 增加了对resultproxy.c扩展的一些定义,以便扩展编译并在Python 2.4上运行。

    参考文献:#2023

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

    参考文献:#2042

  • [sql] 为ResultProxy添加访问器“returns_rows”,“is_insert”

    参考文献:#2089

  • [sql] select()的limit / offset关键字以及传递给select.limit()/ offset()的值将强制为整数。

    参考文献:#2116

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

    参考文献:#1083

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

    参考文献:#2044

  • [postgresql] 为postgresql方言增加了RESERVED_WORDS。

    参考文献:#2092

  • [postgresql] 固定BIT类型以允许“长度”参数,“变化”参数。反射也是固定的。

    参考文献:#2073

MySQL的¶ T0>

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

    参考文献:#2047

源码¶ T0>

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

    参考文献:#2115

MSSQL ¶ T0>

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

    参考文献:#2071

预言¶ 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.

    参考文献:#2100

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

    参考文献:#2116

火鸟¶ T0>

  • [firebird] 如果设置为False,create_engine()上的“implicit_returning”标志将被遵守。

    参考文献:#2083

杂项¶ T0>

  • [informix] 新增RESERVED_WORDS informix方言。

    参考文献:#2092

  • [ext] horizo​​ntal_shard ShardedSession类接受通用会话参数“query_cls”作为构造函数参数,以启用ShardedQuery的进一步子类化。

    参考文献:#2090

  • [declarative] 添加了对名称'metadata'用于声明类的列属性的明确检查。

    参考文献:#2050

  • [declarative] 修复引用旧@classproperty名称引用@declared_attr 的错误消息

    参考文献:#2061

  • [declarative] __mapper_args__中不是“可排序”的参数不会被误认为是可以被哈希的可能列参数。

    参考文献:#2091

  • [documentation] 记录的SQLite DATE / TIME / DATETIME类型。

    参考文献:#2029

  • [examples] 烧杯缓存示例允许query_callable()函数使用“query_cls”参数。

    参考文献:#2090

0.6.6 ¶ T0>

发布时间:2011年1月8日

ORM ¶ T0>

  • [orm] Fixed bug whereby a non-“mutable” attribute modified event which occurred on an object that was clean except for preceding mutable attribute changes would fail to strongly reference itself in the identity map. 这会导致对象被垃圾收集,失去了以前未保存在“可变更改”字典中的任何更改的跟踪。

  • [orm] Fixed bug whereby “passive_deletes=’all’” wasn’t passing the correct symbols to lazy loaders during flush, thereby causing an unwarranted load.

    参考文献:#2013

  • [orm] 修正了阻止在映射的select语句上使用复合映射属性的错误。注意复合材料的工作原理将在0.7下显着改变。

    参考文献:#1997

  • [orm] active_history标志也被添加到了composite()中。该标志在0.6中没有效果,但是它是一个用于向前兼容的占位符标志,因为它适用于复合材料的0.7.

    参考文献:#1976

  • 修正了传递给Session.delete()的过期对象在删除对象时没有考虑到卸载的引用或集合的缺陷,尽管passive_deletes保持默认的False状态。[orm] T2>

    参考文献:#2002

  • [orm] 当继承映射器上指定version_id_col时,如果这些列表达式不相同,则会发出警告。

    参考文献:#1987

  • [orm] “innerjoin” flag doesn’t take effect along the chain of joinedload() joins if a previous join in that chain is an outer join, thus allowing primary rows without a referenced child row to be correctly returned in results.

    参考文献:#1954

  • [orm] Fixed bug regarding “subqueryload” strategy whereby strategy would fail if the entity was an aliased() construct.

    参考文献:#1964

  • [orm] Fixed bug regarding “subqueryload” strategy whereby the join would fail if using a multi-level load of the form from A->joined-subclass->C

    参考文献:#2014

  • [orm] 固定Query对象的索引值-1。它被错误地转换为导致IndexError的空片-1:0.

    参考文献:#1968

  • [orm] mapper参数“primary_key”可以作为单个列以及列表或元组传递。将其说明为标量值的文档示例已更改为列表。

    参考文献:#1971

  • [orm] Added active_history flag to relationship() and column_property(), forces attribute events to always load the “old” value, so that it’s available to attributes.get_history().

    参考文献:#1961

  • [orm] 如果组合键中的参数数量太大,而且太小,则会引发Query.get()。

    参考文献:#1977

  • [orm] 从0.7开始的“优化get”修复的后退,改善了加入继承“load expired row”行为的生成。

    参考文献:#1992

  • [orm] A little more verbiage to the “primaryjoin” error, in an unusual condition that the join condition “works” for viewonly but doesn’t work for non-viewonly, and foreign_keys wasn’t used - adds “foreign_keys” to the suggestion. 也可以将“foreign_keys”添加到通用“方向”错误的建议中。

发动机¶ T0>

  • [engine] 现在,仅当明确使用Unicode类型时,才会引发针对非Unicode绑定数据的“unicode警告”;而不是在引擎或字符串类型上使用convert_unicode = True时

  • [engine] 固定内存泄漏在C版本的十进制结果处理器中。

    参考文献:#1978

  • [engine] 为RowProxy的C版本实现了序列检查功能,为RowProxy的2.7样式“collections.Sequence”注册。

    参考文献:#1871

  • [engine] Threadlocal engine methods rollback(), commit(), prepare() won’t raise if no transaction is in progress; this was a regression introduced in 0.6.

    参考文献:#1998

  • [engine] Threadlocal engine returns itself upon begin(), begin_nested(); engine then implements contextmanager methods to allow the “with” statement.

    参考文献:#2004

SQL ¶ T0>

  • [sql] 修复了单个非关联运算符的多个链的运算符优先规则。即“x - (y - z)”将编译为“x - (y - z)”而不是“x - y - z”。也适用于标签,即“x - (y - z).label('foo')”

    参考文献:#1984

  • [sql] The ‘info’ attribute of Column is copied during Column.copy(), i.e. as occurs when using columns in declarative mixins.

    参考文献:#1967

  • [sql] 为布尔值增加了一个绑定处理器,这些布尔值强制为int,而DBAPI如pymssql在值上天真地调用str()。

  • [sql] CheckConstraint will copy its ‘initially’, ‘deferrable’, and ‘_create_rule’ attributes within a copy()/tometadata()

    参考文献:#2000

的PostgreSQL ¶ T0>

  • [postgresql] IN子句中的单元素元组表达式正确地括起来,也来自

    参考文献:#1984

  • [postgresql] 确保psycopg2和pg8000的“数字”基本类型能够识别每个数字,浮点数,整型代码和标量数组。

    参考文献:#1955

  • [postgresql] 将asuuid = True标志添加到UUID类型,将以Python UUID()对象而不是字符串的形式接收和返回值。目前,UUID类型只能用于psycopg2.

    参考文献:#1956

  • [postgresql] 修正了在池配置+重新创建之后会发生KeyError的非ENUM支持PG版本的问题。

    参考文献:#1989

MySQL的¶ T0>

  • [mysql] 修复了Jython + zxjdbc的错误处理问题,使得has_table()属性再次运行。从0.6.3回归(我们没有Jython buildbot,对不起)

    参考文献:#1960

源码¶ T0>

  • [sqlite] CREATE TABLE中的REFERENCES子句,包含具有相同模式名称的另一个表的远程模式,现在根据SQLite的要求呈现没有模式子句的远程名称¶< / T2>

    参考文献:#1851

  • [sqlite] On the same theme, the REFERENCES clause in a CREATE TABLE that includes a remote schema to a different schema than that of the parent table doesn’t render at all, as cross-schema references do not appear to be supported.

MSSQL ¶ T0>

  • [mssql] 不幸的是没有正确地测试索引反射的重写,并返回了不正确的结果。现在这个回归是固定的。

    参考文献:#1770

预言¶ T0>

  • [oracle] 现在使用由语言环境/ NLS_LANG设置确定的小数点字符的cx_oracle“十进制检测”逻辑,它使用具有模糊数字特征的结果集列,连接这个字符的检测。使用非周期小数点NLS_LANG设置时,还需要cx_oracle 5.0.3或更高版本。

    参考文献:#1953

火鸟¶ T0>

  • [firebird] Firebird numeric type now checks for Decimal explicitly, lets float() pass right through, thereby allowing special values such as float(‘inf’).

    参考文献:#2012

杂项¶ T0>

  • [declarative] 如果__table_args__不是tuple或dict格式,并且不是None,则会产生错误。

    参考文献:#1972

  • [sqlsoup] Added “map_to()” method to SqlSoup, which is a “master” method which accepts explicit arguments for each aspect of the selectable and mapping, including a base class per mapping.

    参考文献:#1975

  • [sqlsoup] 与map(),with_labels(),join()方法一起使用的mapable selectables不再将给定的参数放到内部的“cache”字典中。特别是由于join()和select()对象是在方法本身中创建的,这几乎是纯粹的内存泄漏行为。

  • [examples] 版本示例现在支持检测关联关系()中的更改。

0.6.5 ¶ T0>

发布日期:2010年10月24日

ORM ¶ T0>

  • [orm] 添加了一个新的“lazyload”选项“immediateload”。在填充对象时自动发出通常的“懒惰”加载操作。这里的用例是加载要放置在脱机缓存中的对象,或者在会话不可用之后以其他方式使用,并且希望直接“选择”加载,而不是“加入”或“子查询”。¶ T0>

    参考文献:#1914

  • [orm] New Query methods: query.label(name), query.as_scalar(), return the query’s statement as a scalar subquery with /without label; query.with_entities(*ent), replaces the SELECT list of the query with new entities. 大致相当于query.values()的生成形式,它接受映射的实体以及列表达式。

    参考文献:#1920

  • [orm] Fixed recursion bug which could occur when moving an object from one reference to another, with backrefs involved, where the initiating parent was a subclass (with its own mapper) of the previous parent.

  • [orm] Fixed a regression in 0.6.4 which occurred if you passed an empty list to “include_properties” on mapper()

    参考文献:#1918

  • [orm] 在Query中固定标签错误,NamedTuple会在任何列表达式未标记时错误应用标签。

  • [orm] 修补了query.join()将不恰当地调整左侧连接的右侧到右侧的情况

    参考文献:#1925

  • [orm] Query.select_from() has been beefed up to help ensure that a subsequent call to query.join() will use the select_from() entity, assuming it’s a mapped entity and not a plain selectable, as the default “left” side, not the first entity in the Query object’s list of entities.

  • [orm] The exception raised by Session when it is used subsequent to a subtransaction rollback (which is what happens when a flush fails in autocommit=False mode) has now been reworded (this is the “inactive due to a rollback in a subtransaction” message). 特别是,如果回滚是由flush()期间的异常引起的,则消息说明是这种情况,并重申在刷新期间发生的原始异常的字符串形式。如果会话由于明确使用了子事务(不是很常见)而被关闭,那么消息只是说明了这种情况。

  • [orm] The exception raised by Mapper when repeated requests to its initialization are made after initialization already failed no longer assumes the “hasattr” case, since there’s other scenarios in which this message gets emitted, and the message also does not compound onto itself multiple times - you get the same message for each attempt at usage. “编译”这个用词不当的情况正在被用于“初始化”。

  • [orm] Fixed bug in query.update() where ‘evaluate’ or ‘fetch’ expiration would fail if the column expression key was a class attribute with a different keyname as the actual column name.

    参考文献:#1935

  • [orm] 在刷新过程中添加了一个断言,确保在“新持久性”对象上不生成持有空值的身份密钥。这可能发生在用户定义的代码无意中触发未完全加载的对象上的刷新。

  • [orm] lazy loads for relationship attributes now use the current state, not the “committed” state, of foreign and primary key attributes when issuing SQL, if a flush is not in process. 以前,只会使用数据库提交状态。特别是,这会导致多对一的get() - on-lazyload操作失败,因为当这些属性被确定并且“提交”状态可能不可用时,autoflush不会在这些负载上触发。¶ T0>

    参考文献:#1910

  • [orm] A new flag on relationship(), load_on_pending, allows the lazy loader to fire off on pending objects without a flush taking place, as well as a transient object that’s been manually “attached” to the session. 请注意,此标志会阻止加载对象时发生的属性事件,因此直到冲刷后才能使用backrefs。该标志仅用于非常具体的用例。

  • [orm] Another new flag on relationship(), cascade_backrefs, disables the “save-update” cascade when the event was initiated on the “reverse” side of a bidirectional relationship. 这是一种更清晰的行为,因此可以将多对一设置为临时对象,而不会将其吸引到子对象的会话中,同时仍允许向前集合级联。我们可能在0.7中默认为False。

  • [orm] 当仅放置在关系的多对一侧时,对“passive_updates = False”的行为稍作改进;文档已经澄清,passive_updates = False应该是一对多的。

  • [orm] 在多对一的情况下放置passive_deletes = True会发出警告,因为您可能打算将它放在一对多的一面。

  • [orm] Fixed bug that would prevent “subqueryload” from working correctly with single table inheritance for a relationship from a subclass - the “where type in (x, y, z)” only gets placed on the inside, instead of repeatedly.

  • [orm] When using from_self() with single table inheritance, the “where type in (x, y, z)” is placed on the outside of the query only, instead of repeatedly. 可以对此进行更多的调整。

  • [orm] scoped_session emits a warning when configure() is called if a Session is already present (checks only the current thread)

    参考文献:#1924

  • [orm] reworked the internals of mapper.cascade_iterator() to cut down method calls by about 9% in some circumstances.

    参考文献:#1932

发动机¶ T0>

  • [engine] 固定了0.6.4中的回归,因此允许光标错误一致的更改一直打破了result.lastrowid访问器。已为result.lastrowid添加了测试覆盖率。请注意,lastrowid仅由Pysqlite和一些MySQL驱动程序支持,因此在一般情况下不会超级有用。

  • [engine] the logging message emitted by the engine when a connection is first used is now “BEGIN (implicit)” to emphasize that DBAPI has no explicit begin().

  • [engine] 在metadata.reflect()中添加了“views = True”选项,将可用视图的列表添加到正在反映的视图中。

    参考文献:#1936

  • [engine] engine_from_config() now accepts ‘debug’ for ‘echo’, ‘echo_pool’, ‘force’ for ‘convert_unicode’, boolean values for ‘use_native_unicode’.

    参考文献:#1899

SQL ¶ T0>

  • [sql] Fixed bug in TypeDecorator whereby the dialect-specific type was getting pulled in to generate the DDL for a given type, which didn’t always return the correct result.

  • [sql] TypeDecorator can now have a fully constructed type specified as its “impl”, in addition to a type class.

  • [sql] TypeDecorator will now place itself as the resulting type for a binary expression where the type coercion rules would normally return its impl type - previously, a copy of the impl type would be returned which would have the TypeDecorator embedded into it as the “dialect” impl, this was probably an unintentional way of achieving the desired effect.

  • [sql] TypeDecorator.load_dialect_impl() returns “self.impl” by default, i.e. not the dialect implementation type of “self.impl”. 这可以正确支持编译。行为可以像以前一样以相同的方式被用户覆盖,达到同样的效果。

  • [sql] 添加了type_coerce(expr,type_)表达式元素。在评估表达式和处理结果行时将给定表达式视为给定类型,但不影响除匿名标签之外的SQL生成。

  • [sql] Table.tometadata() now copies Index objects associated with the Table as well.

  • [sql] Table.tometadata() issues a warning if the given Table is already present in the target MetaData - the existing Table object is returned.

  • [sql] An informative error message is raised if a Column which has not yet been assigned a name, i.e. as in declarative, is used in a context where it is exported to the columns collection of an enclosing select() construct, or if any construct involving that column is compiled before its name is assigned.

  • [sql] as_scalar(), label() can be called on a selectable which contains a Column that is not yet named.

    参考文献:#1862

  • [sql] Fixed recursion overflow which could occur when operating with two expressions both of type “NullType”, but not the singleton NULLTYPE instance.

    参考文献:#1907

的PostgreSQL ¶ T0>

  • [postgresql] 将“as_tuple”标志添加到ARRAY类型,并将结果作为元组返回,而不是列表以允许哈希。

  • [postgresql] 修正了防止自定义类型(例如“enum”)构建的“域”被反射的错误。

    参考文献:#1933

MySQL的¶ T0>

  • [mysql] Fixed bug involving reflection of CURRENT_TIMESTAMP default used with ON UPDATE clause, thanks to Taavi Burns

    参考文献:#1940

MSSQL ¶ T0>

  • [mssql] 修正了未能正确处理未知类型反射的反射问题。

    参考文献:#1946

  • [mssql] 修正了使用“schema”对表进行别名失败时无法正确编译的错误。

    参考文献:#1943

  • [mssql] 重写索引的反射以使用sys。目录,以便任何配置的列名(空格,嵌入逗号等)可以反映出来。请注意,索引的反映需要SQL Server 2005或更高版本。

    参考文献:#1770

  • [mssql] 现在mssql + pymssql方言尊重URL的“端口”部分,而不是放弃它。

    参考文献:#1952

预言¶ T0>

  • [oracle] 无论检测到Oracle的版本,现在都可以使用create_engine()的implicit_retunring参数。以前,如果服务器版本信息<10,那么该标志将被强制为False。

    参考文献:#1878

杂项¶ T0>

  • [declarative] @classproperty(很快/现在@declared_attr)对不是mixin的基类中的__mapper_args__,__table_args__,__tablename__生效,以及mixins

    参考文献:#1922

  • [declarative] @classproperty ‘s official name/location for usage with declarative is sqlalchemy.ext.declarative.declared_attr. 同样的事情,但它在那里移动,因为它更像是一个特定于声明的“标记”,而不仅仅是一种属性技术。

    参考文献:#1915

  • [declarative] Fixed bug whereby columns on a mixin wouldn’t propagate correctly to a single-table, or joined-table, inheritance scheme where the attribute name is different than that of the column.,.

    参考文献:#1931#1930

  • [declarative] 现在,mixin可以指定一个覆盖与超类关联的同名列的列。感谢Oystein Haaland。

  • [informix] 主要清理/更新Informix方言0.6,礼貌Florian Apolloner。

    参考文献:#1906

  • [tests] NoseSQLAlchemyPlugin已经被移动到一个新的包“sqlalchemy_nose”中,它与“sqlalchemy”一起安装。这样,“nosetests”脚本将一如既往地工作,但也允许-with-coverage选项在导入SQLAlchemy模块之前打开覆盖范围,从而使coverage能够正常工作。

  • [misc] CircularDependencyError now has .cycles and .edges members, which are the set of elements involved in one or more cycles, and the set of edges as 2-tuples.

    参考文献:#1890

0.6.4 ¶ T0>

发布于:2010年9月07日

ORM ¶ T0>

  • [orm] 名称ConcurrentModificationError已更改为StaleDataError,并且已修改描述性错误消息以准确反映问题所在。对于可能在“except:”子句中指定ConcurrentModificationError的方案,这两个名称仍可用于可预见的未来。

  • [orm] 为身份映射添加了一个互斥体,该互斥体可以针对迭代方法移除操作,而迭代方法现在在返回可迭代之前预缓冲。这是因为asyncrhonous gc可以随时通过gc线程移除项目。

    参考文献:#1891

  • [orm] Session类现在存在于sqlalchemy.orm。*中。对于那些需要一步式Session构造函数的情况,我们不再使用具有非标准默认值的create_session()。然而,大多数用户应该坚持使用sessionmaker()。

  • [orm] query.with_parent() now accepts transient objects and will use the non-persistent values of their pk/fk attributes in order to formulate the criterion. 文档还阐明了with_parent()。的用途

  • [orm] 除了字符串之外,mapper()的include_properties和exclude_properties参数现在还接受Column对象作为成员。这样可以区分名称相同的Column对象,例如join()中的对象。

  • [orm] 如果映射器是针对连接或其他单个可选项(包含多个在其.c中具有相同名称的列)创建的,则会发出警告。集合,并且这些列没有明确命名为相同或独立属性的一部分(或排除在外)。在0.7这个警告将是一个例外。请注意,由于继承而导致组合发生时,不会发出此警告,因此属性仍允许自然被覆盖。在0.7中,这会进一步改善。

    参考文献:#1896

  • [orm] mapper()的primary_key参数现在可以指定一系列列,它们只是映射可选项的计算“主键”列的子集,不会引发错误。这有助于可选择的有效主键比可选中实际标记为“primary_key”的列的数量更简单的情况,例如与主键列上的两个表的联接。

    参考文献:#1896

  • [orm] An object that’s been deleted now gets a flag ‘deleted’, which prohibits the object from being re-add()ed to the session, as previously the object would live in the identity map silently until its attributes were accessed. make_transient()函数现在会重置此标志以及“key”标志。

  • [orm] make_transient()可以在已经是瞬态的实例上安全地调用。

  • [orm] a warning is emitted in mapper() if the polymorphic_on column is not present either in direct or derived form in the mapped selectable or in the with_polymorphic selectable, instead of silently ignoring it. 寻找这个在0.7中成为例外。

  • [orm] Another pass through the series of error messages emitted when relationship() is configured with ambiguous arguments. “foreign_keys”设置不再提及,因为它几乎不需要,因此用户最好设置正确的ForeignKey元数据,这是现在的建议。如果使用'foreign_keys'并且不正确,则消息表明该属性可能是不必要的。该属性的文档得到了加强。这是因为ML上的所有混淆的关系()用户似乎都尝试使用foreign_keys,这是由于表元数据更加清晰,这只会使他们更加混淆。

  • [orm] If the “secondary” table has no ForeignKey metadata and no foreign_keys is set, even though the user is passing screwed up information, it is assumed that primary/secondaryjoin expressions should consider only and all cols in “secondary” to be foreign. 在任何情况下,外键都不在其他位置。现在发出警告而不是错误,并且映射成功。

    参考文献:#1877

  • [orm] Moving an o2m object from one collection to another, or vice versa changing the referenced object by an m2o, where the foreign key is also a member of the primary key, will now be more carefully checked during flush if the change in value of the foreign key on the “many” side is the result of a change in the primary key of the “one” side, or if the “one” is just a different object. 在一个案例中,级联数据库可能已经级联了该值,我们需要查看“新”PK值来执行UPDATE,而另一个我们需要继续查看“旧”数据库。我们现在看一下“旧”,假设passive_updates = True,除非我们知道这是一个PK开关触发了这个变化。

    参考文献:#1856

  • [orm] version_id_col的值可以手动更改,这将导致该行的UPDATE。版本化的UPDATE和DELETE现在使用WHERE子句中的version_id_col的“落实”值,而不是挂起的更改值。如果在属性上存在手动更改,版本生成器也会被绕过。

    参考文献:#1857

  • [orm] 在与具体继承映射器一起使用时修复了merge()的用法。这样的映射器通常具有所谓的“具体”属性,这些属性是“禁止”父级传播的子类属性 - 这些属性允许merge()操作无需通过就可以传递。

  • [orm] Specifying a non-column based argument for column_mapped_collection, including string, text() etc., will raise an error message that specifically asks for a column element, no longer misleads with incorrect information about text() or literal().

    参考文献:#1863

  • [orm] Similarly, for relationship(), foreign_keys, remote_side, order_by - all column-based expressions are enforced - lists of strings are explicitly disallowed since this is a very common error

  • [orm] Dynamic attributes don’t support collection population - added an assertion for when set_committed_value() is called, as well as when joinedload() or subqueryload() options are applied to a dynamic attribute, instead of failure / silent failure.

    参考文献:#1864

  • [orm] Fixed bug whereby generating a Query derived from one which had the same column repeated with different label names, typically in some UNION situations, would fail to propagate the inner columns completely to the outer query.

    参考文献:#1852

  • [orm] object_session() raises the proper UnmappedInstanceError when presented with an unmapped instance.

    参考文献:#1881

  • [orm] 对计算的Mapper属性应用进一步的记忆,在大量多态映射配置中,重要的(〜90%)运行时mapper.py调用计数减少。

  • [orm] 版本控制示例使用的mapper _get_col_to_prop私有方法已被弃用;现在使用mapper.get_property_by_column(),它仍然是公共方法。

  • [orm] 版本控制示例现在可以正常工作,如果在以前为NULL的col上进行版本控制。

发动机¶ T0>

  • [engine] Calling fetchone() or similar on a result that has already been exhausted, has been closed, or is not a result-returning result now raises ResourceClosedError, a subclass of InvalidRequestError, in all cases, regardless of backend. 以前,一些DBAPI会引发ProgrammingError(即pysqlite),而其他DBAPI会返回None导致下游破坏(即MySQL-python)。

  • [engine] Fixed bug in Connection whereby if a “disconnect” event occurred in the “initialize” phase of the first connection pool connect, an AttributeError would be raised when the Connection would attempt to invalidate the DBAPI connection.

    参考文献:#1894

  • [engine] 连接,ResultProxy以及Session使用ResourceClosedError为所有“此连接/事务/结果为关闭”类型的错误。

  • [engine] 可以多次调用Connection.invalidate(),随后的调用什么也不做。

SQL ¶ T0>

  • [sql] Calling execute() on an alias() construct is pending deprecation for 0.7, as it is not itself an “executable” construct. 它目前“代理”了它的内部元素,并且有条件地“可执行”,但这并不是我们现在喜欢的那种模糊性。

  • [sql] ClauseElement的execute()和scalar()方法现在可以适当地移动到Executable子类中。ClauseElement.execute()/ scalar()仍然存在,并且在0.7中处于待弃用状态,但是请注意,如果您不是可执行文件,它们总是会引发错误(除非您是别名(),请参阅前面的注释)¶ T0>

  • [sql] 为Numeric-> Integer添加了基本的数学表达式强制,所以无论表达式的方向如何,结果类型都是Numeric。

  • [sql] 在列上使用“index = True”标志时,更改了用于生成截断的“auto”索引名称的方案。截断只能使用自动生成的名称进行,而不是用户定义的名称(而不是用户定义的错误),截断方案本身现在基于标识符名称的md5哈希碎片,因此具有相似名称的列上的多个索引仍具有唯一名称。

    参考文献:#1855

  • [sql] The generated index name also is based on a “max index name length” attribute which is separate from the “max identifier length” - this to appease MySQL who has a max length of 64 for index names, separate from their overall max length of 255.

    参考文献:#1412

  • [sql] the text() construct, if placed in a column oriented situation, will at least return NULLTYPE for its type instead of None, allowing it to be used a little more freely for ad-hoc column expressions than before. 然而,literal_column()仍然是更好的选择。

  • [sql] 当ForeignKey无法解析目标时,添加对父表/列,目标表/列的错误消息中的完整描述

  • [sql] Fixed bug whereby replacing composite foreign key columns in a reflected table would cause an attempt to remove the reflected constraint from the table a second time, raising a KeyError.

    参考文献:#1865

  • [sql] the _Label construct, i.e. the one that is produced whenever you say somecol.label(), now counts itself in its “proxy_set” unioned with that of its contained column’s proxy set, instead of directly returning that of the contained column. 这允许依赖于_Labels本身身份的列对应操作返回正确的结果

  • [sql] 修复了ORM bug。

    参考文献:#1852

的PostgreSQL ¶ T0>

  • [postgresql] Fixed the psycopg2 dialect to use its set_isolation_level() method instead of relying upon the base “SET SESSION ISOLATION” command, as psycopg2 resets the isolation level on each new transaction otherwise.

MSSQL ¶ T0>

  • [mssql] 修正了“default schema”查询与pymssql后端一起工作的问题。

预言¶ T0>

  • [oracle] 对于那些可能需要显式CAST的情况,向Oracle方言添加ROWID类型。

    参考文献:#1879

  • [oracle] Oracle reflection of indexes has been tuned so that indexes which include some or all primary key columns, but not the same set of columns as that of the primary key, are reflected. 包含与主键相同的列的索引在反射内跳过,因为在这种情况下索引被假定为自动生成的主键索引。以前,PK列存在的任何索引都会被跳过。感谢Kent Bower提供的补丁。

    参考文献:#1867

  • [oracle] Oracle now reflects the names of primary key constraints - also thanks to Kent Bower.

    参考文献:#1868

火鸟¶ T0>

  • [firebird] 修正了列默认值无法反映“default”关键字是否为小写的错误。

杂项¶ T0>

  • [declarative] 如果@classproperty与常规的类绑定映射器属性属性一起使用,它将被调用以获取初始化期间的实际属性值。目前,对不是混合的声明类的列或关系属性使用@classproperty没有好处 - 评估与不使用@classproperty同时进行。但是,我们至少允许它按预期运行。

  • [declarative] 修正了“无法添加额外列”消息的错误名称。

  • [informix] 应用补丁程序以再次获得基本的Informix功能。我们依靠最终用户测试来确保Informix在某种程度上有效。

    参考文献:#1904

  • [documentation] The docs have been reorganized such that the “API Reference” section is gone - all the docstrings from there which were public API are moved into the context of the main doc section that talks about it. 主要文档分为“SQLAlchemy Core”和“SQLAlchemy ORM”部分,映射器/关系文档已被打破。许多部分被重写和/或重组。

  • [examples] The beaker_caching example has been reorganized such that the Session, cache manager, declarative_base are part of environment, and custom cache code is portable and now within “caching_query.py”. 这使得该示例可以更容易地“插入”现有项目。

  • [examples] 复制列时,history_meta版本控制配方设置“unique = False”,以便版本控制表处理多个具有重复值的行。

    参考文献:#1887

0.6.3 ¶ T0>

发布日期:2010年7月15日

ORM ¶ T0>

  • [orm] 在单元工作中删除了错误的多对多加载,这些加载在过期/卸载集合上不必要地触发。只有在passive_updates为False并且父主键已更改,或者passive_deletes为False并且已发生父项删除时,此加载现在才会发生。

    参考文献:#1845

  • [orm] Column-entities (i.e. query(Foo.id)) copy their state more fully when queries are derived from themselves + a selectable (i.e. from_self(), union(), etc. ),所以join()等具有正确的工作状态。

    参考文献:#1853

  • [orm] Fixed bug where Query.join() would fail if querying a non-ORM column then joining without an on clause when a FROM clause is already present, now raises a checked exception the same way it does when the clause is not present.

    参考文献:#1853

  • [orm] 改进了对“未映射类”的检查,包括超类映射但子类不是的情况。任何尝试访问cls._sa_class_manager.mapper的尝试都会引发UnmappedClassError()。

    参考文献:#1142

  • [orm] Added “column_descriptions” accessor to Query, returns a list of dictionaries containing naming/typing information about the entities the Query will return. 可以有助于在ORM查询之上构建GUI。

MySQL的¶ T0>

  • [mysql] The _extract_error_code() method now works correctly with each MySQL dialect ( MySQL-python, OurSQL, MySQL-Connector-Python, PyODBC). 以前,重新连接逻辑会失败的OperationalError条件,但由于MySQLdb和OurSQL有自己的重新连接功能,这里没有这些驱动程序的症状,除非有人观看日志。

    参考文献:#1848

预言¶ T0>

  • [oracle] 更多调整为cx_oracle十进制处理。不含小数位的“模糊”数字在连接处理程序级被强制为int。这样做的好处是,ints会以int参数的形式返回,而不会涉及SQLA类型的对象,并且不会首先转换为Decimal。

    不幸的是,一些外来的子查询情况甚至可能会在各个结果行之间看到不同的类型,所以当指示返回Decimal时,Numeric处理程序不能充分利用“native decimal”模式,并且必须对每个值运行isinstance()如果它的Decimal已经。重新开放

    参考文献:#1840

0.6.2 ¶ T0>

发布日期:2010年7月6日

ORM ¶ T0>

  • [orm] Query.join() will check for a call of the form query.join(target, clause_expression), i.e. missing the tuple, and raise an informative error message that this is the wrong calling form.

  • [orm] Fixed bug regarding flushes on self-referential bi-directional many-to-many relationships, where two objects made to mutually reference each other in one flush would fail to insert a row for both sides. 从0.5开始回归。

    参考文献:#1824

  • [orm] the post_update feature of relationship() has been reworked architecturally to integrate more closely with the new 0.6 unit of work. 更改的动机是,每个影响同一行的不同外键列的多个“更新后”调用在单个UPDATE语句中执行,而不是每行每列一个UPDATE语句。在保持一致的行排序的同时,多行更新也被批量分配到executemany()中。

  • [orm] Query.statement,Query.subquery()等现在将绑定参数的值(即query.params()指定的值)转移到生成的SQL表达式中。以前,这些值不会被传送,绑定参数会显示为None。

  • [orm] 子查询-eager-loading现在可以与包含params()以及get()查询的Query对象一起使用。

  • [orm] Can now call make_transient() on an instance that is referenced by parent objects via many-to-one, without the parent’s foreign key value getting temporarily set to None - this was a function of the “detect primary key switch” flush handler. 它现在忽略不再处于“持久”状态的对象,并且父母的外键标识符不受影响。

  • [orm] query.order_by() now accepts False, which cancels any existing order_by() state on the Query, allowing subsequent generative methods to be called which do not support ORDER BY. 这与传递None的已有功能不同,后者禁止任何现有的order_by()设置,包括映射器上配置的那些设置。False将使得它好像从未调用过order_by(),而None是一个有效的设置。

  • [orm] An instance which is moved to “transient”, has an incomplete or missing set of primary key attributes, and contains expired attributes, will raise an InvalidRequestError if an expired attribute is accessed, instead of getting a recursion overflow.

  • [orm] make_transient()函数现在位于生成的文档中。

  • [orm] make_transient() removes all “loader” callables from the state being made transient, removing any “expired” state - all unloaded attributes reset back to undefined, None/empty on access.

SQL ¶ T0>

  • [sql] 具有convert_unicode = True的Unicode和String类型发出的警告不再嵌入传递的实际值。这样,Python警告注册表的大小不会继续增加,警告会按照警告过滤器设置发出一次,并且大字符串值不会污染输出。

    参考文献:#1822

  • [sql] Fixed bug that would prevent overridden clause compilation from working for “annotated” expression elements, which are often generated by the ORM.

  • [sql] LIKE运算符或类似语句的“ESCAPE”参数通过render_literal_value()传递,该函数可能会实现反斜杠的转义。

    参考文献:#1400

  • [sql] Fixed bug in Enum type which blew away native_enum flag when used with TypeDecorators or other adaption scenarios.

  • [sql] Inspector hits bind.connect() when invoked to ensure initialize has been called. 内部名称“.conn”更改为“.bind”,因为它就是这样。

  • [sql] Modified the internals of “column annotation” such that a custom Column subclass can safely override _constructor to return Column, for the purposes of making “configurational” column classes that aren’t involved in proxying, etc.

  • [sql] Column.copy() takes along the “unique” attribute among others, fixes regarding declarative mixins

    参考文献:#1829

的PostgreSQL ¶ T0>

  • [postgresql] render_literal_value()被重写,它们转义反斜杠,当前应用于LIKE和类似表达式的ESCAPE子句。最终,这将必须检测“standard_conforming_strings”的完整行为的价值。

    参考文献:#1400

  • [postgresql] 如果在8.3版之前的PG版本中使用types.Enum,则不会生成“CREATE TYPE”/“DROP TYPE” - supports_native_enum标志完全符合要求¶ t2 >

    参考文献:#1836

MySQL的¶ T0>

  • [mysql] 对于检测到的MySQL版本,MySQL方言不会发出CAST()<4.0.2。这允许在连接上进行unicode检查。

    参考文献:#1826

  • [mysql] 除了ANSI_QUOTES之外,MySQL方言现在还检测NO_BACKSLASH_ESCAPES sql模式。

  • [mysql] render_literal_value()被覆盖,其中转义反斜杠,目前适用于LIKE和类似表达式的ESCAPE子句。此行为源于检测NO_BACKSLASH_ESCAPES的值。

    参考文献:#1400

MSSQL ¶ T0>

  • [mssql] If server_version_info is outside the usual range of (8, ), (9, ), (10, ), a warning is emitted which suggests checking that the FreeTDS version configuration is using 7.0 or 8.0, not 4.2.

    参考文献:#1825

预言¶ T0>

  • [oracle] 修复了ora-8兼容性标志,使得它们不会在实际发生第一个数据库连接之前缓存陈旧值。

    参考文献:#1819

  • [oracle] Oracle’s “native decimal” metadata begins to return ambiguous typing information about numerics when columns are embedded in subqueries as well as when ROWNUM is consulted with subqueries, as we do for limit/offset. 我们已经将这些不明确的条件添加到cx_oracle“convert to Decimal()”处理程序中,以便我们在更多情况下接收数字作为Decimal,而不是作为浮点数。如果需要的话,它们将被转换为Integer或Float,或者保留为无损Decimal。

    参考文献:#1840

火鸟¶ T0>

  • [firebird] 修复了do_execute()中的错误签名,0.6.1中引入了错误。

    参考文献:#1823

  • [firebird] Firebird dialect adds CHAR, VARCHAR types which accept a “charset” flag, to support Firebird “CHARACTER SET” clause.

    参考文献:#1813

杂项¶ T0>

  • [declarative] Added support for @classproperty to provide any kind of schema/mapping construct from a declarative mixin, including columns with foreign keys, relationships, column_property, deferred. 这解决了声明性混合中的所有这些问题。如果在mixin上指定了任何MapperProperty子类而不使用@classproperty,则会产生错误。

    References: #1805, #1796, #1751

  • [declarative] a mixin class can now define a column that matches one which is present on a __table__ defined on a subclass. 但是,它不能定义__table__中不存在的错误消息,现在这里的错误消息可以工作。

    参考文献:#1821

  • [extension] [compiler] 当重写编译内置子句结构时,会自动复制'default'编译器,所以如果用户定义的编译器特定于某些后端,则不会引发KeyError,调用另一个后端的编译。

    参考文献:#1838

  • [documentation] 添加了Inspector的文档。

    参考文献:#1820

  • [documentation] Fixed @memoized_property and @memoized_instancemethod decorators so that Sphinx documentation picks up these attributes and methods, such as ResultProxy.inserted_primary_key.

    参考文献:#1830

0.6.1 ¶ T0>

发布时间:2010年5月31日

ORM ¶ T0>

  • [orm] 修正0.6.0中引入的回归,其中涉及对可变属性进行不当历史记录。

    参考文献:#1782

  • [orm] Fixed regression introduced in 0.6.0 unit of work refactor that broke updates for bi-directional relationship() with post_update=True.

    参考文献:#1807

  • [orm] session.merge()不会在返回的实例上过期,如果该实例是“挂起”的话。

    参考文献:#1789

  • [orm] 修正了CollectionAdapter的__setstate__方法在反序列化中不失败,其中父InstanceState尚未反序列化

    参考文献:#1802

  • [orm] 添加内部警告,以防万一没有完整PK的实例发生过期并被要求刷新。

    参考文献:#1797

  • [orm] 为映射器对UPDATE,INSERT和DELETE表达式的使用增加了更积极的缓存。假设该语句没有附加每个对象的SQL表达式,表达式对象在第一次创建之后由映射器进行高速缓存,并且其编译后的表单在相关引擎期间持久存储在高速缓存字典中。缓存是一个LRUCache,极少数情况下,映射程序接收的数据量非常大,不同的列模式为UPDATE。

SQL ¶ T0>

  • [sql] expr.in_()现在接受一个text()构造作为参数。分组括号会自动添加,即用法如col.in_(text(“select id from table”))

    参考文献:#1793

  • [sql] Columns of _Binary type (i.e. LargeBinary, BLOB, etc.) 将右侧的“basestring”强制转换为_Binary,因此需要进行DBAPI处理。

  • [sql] 添加了table.add_is_dependent_on(othertable),允许在两个表对象之间手动放置依赖关系规则,以便在create_all(),drop_all(),sorted_tables中使用。

    参考文献:#1801

  • [sql] 修正了防止隐式RETURNING与包含零的组合主键正常工作的错误。

    参考文献:#1778

  • [sql] Fixed errant space character when generating ADD CONSTRAINT for a named UNIQUE constraint.

  • [sql] Fixed “table” argument on constructor of ForeginKeyConstraint

    参考文献:#1571

  • [sql] Fixed bug in connection pool cursor wrapper whereby if a cursor threw an exception on close(), the logging of the message would fail.

    参考文献:#1786

  • [sql] the _make_proxy() method of ColumnClause and Column now use self.__class__ to determine the class of object to be returned instead of hardcoding to ColumnClause/Column, making it slightly easier to produce specific subclasses of these which work in alias/subquery situations.

  • [sql] func.XXX() doesn’t inadvertently resolve to non-Function classes (e.g. fixes func.text()).

    参考文献:#1798

MySQL的¶ T0>

  • [mysql] func.sysdate()在MySQL上发出“SYSDATE()”,即结尾括号。

    参考文献:#1794

源码¶ T0>

  • [sqlite] 修正了由于SQLite AUTOINCREMENT关键字被渲染而导致“PRIMARY KEY”约束移动到列级别时约束的串联约束。

    参考文献:#1812

预言¶ T0>

  • [oracle] 添加了对低于版本5的cx_oracle版本的检查,在这种情况下不会使用不兼容的“输出类型处理程序”。这会影响十进制精度和一些unicode处理问题。

    参考文献:#1775

  • [oracle] 修复了use_ansi = False模式,在几乎所有情况下都产生了破碎的WHERE子句。

    参考文献:#1790

  • [oracle] Re-established support for Oracle 8 with cx_oracle, including that use_ansi is set to False automatically, NVARCHAR2 and NCLOB are not rendered for Unicode, “native unicode” check doesn’t fail, cx_oracle “native unicode” mode is disabled, VARCHAR() is emitted with bytes count instead of char count.

    参考文献:#1808

  • [oracle] 在正常的Python 2.x模式下,oracle_xe 5在其连接字符串中不接受Python unicode对象 - 所以我们直接对str()进行强制转换。在这里连接字符串不支持非ascii字符,因为我们不知道我们可以使用什么编码。

    参考文献:#1670

  • [oracle] FOR UPDATE is emitted in the syntactically correct position when limit/offset is used, i.e. the ROWNUM subquery. 但是,Oracle无法真正使用ORDER BY或子查询来处理FOR UPDATE,所以它仍然不是很实用,但至少SQLA会通过Oracle解析器获取SQL。

    参考文献:#1815

火鸟¶ T0>

  • [firebird] 在has_table()和has_sequence()中使用的查询中添加了一个标签,可用于不会为结果列提供标签的Firebird旧版本。

    参考文献:#1521

  • [firebird] 当通过查询字符串传递时,为“type_conv”属性添加整数强制,以便由Kinterbasdb正确解释。

    参考文献:#1779

  • [firebird] 将'连接关闭'添加到表示连接断开的异常字符串列表中。

    参考文献:#1646

杂项¶ T0>

  • [engines] 修正了Python 2.4中的C扩展。

    参考文献:#1781

  • [engines] 在发生dispose()后,池类将重复使用相同的“pool_logging_name”设置。

  • [engines] 引擎获得“execution_options”参数和update_execution_options()方法,该方法将应用于此引擎生成的所有连接。

  • [sqlsoup] the SqlSoup constructor accepts a base argument which specifies the base class to use for mapped classes, the default being object.

    参考文献:#1783

0.6.0 ¶ T0>

发布于:2010年4月18日

ORM ¶ T0>

  • [orm] 工作单元内部已被重写。由于不再依赖递归调用,现在可以刷新大量与对象相关的对象的工作单元而不会发生递归溢出。现在,对于特定的会话状态,内部结构的数量保持不变,而不管映射上存在多少关系。事件流现在对应于线性步骤列表,由映射器和关系基于要完成的实际工作生成,通过单个拓扑排序进行正确排序。刷新操作使用更少的步骤和更少的内存来组装。

    参考文献:#1742#1081

  • [orm] Along with the UOW rewrite, this also removes an issue introduced in 0.6beta3 regarding topological cycle detection for units of work with long dependency cycles. 我们现在使用Guido编写的算法(感谢Guido!)。¶ T0>

  • [orm] one-to-many relationships now maintain a list of positive parent-child associations within the flush, preventing previous parents marked as deleted from cascading a delete or NULL foreign key set on those child objects, despite the end-user not removing the child from the old association.

    参考文献:#1764

  • [orm] 集合延迟加载将在多对一的反向关闭默认预加载,因为该加载在定义上是不必要的。

    参考文献:#1495

  • [orm] Session.refresh() now does an equivalent expire() on the given instance first, so that the “refresh-expire” cascade is propagated. 以前,refresh()不受“refresh-expire”级联的影响。这是行为与0.6beta2行为的变化,其中传递给refresh()的“lockmode”标志将导致版本检查发生。由于实例首次过期,因此refresh()会始终将对象升级到最新版本。

  • [orm] The ‘refresh-expire’ cascade, when reaching a pending object, will expunge the object if the cascade also includes “delete-orphan”, or will simply detach it otherwise.

    参考文献:#1754

  • [orm] id(obj)不再在topological.py中内部使用,因为排序函数现在只需要可哈希对象。

    参考文献:#1756

  • [orm] The ORM will set the docstring of all generated descriptors to None by default. 这可以使用'doc'来覆盖(或者如果使用Sphinx,属性docstrings也可以)。

  • [orm] 将kw参数'doc'添加到所有映射器属性可调参数以及Column()。将字符串'doc'组装为描述符上的'__doc__'属性。

  • [orm] Usage of version_id_col on a backend that supports cursor.rowcount for execute() but not executemany() now works when a delete is issued (already worked for saves, since those don’t use executemany()). 对于根本不支持cursor.rowcount的后端,发出的警告与save相同。

    参考文献:#1761

  • [orm] The ORM now short-term caches the “compiled” form of insert() and update() constructs when flushing lists of objects of all the same class, thereby avoiding redundant compilation per individual INSERT/UPDATE within an individual flush() call.

  • [orm] internal getattr(), setattr(), getcommitted() methods on ColumnProperty, CompositeProperty, RelationshipProperty have been underscored (i.e. are private), signature has changed.

SQL ¶ T0>

  • [sql] Restored some bind-labeling logic from 0.5 which ensures that tables with column names that overlap another column of the form “_” won’t produce errors if column._label is used as a bind name during an UPDATE. 已添加0.5中不存在的测试覆盖率。

    参考文献:#1755

  • [sql] somejoin.select(fold_equivalents=True) is no longer deprecated, and will eventually be rolled into a more comprehensive version of the feature for.

    参考文献:#1729

  • [sql] the Numeric type raises an enormous warning when expected to convert floats to Decimal from a DBAPI that returns floats. 这包括SQLite,Sybase,MS-SQL。

    参考文献:#1759

  • [sql] 修复了表达式中的一个错误,该错误导致了具有两个NULL类型的表达式的无限循环

  • [sql] Fixed bug in execution_options() feature whereby the existing Transaction and other state information from the parent connection would not be propagated to the sub-connection.

  • [sql] 添加了新的'compiled_cache'执行选项。当连接将子句表达式编译为方言和参数特定的编译对象时,Compiled对象将被缓存的字典。用户有责任管理该字典的大小,该字典将具有与方言,子句元素,INSERT或UPDATE的VALUES或SET子句中的列名相对应的键,以及用于INSERT或UPDATE语句。

  • [sql] 将get_pk_constraint()添加到reflection.Inspector,类似于get_primary_keys(),除了返回一个包含约束名称的dict,用于受支持的后端(迄今为止的PG)¶< / T2>

    参考文献:#1769

  • [sql] Table.create() and Table.drop() no longer apply metadata- level create/drop events.

    参考文献:#1771

的PostgreSQL ¶ T0>

  • [postgresql] 在序列名称被更改之后,Postgresql现在正确反映了与SERIAL列相关联的序列名称。感谢Kumar McMillan提供的补丁。

    参考文献:#1071

  • [postgresql] 收到未知数​​字时修复了psycopg2._PGNumeric类型中缺少的导入。

  • [postgresql] psycopg2 / pg8000方言现在知道REAL [],FLOAT [],DOUBLE_PRECISION [],NUMERIC []返回类型而不引发异常

  • [postgresql] Postgresql反映主键约束的名称(如果存在)。

    参考文献:#1769

预言¶ T0>

  • [oracle] 现在使用cx_oracle输出转换器,以便DBAPI原生返回我们喜欢的值类型:

  • [oracle] NUMBER values with positive precision + scale convert to cx_oracle.STRING and then to Decimal. 这使得在使用cx_oracle时数值类型具有完美的精度。

    参考文献:#1759

  • [oracle] 现在STRING / FIXED_CHAR本地转换为unicode。SQLAlchemy的String类型不需要应用任何类型的转换。

火鸟¶ T0>

  • [firebird] 通过在create_engine()上设置'enable_rowcount = False',可以基于每个引擎禁用result.rowcount的功能。通常,无条件地在任何UPDATE或DELETE语句之后调用cursor.rowcount,因为随后关闭了游标并且Firebird需要打开游标才能获得行计数。这个电话稍微昂贵,所以它可以被禁用。要在每次执行的基础上重新启用,可以使用'enable_rowcount = True'执行选项。

杂项¶ T0>

  • [engines] C扩展现在也适用于将自定义序列用作行(而不仅是元组)的DBAPI。

    参考文献:#1757

  • [ext] 编译器扩展现在允许在扩展到子类的基类上使用@compiles装饰器,在编译器上的@compiles修饰器不会被基类上的@compiles修饰器破坏。¶ T2>

  • [ext] Declarative will raise an informative error message if a non-mapped class attribute is referenced in the string-based relationship() arguments.

  • [ext] 进一步修改了声明式中的“mixin”逻辑,以另外允许__mapper_args__作为mixin上的@class属性,例如动态分配polymorphic_identity。

  • [examples] 更新了attribute_shard.py示例,以便使用更强大的搜索Query的二进制表达式来将列与文本值进行比较。

0.6beta3 ¶ T0>

发布于:2010年3月28日

ORM ¶ T0>

  • [orm] 主要功能:为关系()添加了新的“子查询”加载功能。这是一个热切的加载选项,它为查询中表示的每个集合生成第二个SELECT,并同时为所有父母生成。查询重新发布包装在子查询中的原始最终用户查询,将连接应用到目标集合,并将所有这些集合完全加载到一个结果中,类似于“已加入”的加载,但使用所有内部连接,重复获取完整的父行(因为大多数DBAPI似乎都这样做,即使列被跳过)。子查询加载可在mapper配置级别使用“lazy ='subquery'”并在查询选项级别使用“subqueryload(props ..)”,“subqueryload_all(props ...)”。

    参考文献:#1675

  • [orm] To accommodate the fact that there are now two kinds of eager loading available, the new names for eagerload() and eagerload_all() are joinedload() and joinedload_all(). 在可预见的将来,旧名称仍然是同义词。

  • [orm] The “lazy” flag on the relationship() function now accepts a string argument for all kinds of loading: “select”, “joined”, “subquery”, “noload” and “dynamic”, where the default is now “select”. True / False / None的旧值仍然保留其通常的含义,并且在可预见的未来仍然是同义词。

  • [orm] 向Query()构造添加了with_hint()方法。这直接调用select()。with_hint()并接受实体以及表和别名。请参阅下面的SQL部分中的with_hint()。

    参考文献:#921

  • [orm] Fixed bug in Query whereby calling q.join(prop).from_self(...). 连接(prop)将无法将第二个连接渲染到子查询的外部,当连接到与内部相同的标准时。

  • [orm] Fixed bug in Query whereby the usage of aliased() constructs would fail if the underlying table (but not the actual alias) were referenced inside the subquery generated by q.from_self() or q.select_from().

  • [orm] Fixed bug which affected all eagerload() and similar options such that “remote” eager loads, i.e. eagerloads off of a lazy load such as query(A).options(eagerload(A.b, B.c)) wouldn’t eagerload anything, but using eagerload(“b.c”) would work fine.

  • [orm] 查询获得add_columns(col)的多版本add_columns(* columns)方法。add_column(col)将来会被弃用。

  • [orm] Query.join()将检测最终结果是否为“FROM A JOIN A”,如果是,则会引发错误。

  • [orm] Query.join(Cls.propname, from_joinpoint=True) will check more carefully that “Cls” is compatible with the current joinpoint, and act the same way as Query.join(“propname”, from_joinpoint=True) in that regard.

SQL ¶ T0>

  • [sql] 添加with_hint()方法以选择()构造。指定表/别名,提示文本和可选的方言名称,并且“提示”将在语句的适当位置呈现。适用于Oracle,Sybase,MySQL。

    参考文献:#921

  • [sql] Fixed bug introduced in 0.6beta2 where column labels would render inside of column expressions already assigned a label.

    参考文献:#1747

的PostgreSQL ¶ T0>

  • [postgresql] psycopg2方言将通过“sqlalchemy.dialects.postgresql”记录器名称记录NOTICE消息。

    参考文献:#877

  • [postgresql] TIME和TIMESTAMP类型现在可以直接从postgresql方言中获得,它将PG特有的参数'precision'添加到两者中。'TIME'和'TIMEZONE'类型的'precision'和'timezone'都被正确反映。

    参考文献:#997

MySQL的¶ T0>

  • [mysql] 当反射 - TINYINT(1)返回时,不要再猜测TINYINT(1)应该是BOOLEAN。在表定义中使用布尔值/布尔值来获取布尔转换行为。

    参考文献:#1752

预言¶ T0>

  • [oracle] The Oracle dialect will issue VARCHAR type definitions using character counts, i.e. VARCHAR2(50 CHAR), so that the column is sized in terms of characters and not bytes. 字符类型的列反射也将使用ALL_TAB_COLUMNS.CHAR_LENGTH而不是ALL_TAB_COLUMNS.DATA_LENGTH。当服务器版本为9或更高版本时,这两种行为都会生效 - 对于版本8,使用旧行为。

    参考文献:#1744

杂项¶ T0>

  • [declarative] 如果mixin实现了一个不可预知的__getattribute __(),即Zope接口,那么使用mixin不会中断。

    参考文献:#1746

  • [declarative] 在mixins上使用@classdecorator和类似词来定义__tablename__,__table_args__等。现在可以在该方法引用最终子类上的属性时使用。

    参考文献:#1749

  • [declarative] 声明式混合中不允许使用外键的关系和列,对不起。

    参考文献:#1751

  • [ext] sqlalchemy.orm.shard模块现在成为扩展名sqlalchemy.ext.horizo​​ntal_shard。旧的导入使用了弃用警告。

0.6beta2 ¶ T0>

发布日期:2010年3月20日

ORM ¶ T0>

  • [orm] relation()函数的正式名称现在是relationship(),以消除对关系代数术语的混淆。在可预见的将来,relation()将保持相同的容量。

    参考文献:#1740

  • [orm] 为Mapper添加了“version_id_generator”参数,这是一个可调用的参数,在“version_id_col”的当前值的情况下返回下一个版本号。可用于替代版本控制方案,如uuid,时间戳。

    参考文献:#1692

  • [orm] added “lockmode” kw argument to Session.refresh(), will pass through the string value to Query the same as in with_lockmode(), will also do version check for a version_id_col-enabled mapping.

  • [orm] Fixed bug whereby calling query(A).join(A.bs).add_entity(B) in a joined inheritance scenario would double-add B as a target and produce an invalid query.

    参考文献:#1188

  • [orm] Fixed bug in session.rollback() which involved not removing formerly “pending” objects from the session before re-integrating “deleted” objects, typically occurred with natural primary keys. 如果它们之间存在主键冲突,则删除的附加内部将失败。以前的“待处理”对象现在先被清除。

    参考文献:#1674

  • [orm] 删除了很多没有人关心的日志记录,日志记录仍然会响应日志级别的实时更改。没有明显的额外开销。

    参考文献:#1719

  • [orm] 修正了session.merge()中的错误,它阻止了字典集合的合并。

  • [orm] session.merge() works with relations that specifically don’t include “merge” in their cascade options - the target is ignored completely.

  • 如果目标具有该属性的值,即使传入的合并没有该属性的值,session.merge()也不会过期现有目标上的现有标量属性。[orm] 这可以防止对现有项目造成不必要的负载如果目的地没有attr,但仍然会将attr标记为已到期,这符合延迟cols的某些合同。

    参考文献:#1681

  • [orm] The “allow_null_pks” flag is now called “allow_partial_pks”, defaults to True, acts like it did in 0.5 again. 除此之外,它也在merge()中实现,使得如果标志为False,则不会为具有部分NULL主键的传入实例发出SELECT。

    参考文献:#1680

  • [orm] Fixed bug in 0.6-reworked “many-to-one” optimizations such that a many-to-one that is against a non-primary key column on the remote table (i.e. foreign key against a UNIQUE column) will pull the “old” value in from the database during a change, since if it’s in the session we will need it for proper history/backref accounting, and we can’t pull from the local identity map on a non-primary key column.

    参考文献:#1737

  • [orm] 固定内部错误,如果在单表继承关系()上调用has()或类似的复杂表达式时会发生。

    参考文献:#1731

  • [orm] query.one() no longer applies LIMIT to the query, this to ensure that it fully counts all object identities present in the result, even in the case where joins may conceal multiple identities for two or more rows. 作为奖励,现在也可以用发出from_statement()的查询来调用one()以开始,因为它不再修改查询。

    参考文献:#1688

  • 如果查询标识映射中存在的标识符与所请求的标识符不同的类,即使用多态加载时,query.get()现在返回None。[orm]

    参考文献:#1727

  • [orm] A major fix in query.join(), when the “on” clause is an attribute of an aliased() construct, but there is already an existing join made out to a compatible target, query properly joins to the right aliased() construct instead of sticking onto the right side of the existing join.

    参考文献:#1706

  • [orm] Slight improvement to the fix for to not issue needless updates of the primary key column during a so-called “row switch” operation, i.e. add + delete of two objects with the same PK.

    参考文献:#1362

  • [orm] 当属性加载或刷新操作由于对象与任何会话分离而失败时,现在使用sqlalchemy.orm.exc.DetachedInstanceError。UnboundExecutionError特定于绑定到会话和语句的引擎。

  • [orm] Query called in the context of an expression will render disambiguating labels in all cases. 请注意,这并不适用于现有的.statement和.subquery()访问器/方法,它仍然支持默认为False的.with_labels()设置。

  • [orm] Query.union() retains disambiguating labels within the returned statement, thus avoiding various SQL composition errors which can result from column name conflicts.

    参考文献:#1676

  • [orm] 修正了属性历史记录中无意中在映射实例上调用了__eq__的错误。

  • [orm] Some internal streamlining of object loading grants a small speedup for large results, estimates are around 10-15%. 给“状态”内部一个良好的固体清理,复杂性较低,数据成员,方法调用,空白字典创建。

  • [orm] query.delete()的文档说明

    参考文献:#1689

  • [orm] 在r6711中引入了属性设置为None时,在多对一关系()中修复级联错误(在add()中级联删除的项目到会话中) T2>

  • [orm] Calling query.order_by() or query.distinct() before calling query.select_from(), query.with_polymorphic(), or query.from_statement() raises an exception now instead of silently dropping those criterion.

    参考文献:#1736

  • [orm] query.scalar() now raises an exception if more than one row is returned. 所有其他行为保持不变。

    参考文献:#1735

  • [orm] Fixed bug which caused “row switch” logic, that is an INSERT and DELETE replaced by an UPDATE, to fail when version_id_col was in use.

    参考文献:#1692

SQL ¶ T0>

  • [sql] join() will now simulate a NATURAL JOIN by default. 意思是,如果左侧是连接,它将尝试将右侧连接到左侧的第一个右侧,如果成功,则不会引发任何有关模糊连接条件的例外,即使其他连接目标左侧。¶ T0>

    参考文献:#1714

  • [sql] The most common result processors conversion function were moved to the new “processors” module. 鼓励方言作者在符合他们的需求时使用这些函数,而不是实现自定义函数。

  • [sql] SchemaType和子类Boolean,Enum现在是可序列化的,包括它们的ddl监听器和其他事件可调用。

    参考文献:#1694#1698

  • [sql] Some platforms will now interpret certain literal values as non-bind parameters, rendered literally into the SQL statement. 这支持严格的SQL-92规则,这些规则由包括MS-SQL和Sybase在内的一些平台实施。在此模型中,绑定参数不允许在SELECT的columns子句中使用,也不允许使用某些不明确的表达式,例如“?=?”。启用此模式后,基本编译器会将绑定呈现为内联文字,但只能跨字符串和数字值显示。其他类型如日期会引发错误,除非方言子类为这些定义了字面渲染函数。bind参数必须已经有嵌入的文字值,否则会引发错误(即不能使用直接bindparam('x'))。方言还可以扩展不接受绑定的区域,例如函数的参数列表(在使用本机SQL绑定时不适用于MS-SQL)。

  • [sql] 将“unicode_errors”参数添加到String,Unicode等行为就像标准库的string.decode()函数的'errors'关键字参数。该标志要求convert_unicode设置为“force” - 否则,SQLAlchemy不保证处理unicode转换的任务。请注意,此标志为已经返回unicode对象的后端(大多数DBAPI所执行的操作)的后端操作增加了显着的性能开销。这个标志只能作为从不同或损坏编码的列中读取字符串的绝对最后手段,它只适用于首先接受无效编码的数据库(即MySQL)。不是 PG,Sqlite等)

  • [sql] 增加了数学否定运算符支持,-x。

  • [sql] FunctionElement subclasses are now directly executable the same way any func.foo() construct is, with automatic SELECT being applied when passed to execute().

  • [sql] func.foo()构造的“type”和“bind”关键字参数现在是“func”构造的本地对象,不属于FunctionElement基类的一部分,允许“类型“将在自定义构造函数或类级别变量中处理。

  • [sql] 将keys()方法恢复到ResultProxy。

  • [sql] The type/expression system now does a more complete job of determining the return type from an expression as well as the adaptation of the Python operator into a SQL operator, based on the full left/right/operator of the given expression. 特别是为Postgresql EXTRACT创建的日期/时间/间隔系统现在已被推广到类型系统中。现在通常不会发生以前经常出现的“列+文字”表达式,迫使“文字”类型与“列”类型相同,现在通常不会发生 - “文字”类型首先从Python类型派生假定标准本地Python类型+日期类型,然后再回到表达式另一侧的已知类型。如果“后备”类型是兼容的(即来自字符串的CHAR),则文字方将使用该类型。TypeDecorator类型在默认情况下覆盖这个以强制无条件地强制“literal”,这可以通过实现coerce_compared_value()方法来改变。也是。的一部分

    参考文献:#1647#1683

  • [sql] Made sqlalchemy.sql.expressions.Executable part of public API, used for any expression construct that can be sent to execute(). FunctionElement现在继承可执行文件,以便获得execution_options(),这些文件也传播到execute()中生成的select()。依次可执行的子类_Generative,它标记支持@_generative装饰器的任何ClauseElement - 为了编译器扩展的好处,这些也可能变成“public”。

  • [sql] A change to the solution for - an end-user defined bind parameter name that directly conflicts with a column-named bind generated directly from the SET or VALUES clause of an update/insert generates a compile error. 这减少了调用计数并消除了一些不良名称冲突仍然可能发生的情况。

    参考文献:#1579

  • [sql] Column() requires a type if it has no foreign keys (this is not new). 如果Column()没有类型,也没有外键,则会产生错误。

    参考文献:#1705

  • [sql] the “scale” argument of the Numeric() type is honored when coercing a returned floating point value into a string on its way to Decimal - this allows accuracy to function on SQLite, MySQL.

    参考文献:#1717

  • [sql] the copy() method of Column now copies over uninitialized “on table attach” events. 帮助新的声明式“mixin”功能。

MySQL的¶ T0>

  • [mysql] 修正了COLLATE存在的反射错误,可空标志和服务器默认值不会被反映出来。

    参考文献:#1655

  • [mysql] 固定TINYINT(1)“boolean”列的反射,使用UNSIGNED等整数标志定义。

  • [mysql] 进一步修正mysql连接器方言

    参考文献:#1668

  • [mysql] InnoDB上的“autoincrement”列不是第一个的复合PK表将在CREATE TABLE中发出明确的“KEY”短语,从而避免错误。

    参考文献:#1496

  • [mysql] 增加了对各种MySQL关键字的反射/创建表支持。

    参考文献:#1634

  • [mysql] 修正了在Windows主机上反映表可能发生的导入错误

    参考文献:#1580

源码¶ T0>

  • [sqlite] 将“native_datetime = True”标志添加到create_engine()。这会导致DATE和TIMESTAMP类型在连接上启用PARSE_DECLTYPES的假设下跳过所有绑定参数和结果行处理。请注意,这与“func.current_date()”不完全兼容,它将作为字符串返回。

    参考文献:#1685

MSSQL ¶ T0>

  • [mssql] 重新建立了对pymssql方言的支持

  • [mssql] 隐式返回,反射等的各种修复 - MS-SQL方言在0.6中还不完整(但接近)

  • [mssql] 增加了对mxODBC的基本支持。

    参考文献:#1710

  • [mssql] 删除了text_as_varchar选项。

预言¶ T0>

  • [oracle] “out”参数需要cx_oracle支持的类型。如果找不到cx_oracle类型,则会产生错误。

  • [oracle] Oracle ‘DATE’ now does not perform any result processing, as the DATE type in Oracle stores full date+time objects, that’s what you’ll get. 请注意,泛型类型.Date类型仍然对传入值调用value.date(),但是。当反映一个表时,反射类型将是'DATE'。

  • [oracle] 增加了对Oracle的WITH_UNICODE模式的初步支持。至少,这为Python 3创建了对cx_Oracle的初始支持。当在Python 2.xx中使用WITH_UNICODE模式时,会发出一个大而可怕的警告,要求用户认真考虑使用这种困难的操作模式。

    参考文献:#1670

  • [oracle] 现在,except_()方法在Oracle上呈现为MINUS,这在该平台上或多或少是等同的。

    参考文献:#1712

  • [oracle] 添加了对TIMESTAMP WITH TIME ZONE的呈现和反映支持,即TIMESTAMP(timezone = True)。

    参考文献:#651

  • [oracle] 现在可以反映Oracle INTERVAL类型。

杂项¶ T0>

  • [py3k] 改进了关于Python 3的安装/测试设置,现在Distribute在Py3k上运行。distribute_setup.py现在包含在内。有关Python 3安装/测试说明,请参阅README.py3k。

  • [engines] 增加了一个可选的C扩展,通过重新实现RowProxy和最常用的结果处理器来加速sql层。实际的加速将很大程度上取决于您的DBAPI和您的表中使用的数据类型的混合,并且可以从30%改进到200%以上。它还为大型查询的ORM速度提供了适度(〜15-20%)的间接改进。请注意,默认情况下,不是内置/安装。请参阅自述文件以获取安装说明。

  • 在“autocommit”场景中,在DBAPI连接上调用commit()之前,执行顺序会从游标中拉取所有rowcount / last插入的ID信息。[engines] 这有助于mxodbc与rowcount,可能是一个好主意。

  • [engines] 打开日志记录,以便更频繁地调用isEnabledFor(),以便在下次连接时反映引擎/池日志级别的更改。这增加了少量的方法调用开销。这是微不足道的,并且会在调用create_engine()之后正好配置日志时,使所有这些情况的生活变得更加轻松。

    参考文献:#1719

  • [engines] 不推荐使用assert_unicode标志。SQLAlchemy将在所有要求对非Unicode Unicode字符串进行编码的情况下以及Unicode或UnicodeType类型显式传递字符串时发出警告。对于已经接受Python unicode对象的DBAPI,String类型不会做任何事情。

  • [engines] 绑定参数作为元组而不是列表发送。一些后端驱动程序不会接受绑定参数作为列表。

  • [engines] threadlocal引擎在close()时没有正确关闭连接 - 修正了

  • [engines] 如果事务对象不是“活动”,事务对象不会回滚或提交,允许更准确地嵌套begin / rollback / commit。

  • [engines] 作为绑定的Python unicode对象导致Unicode类型,而不是字符串,从而消除了不支持unicode绑定的驱动程序中的某类unicode错误。

  • [engines] 将create_engine(),Pool()构造函数以及“pool_logging_name”参数的参数添加到create_engine(),该参数过滤到Pool的参数。在记录消息的“名称”字段中发出给定的字符串名称,而不是缺省的十六进制标识符字符串。

    参考文献:#1555

  • [engines] Dialect的visit_pool()方法被删除,并被on_connect()取代。此方法返回一个可调用对象,它在创建每个对象后接收原始DBAPI连接。如果为非无,则可调用组件通过连接策略组装成first_connect / connect pool侦听器。为方言提供更简单的界面。

  • [engines] StaticPool现在可以在不打开新连接的情况下初始化,处理和重新创建连接 - 连接仅在第一次请求时打开。dispose()现在也可以在AssertionPool上工作。

    参考文献:#1728

  • [ticket: 1673] [metadata] 通过传递“schema = None”作为参数,增加了在使用“tometadata”时去除模式信息的功能。如果没有指定schema,那么该表的模式将被保留。

  • [declarative] DeclarativeMeta独占使用cls .__ dict__(不是dict_)作为类信息的来源; _as_declarative只使用传递给它的dict_作为类信息的来源(当使用DeclarativeMeta时,它是cls .__ dict__)。这在理论上应该使定制元类更容易修改传入_as_declarative的状态。

  • [declarative] declarative now accepts mixin classes directly, as a means to provide common functional and column-based elements on all subclasses, as well as a means to propagate a fixed set of __table_args__ or __mapper_args__ to subclasses. 对于__table_args __ / __ mapper_args__从继承的mixin到本地的自定义组合,现在可以使用描述符。新的细节都在声明性文档中。感谢Chris Withers为此付出了努力。

    参考文献:#1707

  • [declarative] the __mapper_args__ dict is copied when propagating to a subclass, and is taken straight off the class __dict__ to avoid any propagation from the parent. 映射器继承已经从父映射器传播你想要的东西。

    参考文献:#1393

  • [declarative] 当一个单表子类指定一个已存在于基类中的列时会引发异常。

    参考文献:#1732

  • [sybase] 为Sybase实施了一个初步工作方言,其中包含Python-Sybase和Pyodbc的子实现。处理表格创建/删除和基本往返功能。尚未包含对unicode /特殊表达式/ etc等的反映或全面支持

  • [examples] 稍微更改了烧杯缓存示例,以便为lazyload缓存提供单独的RelationCache选项。该对象通过将几个分组到一个通用结构中,可以更有效地查找任何数量的潜在属性。FromCache和RelationCache都更简单。

  • [documentation] 文档中的主要清理工作将类,函数和方法名称链接到API文档中。

    参考文献:#1700

0.6beta1 ¶ T0>

发布日期:2010年2月3日

ORM ¶ T0>

  • [orm]

    query.update()和query.delete()的更改:
    • query.update()的'expire'选项已被重命名为'fetch',因此与query.delete()的匹配。'过期'已弃用并发出警告。
    • 对于同步策略,query.update()和query.delete()都默认为“评估”。
    • update()和delete()的“同步”策略会在失败时产生错误。没有隐含的回退到“获取”。评估失败是基于标准的结构,所以成功/失败是基于代码结构的确定性。

  • [orm]

    多对一关系的增强:
    • 多对一的关系现在会在更少的情况下触发延迟加载,包括在大多数情况下不会在更换新代码时获取“旧”值。
    • 现在,对于一个简单加载(称为“use_get”条件),即Related-> Sub(Base),使用get()方法的多对一关系无需重新定义primaryjoin条件的基表。
    • 指定具有声明列的外键,即ForeignKey(MyRelatedClass.id)不会中断发生的“use_get”条件
    • relation(),eagerload()和eagerload_all()现在具有一个名为“innerjoin”的选项。指定TrueFalse来控制eager连接是否构造为INNER或OUTER连接。与往常一样,默认为False映射器选项将覆盖关系()中指定的任何设置。通常应该设置为多对一,而不是可空的外键关系,以提高连接性能。
    • 当LIMIT / OFFSET出现时,预加载的行为使得主查询被包装在子查询中,现在对于所有紧急加载都是多对一连接的情况来说是个例外。在这种情况下,由于多对一连接不会将行添加到结果中,所以急切连接与限制/偏移一起直接与父表对齐,而无需额外的子查询开销。

    References: #1186, #1492, #1544

  • [orm] Session.merge()的增强/改变:

  • [orm] Session.merge()上的“dont_load = True”标志被弃用,现在是“load = False”。

  • [orm] Session.merge() is performance optimized, using half the call counts for “load=False” mode compared to 0.5 and significantly fewer SQL queries in the case of collections for “load=True” mode.

  • [orm] merge() will not issue a needless merge of attributes if the given instance is the same instance which is already present.

  • [orm] merge() now also merges the “options” associated with a given state, i.e. those passed through query.options() which follow along with an instance, such as options to eagerly- or lazyily- load various attributes. 这对于构建高度集成的缓存方案至关重要。这是一个微妙的行为变化与0.5.

  • [orm] 修正了关于实例状态中存在的“加载路径”的序列化的bug,当将merge()与序列化状态的使用以及相关的选项组合起来时,这也是必需的保存。¶ T2>

  • [orm] 全新的merge()将以一个新的综合示例展示如何将Beaker与SQLAlchemy集成。请参阅下面的“示例”注释中的注释。

  • [orm] Primary key values can now be changed on a joined-table inheritance object, and ON UPDATE CASCADE will be taken into account when the flush happens. 使用SQLite或MySQL / MyISAM时,在mapper()上将新的“passive_updates”标志设置为False

    参考文献:#1362

  • [orm] flush() now detects when a primary key column was updated by an ON UPDATE CASCADE operation from another primary key, and can then locate the row for a subsequent UPDATE on the new PK value. 当关系()存在以建立关系以及passive_updates = True时,会发生这种情况。

    参考文献:#1671

  • [orm] the “save-update” cascade will now cascade the pending removed values from a scalar or collection attribute into the new session during an add() operation. 这样flush()操作也会删除或修改这些断开项目的行。

  • [orm] 现在使用带有“辅助”表的“动态”加载器生成一个查询,其中“辅助”表不是别名。这允许辅助Table对象用在relation()的“order_by”属性中,并且还允许将其用于针对动态关系的过滤标准。

    参考文献:#1531

  • [orm] relation() with uselist=False will emit a warning when an eager or lazy load locates more than one valid value for the row. 这可能是由于primaryjoin / secondaryjoin条件不适合渴望的LEFT OUTER JOIN或其他条件。

    参考文献:#1643

  • [orm] an explicit check occurs when a synonym() is used with map_column=True, when a ColumnProperty (deferred or otherwise) exists separately in the properties dictionary sent to mapper with the same keyname. 而不是默默地替换现有的属性(以及该属性的可能选项),会引发错误。

    参考文献:#1633

  • [orm] a “dynamic” loader sets up its query criterion at construction time so that the actual query is returned from non-cloning accessors like “statement”.

  • [orm] 当迭代一个Query()时返回的“named tuple”对象现在可以被pickleable

  • [orm] mapping to a select() construct now requires that you make an alias() out of it distinctly. 这可以消除对等问题的混淆

    参考文献:#1542

  • [orm] query.join()已被重写以提供更一致的行为和更多的灵活性(包括)

    参考文献:#1537

  • [orm] query.select_from() accepts multiple clauses to produce multiple comma separated entries within the FROM clause. 从多宿主连接()子句中选择时很有用。

  • [orm] query.select_from() also accepts mapped classes, aliased() constructs, and mappers as arguments. 特别是当从多个连接表类查询以确保完整连接被呈现时,这有助于。

  • [orm] query.get() can be used with a mapping to an outer join where one or more of the primary key values are None.

    参考文献:#1135

  • [orm] query.from_self(), query.union(), others which do a “SELECT * from (SELECT...)” type of nesting will do a better job translating column expressions within the subquery to the columns clause of the outer query. 这可能与0.5后向不兼容,因为这可能会破坏没有应用标签的文字表达式(即literal('foo')等)。

    参考文献:#1568

  • [orm] 关系primaryjoin和secondaryjoin现在检查它们是否是列表达式,而不仅仅是子句元素。这禁止像FROM表达式那样直接放在那里。

    参考文献:#1622

  • [orm] expression.null() is fully understood the same way None is when comparing an object/collection-referencing attribute within query.filter(), filter_by(), etc.

    参考文献:#1415

  • [orm] 添加了“make_transient()”辅助函数,该函数将持久性/分离性实例转换为临时性实例(即,删除instance_key并从任何会话中删除)。

    参考文献:#1052

  • [orm] 不推荐使用mapper()上的allow_null_pks标志,并且该功能默认为“打开”。这意味着对于任何主键列都有一个非空值的行将被视为一个标识。通常只有在映射到外连接时才需要这种情况。

    参考文献:#1339

  • [orm] the mechanics of “backref” have been fully merged into the finer grained “back_populates” system, and take place entirely within the _generate_backref() method of RelationProperty. 这使得RelationProperty的初始化过程更简单,并允许设置(例如从RelationProperty的子类)更容易地传播到反向引用。内部的BackRef()消失了,backref()返回一个被RelationProperty理解的普通元组。

  • [orm] mapper()上的version_id_col特性在与不支持“rowcount”的方言一起使用时会引发警告。

    参考文献:#1569

  • [orm] 将“execution_options()”添加到Query中,以便可以将选项传递给结果语句。目前只有Select语句具有这些选项,唯一使用的选项是“stream_results”,而知道“stream_results”的唯一方言是psycopg2.

  • [orm] Query.yield_per()会自动设置“stream_results”语句选项。

  • [orm]

    已弃用或已删除:
    • mapper()上的'allow_null_pks'标志已被弃用。它现在什么都不做,并且在所有情况下都是“开启”的。
    • sessionmaker()上的'transactional'标志被删除。使用'autocommit = True'来表示'transactional = False'。
    • mapper()上的'polymorphic_fetch'参数被删除。加载可以使用'with_polymorphic'选项进行控制。
    • mapper()上的'select_table'参数被删除。为此功能使用'with_polymorphic =(“*”,)'。
    • 同义词()的'代理'参数被删除。这个标志在整个0.5中没有做任何事情,因为“代理生成”行为现在是自动的。
    • 将单个元素列表传递给eagerload(),eagerload_all(),contains_eager(),lazyload(),defer()和undefer()而不是多个位置*参数已被弃用。
    • 将单个元素列表传递给query.order_by(),query.group_by(),query.join()或query.outerjoin()而不是多个位置*参数已弃用。
    • query.iterate_instances()被删除。使用query.instances()。
    • Query.query_from_parent()被删除。使用sqlalchemy.orm.with_parent()函数生成一个“父”子句,或者query.with_parent()。
    • query._from_self()被移除,请改用query.from_self()。
    • composite()的“comparator”参数被删除。使用“comparator_factory”。
    • RelationProperty._get_join()被删除。
    • Session上的'echo_uow'标志被删除。在“sqlalchemy.orm.unitofwork”名称上使用日志记录。
    • session.clear()被删除。使用session.expunge_all()。
    • session.save(),session.update(),session.save_or_update()被删除。使用session.add()和session.add_all()。
    • session.flush()上的“objects”标志仍然被弃用。
    • session.merge()中的“dont_load = True”标志不赞成使用“load = False”。
    • ScopedSession.mapper保持不推荐使用。请参阅http://www.sqlalchemy.org/trac/wiki/UsageRecipes/SessionAwareMapper中的使用配方
    • 将InstanceState(内部SQLAlchemy状态对象)传递给attributes.init_collection()或attributes.get_history()已弃用。这些函数是公共API,通常需要一个常规的映射对象实例。
    • declarative_base()的'engine'参数被删除。使用'bind'关键字参数。

SQL ¶ T0>

  • [sql] the “autocommit” flag on select() and text() as well as select().autocommit() are deprecated - now call .execution_options(autocommit=True) on either of those constructs, also available directly on Connection and orm.Query.

  • [sql] the autoincrement flag on column now indicates the column which should be linked to cursor.lastrowid, if that method is used. 有关详细信息,请参阅API文档。

  • [sql] an executemany() now requires that all bound parameter sets require that all keys are present which are present in the first bound parameter set. 插入/更新语句的结构和行为很大程度上取决于第一个参数集,其中包括哪些缺省值将被触发,并且所有其余缺省值都会执行最小猜测操作,以便不影响性能。出于这个原因,默认情况会以默默的方式“失败”,因为这是现在的防范。

    参考文献:#1566

  • [sql] returning() support is native to insert(), update(), delete(). Postgresql,Firebird,MSSQL和Oracle存在不同级别功能的实现。可以使用列表达式显式调用返回(),这些列表达式通常通过fetchone()或first()返回结果集。

    如果正在使用的数据库版本支持它(执行版本号检查),则insert()构造也将隐式地使用RETURNING来获取新生成的主键值。如果没有指定最终用户返回(),则会发生这种情况。

  • [sql] union(), intersect(), except() and other “compound” types of statements have more consistent behavior w.r.t. 圆括号。嵌入在另一个元素中的每个复合元素现在将用括号分组 - 之前,列表中的第一个复合元素不会被分组,因为SQLite不喜欢以括号开头的语句。但是,Postgresql尤其具有关于INTERSECT的优先规则,并且对于括号同样适用于所有子元素更为一致。所以现在,SQLite的解决方法也是以前PG的解决方法 - 当嵌套复合元素时,第一个通常需要调用“.alias()。select()”以将其包装在子查询中。¶ T0>

    参考文献:#1665

  • [sql] insert() and update() constructs can now embed bindparam() objects using names that match the keys of columns. 这些绑定参数将绕过通常路由到生成的SQL的VALUES或SET子句中显示的那些键。

    参考文献:#1579

  • [sql] the Binary type now returns data as a Python string (or a “bytes” type in Python 3), instead of the built- in “buffer” type. 这允许二进制数据的对称往返行程。

    参考文献:#1524

  • [sql] 添加了tuple_()构造,允许将表达式集与另一个集进行比较,通常使用IN对复合主键或类似进行比较。还接受具有多个列的IN。“标量选择只能有一列”的错误信息被删除 - 将依赖于数据库来报告与col不匹配的问题。

  • [sql] User-defined “default” and “onupdate” callables which accept a context should now call upon “context.current_parameters” to get at the dictionary of bind parameters currently being processed. 无论是单执行还是执行语句执行,该字典都可以以相同方式使用。

  • [sql] multi-part schema names, i.e. with dots such as “dbo.master”, are now rendered in select() labels with underscores for dots, i.e. “dbo_master_table_column”. 这是一个“友好”的标签,在结果集中表现更好。

    参考文献:#1428

  • [sql] removed needless “counter” behavior with select() labelnames that match a column name in the table, i.e. generates “tablename_id” for “id”, instead of “tablename_id_1” in an attempt to avoid naming conflicts, when the table has a column actually named “tablename_id” - this is because the labeling logic is always applied to all columns so a naming conflict will never occur.

  • [sql] calling expr.in_([]), i.e. with an empty list, emits a warning before issuing the usual “expr != expr” clause. “expr!= expr”可能非常昂贵,如果列表为空,则最好是不发出in_(),而不是简单地查询或修改标准以适应更复杂的情况。¶< / T0>

    参考文献:#1628

  • [sql] Added “execution_options()” to select()/text(), which set the default options for the Connection. 请参阅“引擎”中的注释。

  • [sql]

    已弃用或已删除:
    • select()上的“标量”标志被删除,使用select.as_scalar()。
    • bindparam()上的“shortname”属性被删除。
    • postgres_returning,insert(),update(),delete()上的firebird_returning标志都被弃用,使用新的返回()方法。
    • 加入时的fold_equivalents标志已被弃用(将保持到实施)

    参考文献:#1131

架构¶ T0>

  • [schema] MetaData__包含__()方法现在接受字符串或对象作为参数。如果给定,则首先将参数转换为table.key,即“[SCHEMANAME。] ¶ T1> T0>

    参考文献:#1541

  • [schema] deprecated MetaData.connect() and ThreadLocalMetaData.connect() have been removed - send the “bind” attribute to bind a metadata.

  • [schema] 不赞成使用metadata.table_iterator()方法(使用sorted_tables)

  • [schema] 不推荐使用PassiveDefault - 使用DefaultClause。

  • [schema] the “metadata” argument is removed from DefaultGenerator and subclasses, but remains locally present on Sequence, which is a standalone construct in DDL.

  • [schema] 从Index和Constraint对象中删除了公共可变性:

    • ForeignKeyConstraint.append_element()
    • Index.append_column()
    • UniqueConstraint.append_column()
    • PrimaryKeyConstraint.add()
    • PrimaryKeyConstraint.remove()

    这些应该以声明方式构建(即在一个构造中)。

  • [schema] Sequence上的“start”和“increment”属性现在默认在Oracle和Postgresql上生成“START WITH”和“INCREMENT BY”。Firebird现在不支持这些关键字。

    参考文献:#1545

  • [schema] UniqueConstraint,Index,PrimaryKeyConstraint都接受列名或列对象列表作为参数。

  • [schema]

    其他删除的东西:
    • Table.key(不知道这是什么)
    • Table.primary_key不可分配 - 使用table.append_constraint(PrimaryKeyConstraint(...))
    • Column.bind(通过column.table.bind获取)
    • Column.metadata(通过column.table.metadata获取)
    • Column.sequence(使用column.default)
    • ForeignKey(约束= some_parent)(现在是私人_constraint)

  • [schema] ForeignKey上的use_alter标志现在是可以使用DDL()事件系统手动构建的操作的快捷选项。A side effect of this refactor is that ForeignKeyConstraint objects with use_alter=True will not be emitted on SQLite, which does not support ALTER for foreign keys.

  • [schema] 现在,ForeignKey和ForeignKeyConstraint对象正确地copy()所有公共关键字参数。

    参考文献:#1605

的PostgreSQL ¶ T0>

  • [postgresql] 新的方言:py3k上的pg8000,zxjdbc和pypostgresql。

  • [postgresql] “postgres”方言现在被命名为“postgresql”!连接字符串如下所示:

    postgresql:// scott:tiger @ localhost / test postgresql + pg8000:// scott:tiger @ localhost / test

    “postgres”的名字仍然以下列方式向后兼容:

    • 有一个“postgres.py”虚拟方言,它允许旧的URL工作,即postgres:// scott:tiger @ localhost / test
    • 可以从旧的“数据库”模块中导入“postgres”名称,即从“sqlalchemy.databases import postgres”以及“方言”,“from sqlalchemy.dialects.postgres import base as pg”,将发送弃用警告。
    • 现在特殊表达式参数被命名为“postgresql_returning”和“postgresql_where”,但较旧的“postgres_returning”和“postgres_where”名称仍然适用于弃用警告。

  • [postgresql] “postgresql_where”现在接受SQL表达式,该表达式还可以包含文字,这些文字将根据需要引用。

  • [postgresql] psycopg2方言现在在所有新连接上使用psycopg2的“unicode扩展”,它允许所有的String / Text /等。类型以避免需要将字节串后处理到unicode(由于其体积而导致的昂贵步骤)。本地返回unicode的其他方言(pg8000,zxjdbc)也会跳过unicode后期处理。

  • [postgresql] 添加了新的ENUM类型,该类型作为模式级结构存在并扩展了泛型枚举类型。自动将自身与表及其父元数据相关联,以根据需要发出适当的CREATE TYPE / DROP TYPE命令,支持unicode标签,支持反射。

    参考文献:#1511

  • [postgresql] INTERVAL支持与PG接受的参数相对应的可选“precision”参数。

  • [postgresql] 使用新的dialect.initialize()功能设置依赖于版本的行为。

  • [postgresql] somewhat better support for % signs in table/column names; psycopg2 can’t handle a bind parameter name of %(foobar)s however and SQLA doesn’t want to add overhead just to treat that one non-existent use case.

    参考文献:#1279

  • [postgresql] 将NULL插入到主键+外键列中将允许引发“not null constraint”错误,而不是尝试执行不存在的“col_id_seq”序列。¶ T2>

    参考文献:#1516

  • [postgresql] autoincrement SELECT语句,即从修改行的过程中选择的语句现在可以在服务器端游标模式下工作(指定的游标不用于这种语句)。¶ T2>

  • [postgresql] postgresql dialect can properly detect pg “devel” version strings, i.e. “8.5devel”

    参考文献:#1636

  • [postgresql] psycopg2现在遵守语句选项“stream_results”。该选项将覆盖连接设置“server_side_cursors”。如果为true,则服务器端游标将用于该语句。如果为false,即使连接上的“server_side_cursors”为真,它们也不会被使用。

    参考文献:#1619

MySQL的¶ T0>

  • [mysql] New dialects: oursql, a new native dialect, MySQL Connector/Python, a native Python port of MySQLdb, and of course zxjdbc on Jython.

  • [mysql] VARCHAR / NVARCHAR不会在没有长度的情况下呈现,在传递给MySQL之前会产生错误。不影响CAST,因为无论如何,在MySQL CAST中都不允许VARCHAR,在这种情况下,方言呈现CHAR / NCHAR。

  • [mysql] all the _detect_XXX() functions now run once underneath dialect.initialize()

  • [mysql] somewhat better support for % signs in table/column names; MySQLdb can’t handle % signs in SQL when executemany() is used, and SQLA doesn’t want to add overhead just to treat that one non-existent use case.

    参考文献:#1279

  • [mysql] 在所有情况下,BINARY和MSBinary类型现在都会生成“BINARY”。省略“length”参数将生成没有长度的“BINARY”。使用BLOB生成未经修改的二进制列。

  • [mysql] 不建议使用MSEnum / ENUM的“quoting ='quoted'”参数。最好依靠自动引用。

  • [mysql] 如果给定的标签名是unicode对象,ENUM现在子类化新的泛型Enum类型,并且还隐式处理unicode值。

  • [mysql] 如果“nullable = False”没有传递给Column(),并且没有默认值,那么TIMESTAMP类型的列现在默认为NULL。现在这与所有其他类型一致,并且在TIMESTAMP的情况下,由于MySQL对TIMESTAMP列的默认可空性进行“切换”,显式呈现“NULL”。

    参考文献:#1539

源码¶ T0>

  • [sqlite] DATE,TIME和DATETIME类型现在可以使用可选的storage_format和regexp参数。storage_format可用于使用自定义字符串格式来存储这些类型。regexp允许使用自定义正则表达式来匹配来自数据库的字符串值。

  • [sqlite] 现在,Time和DateTime类型默认使用更严格的正则表达式来匹配数据库中的字符串。如果您使用的是以传统格式存储的数据,请使用regexp参数。

  • SQLite中的[sqlite] __ legacy_microseconds__ Time和DateTime类型不再受支持。您应该使用storage_format参数。

  • [sqlite] Date, Time and DateTime types are now stricter in what they accept as bind parameters: Date type only accepts date objects (and datetime ones, because they inherit from date), Time only accepts time objects, and DateTime only accepts date and datetime objects.

  • [sqlite] Table() supports a keyword argument “sqlite_autoincrement”, which applies the SQLite keyword “AUTOINCREMENT” to the single integer primary key column when generating DDL. 将防止生成单独的PRIMARY KEY约束。

    参考文献:#1016

MSSQL ¶ T0>

  • [mssql] MSSQL + Pyodbc + FreeTDS现在大部分都可以使用,可能有二进制数据和unicode模式标识符的例外。

  • [mssql] “has_window_funcs”标志被删除。LIMIT / OFFSET用法将一直使用ROW NUMBER,如果在较早版本的SQL Server上,则操作失败。行为是完全一样的,除了错误是由SQL服务器而不是方言引发的,并且不需要标志设置来启用它。

  • [mssql] “auto_identity_insert”标志被删除。当INSERT语句覆盖已知有序列的列时,此功能始终生效。与“has_window_funcs”一样,如果底层驱动程序不支持这种情况,那么在任何情况下都不能执行此操作,所以没有标志是没有意义的。

  • [mssql] 使用新的dialect.initialize()功能设置版本依赖的行为。

  • [mssql] 删除了不再使用的序列的引用。mssql中的隐式标识与任何其他方言中的隐式序列的工作方式相同。显式序列通过使用“default = Sequence()”来启用。有关更多信息,请参阅MSSQL方言文档。

预言¶ T0>

  • [oracle] 单元测试通过cx_oracle 100%!

  • [oracle] 支持cx_Oracle的“native unicode”模式,它不需要设置NLS_LANG。使用cx_oracle的最新5.0.2或更高版本。

  • [oracle] 将一个NCLOB类型添加到基类型中。

  • [oracle] use_ansi = False不会泄露到从也使用JOIN / OUTERJOIN的子查询中选择的语句的FROM / WHERE子句中。

  • [oracle] 为方言添加了本地INTERVAL类型。由于在YEAR TO MONTH中缺少对cx_oracle的支持,目前只支持DAY TO SECOND间隔类型。

    参考文献:#1467

  • [oracle] usage of the CHAR type results in cx_oracle’s FIXED_CHAR dbapi type being bound to statements.

  • [oracle] the Oracle dialect now features NUMBER which intends to act justlike Oracle’s NUMBER type. 它是表反射返回的主要数值类型,并尝试根据精度/比例参数返回Decimal()/ float / int。

    参考文献:#885

  • [oracle] func.char_length是LENGTH 的一个通用函数

  • [oracle] ForeignKey() which includes onupdate= will emit a warning, not emit ON UPDATE CASCADE which is unsupported by oracle

  • RowProxy()的keys()方法现在返回结果列名称normalized,使其成为SQLAlchemy不区分大小写的名称。[oracle] 这意味着对于不区分大小写的名称,它们将是小写字母,而DBAPI通常将它们作为大写名称返回。这允许行键()与进一步的SQLAlchemy操作兼容。

  • [oracle] 使用新的dialect.initialize()功能设置版本相关的行为。

  • [oracle] using types.BigInteger with Oracle will generate NUMBER(19)

    参考文献:#1125

  • [oracle] “区分大小写”功能将在反映过程中检测到全小写区分大小写的列名称,并将“quote = True”添加到生成的列中,以保持正确的引用。¶ T2>

火鸟¶ T0>

  • RowProxy()的keys()方法现在返回结果列名称标准化,使其成为SQLAlchemy不区分大小写的名称。[firebird] 这意味着对于不区分大小写的名称,它们将是小写字母,而DBAPI通常将它们作为大写名称返回。这允许行键()与进一步的SQLAlchemy操作兼容。

  • [firebird] 使用新的dialect.initialize()功能设置版本相关的行为。

  • [firebird] “区分大小写”功能将在反映过程中检测全小写区分大小写的列名称,并将“quote = True”添加到生成的列中,以便保持正确的引用。¶ T2>

杂项¶ T0>

  • [release] [major] 有关整套功能描述,请参阅http://docs.sqlalchemy.org/en/latest/changelog_migration_06.html这份文件是一项正在进行中的工作。

  • [release] [major] 0.6版本中包含的所有bug修复和功能增强都来自最新的0.5版本及以下版本。

  • [release] [major] 目前定位的平台包括Python 2.4 / 2.5 / 2.6,Python 3.1,Jython2.5.

  • [engines] transaction isolation level may be specified with create_engine(... isolation_level=”...”); available on postgresql and sqlite.

    参考文献:#443

  • [engines] 连接有execution_options(),这是生成方法,它接受影响语句执行的关键字w.r.t.DBAPI。当前支持“stream_results”,导致psycopg2为该语句使用服务器端游标,以及“autocommit”,它是select()和text()中“autocommit”选项的新位置。select()和text()也有.execution_options()以及ORM Query()。

  • [engines] 修复了入口点驱动方言的导入,不依靠愚蠢的tb_info技巧来确定导入错误状态

    参考文献:#1630

  • [engines] 将first()方法添加到ResultProxy,返回第一行并立即关闭结果集。

  • [engines] RowProxy objects are now pickleable, i.e. the object returned by result.fetchone(), result.fetchall() etc.

  • [engines] RowProxy no longer has a close() method, as the row no longer maintains a reference to the parent. 改为在父代ResultProxy上调用close(),或使用autoclose。

  • [engines] ResultProxy internals have been overhauled to greatly reduce method call counts when fetching columns. 在获取较大的结果集时可以提供很大的速度提升(高达100%以上)。当提取没有应用类型级别处理的列和将结果用作元组(而不是字典)时,这种改进会更大。非常感谢Elixir的Gaëtande Menten对这个戏剧性的改进!

    参考文献:#1586

  • [engines] 当存在一个组合主键时,依赖后缀“最后插入的id”获取生成的序列值(即MySQL,MS-SQL)的数据库现在可以正常工作,其中“自动增量“列不是表中的第一个主键列。

  • [engines] last_inserted_ids()方法已被重命名为描述符“inserted_primary_key”。

  • [engines] setting echo=False on create_engine() now sets the loglevel to WARN instead of NOTSET. 这样即使日志记录为“sqlalchemy.engine”,也可以禁用特定引擎的日志记录。请注意,“echo”的默认设置是None

    参考文献:#1554

  • [engines] ConnectionProxy now has wrapper methods for all transaction lifecycle events, including begin(), rollback(), commit() begin_nested(), begin_prepared(), prepare(), release_savepoint(), etc.

  • [engines] 连接池日志记录现在使用INFO和DEBUG日志级别进行日志记录。INFO用于主要事件,例如无效连接,所有获取/返回日志记录的DEBUG。echo_pool可以像echo一样使用False,None,True或“debug”。

  • [engines] 所有pyodbc方言现在支持额外的pyodbc特定kw参数'ansi','unicode_results','autocommit'。

    参考文献:#1621

  • [engines] “threadlocal”引擎已被重写和简化,现在支持SAVEPOINT操作。

  • [engines]

    已弃用或删除
    • result.last_inserted_ids()已弃用。使用result.inserted_primary_key
    • dialect.get_default_schema_name(连接)现在通过dialect.default_schema_name公开。
    • 来自engine.transaction()和engine.run_callable()的“连接”参数被删除 - 连接本身现在有这些方法。所有四种方法都接受传递给给定可调用的* args和** kwargs,以及操作连接。

  • [reflection/inspection] Table reflection has been expanded and generalized into a new API called “sqlalchemy.engine.reflection.Inspector”. Inspector对象提供有关各种模式信息的细粒度信息,并具有扩展空间,包括表名,列名,视图定义,序列,索引等。

  • [reflection/inspection] 视图现在可以反映为普通表格对象。使用相同的表构造函数,但要注意“有效的”主键和外键约束不是反射结果的一部分;如果需要,必须明确指定它们。

  • [reflection/inspection] The existing autoload=True system now uses Inspector underneath so that each dialect need only return “raw” data about tables and other objects - Inspector is the single place that information is compiled into Table objects so that consistency is at a maximum.

  • [ddl] the DDL system has been greatly expanded. DDL()类现在扩展了更通用的DDLElement(),它构成了许多新构造的基础:

    • CREATETABLE()
    • DROPTABLE()
    • AddConstraint()
    • DropConstraint()
    • 的CreateIndex()
    • DropIndex()
    • CreateSequence()
    • DropSequence()

    像普通的DDL()一样,这些支持“on”和“execute-at()”。可以使用sqlalchemy.ext.compiler扩展名创建用户定义的DDLElement子类并将其链接到编译器。

  • [ddl] 传递给DDL()和DDLElement()的“on”可调用的签名被修改如下:

    DDL
    DDLElement对象本身
    事件
    字符串事件名称。
    目标
    之前的“schema_item”,触发事件的Table或MetaData对象。
    连接
    用于该操作的Connection对象。
    **千瓦
    关键字参数。对于创建/删除之前/之后的元数据,CREATE / DROP DDL要发布的表对象列表作为kw参数“tables”传递。对于依赖于特定表的存在的元数据级DDL来说,这是必需的。
    DDL的“schema_item”属性已重命名为
    “目标”。

  • [dialect] [refactor] Dialect modules are now broken into database dialects plus DBAPI implementations. 连接URL现在最好使用dialect + driver:// ...指定,即“mysql + mysqldb:// scott:tiger @ localhost / test”。有关示例,请参阅0.6文档。

  • [dialect] [refactor] 外部方言的setuptools入口点现在称为“sqlalchemy.dialects”。

  • [dialect] [refactor] the “owner” keyword argument is removed from Table. 使用“模式”来表示任何名称空间要预先添加到表名中。

  • [dialect] [refactor] server_version_info成为一个静态属性

  • [dialect] [refactor] dialects receive an initialize() event on initial connection to determine connection properties.

  • [dialect] [refactor] dialects receive a visit_pool event have an opportunity to establish pool listeners.

  • [dialect] [refactor] 缓存的TypeEngine类是缓存的每个方言类而不是每个方言。

  • [dialect] [refactor] 新的UserDefinedType应该被用作新类型的基类,它保留了get_col_spec()的0.5行为。

  • [dialect] [refactor] 现在所有类型的result_processor()方法接受第二个参数“coltype”,它是cursor.description中的DBAPI类型参数。这个参数可以帮助某些类型决定最有效的结果值处理。

  • [dialect] [refactor] 已弃用Dialect.get_params()已移除

  • [dialect] [refactor] Dialect.get_rowcount() has been renamed to a descriptor “rowcount”, and calls cursor.rowcount directly. 需要为某些调用硬连线的方言应覆盖提供不同行为的方法。

  • [dialect] [refactor] DefaultRunner和子类已被删除。这个对象的工作已经简化并移入ExecutionContext。支持序列的方言应该在其执行上下文实现中添加一个fire_sequence()方法。

    参考文献:#1566

  • [dialect] [refactor] 编译器生成的函数和运算符现在使用形式为“visit_ ”和“visit_ _fn”的(几乎)常规调度函数来提供定制的处理。 T3> T2>这代替了在编译器子类中使用直接的访问方法复制“函数”和“操作符”字典的需要,并且还允许编译器子类完全控制渲染,因为完整的_Function或_BinaryExpression对象被传入。 T0>

  • [types] 方言内类型的构造已经彻底改变。方言现在将公开可用的类型定义为大写名称,而内部实现类型使用下划线标识符(即私有)。用SQL和DDL表示类型的系统已被移至编译器系统。这具有大部分方言中的类型对象少得多的效果。关于这种方言作者的体系结构的详细文档在lib / sqlalchemy / dialects_type_migration_guidelines.txt中。

  • [types] 类型不再对默认参数进行猜测。特别是Numeric,Float,NUMERIC,FLOAT,DECIMAL除非指定,否则不会生成任何长度或比例。

  • 二进制文件被重命名为types.LargeBinary,它只产生BLOB,BYTEA或类似的“长二进制”类型。[types] 添加了新的基本BINARY和VARBINARY类型,以不可知的方式访问这些MySQL / MS-SQL特定类型。

    参考文献:#1664

  • [types] String/Text/Unicode types now skip the unicode() check on each result column value if the dialect has detected the DBAPI as returning Python unicode objects natively. 此检查是在第一次连接时使用“SELECT CAST”某些文本“AS VARCHAR(10)”或等价物发出的,然后检查返回的对象是否为Python unicode。这使得native-unicode DBAPI具有巨大的性能提升,包括pysqlite / sqlite3,psycopg2和pg8000.

  • [types] 大多数类型的结果处理器已经过检查,可能会提高速度。具体而言,以下通用类型已进行了优化,从而改进了速度:Unicode,PickleType,Interval,TypeDecorator,Binary。此外,以下特定于dbapi的实现已得到改进:Sqlite上的Time,Date和DateTime,Postgresql上的ARRAY,MySQL上的Time,MySQL上的Numeric(as_decimal = False),MySQL上的python和pypostgresql,cx_oracle上的DateTime以及cx_oracle上的基于LOB的类型¶ T0>

  • [types] Reflection of types now returns the exact UPPERCASE type within types.py, or the UPPERCASE type within the dialect itself if the type is not a standard SQL type. 这意味着现在反射会返回有关反射类型的更准确的信息。

  • [types] 添加了一个新的Enum泛型类型。Enum是一个模式感知对象,用于支持需要特定DDL才能使用枚举或等效数据库的数据库;在PG的情况下,它处理CREATE TYPE的细节,并且在没有本地枚举支持的其他数据库上,将通过生成VARCHAR +内联CHECK约束来强制执行枚举。

    参考文献:#1511#1109

  • [types] Interval类型包含一个“native”标志,用于控制是否选择本地INTERVAL类型(postgresql + oracle)(如果可用)。还添加了“day_precision”和“second_precision”参数,它们适当地传播到这些本机类型。与。相关

    参考文献:#1467

  • [types] 布尔类型在不支持本机布尔支持的后端上使用时,将生成CHECK约束“col IN(0,1)”以及基于int / smallint的列类型。如果需要,可以使用create_constraint = False关闭此功能。请注意,MySQL没有本地布尔型 CHECK约束支持,所以此功能在该平台上不可用。

    参考文献:#1589

  • [types] 当mutable = True时,PickleType现在使用==来比较值,除非带有比较函数的“comparator”参数指定为类型。如果没有覆盖__eq __()或者没有提供比较函数,那么被腌制的对象将根据标识进行比较(这违背了mutable = True的目的)。

  • [types] Numeric和Float的默认“precision”和“scale”参数已被删除,现在默认为None。除非提供这些值,否则默认情况下,NUMERIC和FLOAT将默认呈现为不带数字参数。

  • [types] AbstractType.get_search_list()被移除 - 用于的游戏不再需要。

  • [types] 添加了一个通用的BigInteger类型,编译为BIGINT或NUMBER(19)。

    参考文献:#1125

  • [types] 使用autocommit = False,autoflush = True,sqlsoup已被彻底修改为显式支持0.5样式会话。SQLSoup的默认行为现在需要通常使用已添加到其接口的commit()和rollback()。explcit Session或scoped_session可以传递给构造函数,从而允许重写这些参数。

  • [types] sqlsoup db。.update()和delete()现在分别调用query(cls).update()和delete()。 < / T2>

  • [types] sqlsoup now has execute() and connection(), which call upon the Session methods of those names, ensuring that the bind is in terms of the SqlSoup object’s bind.

  • [types] sqlsoup objects no longer have the ‘query’ attribute - it’s not needed for sqlsoup’s usage paradigm and it gets in the way of a column that is actually named ‘query’.

  • [types] 传递给association_proxy的proxy_factory callable的签名现在是(lazy_collection,creator,value_attr,association_proxy),并添加第四个参数,即父AssociationProxy参数。允许内置集合的可序列化和子类化。

    参考文献:#1259

  • [types] 感谢Scott Torborg,association_proxy现在具有基本的比较器方法.any(),.has(),.contains(),==,!=。

    参考文献:#1372