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

SQLAlchemy 1.1文档

0.8更新日志

0.8.7 ¶ T0>

发布日期:2014年7月22日

ORM ¶ T0>

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

    参考文献:#3055

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

    参考文献:#3047

SQL ¶ T0>

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

    参考文献:#3124

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

    参考文献:#3102

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

    参考文献:#3044

  • 修复了当Table.update()Table.delete()在空的时候会产生一个空的WHERE子句的问题。[sql] [bug] and_()or_()或其他空白表达。这与select()的一致。

    参考文献:#3045

的PostgreSQL ¶ T0>

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

    参考文献:#3053

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

    参考:拉取请求bitbucket:13

MySQL的¶ T0>

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

    参考文献:#3101

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

    参考文献:#3085

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

    参考文献:拉取请求bitbucket:15

MSSQL ¶ T0>

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

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

    参考文献:#3091

杂项¶ T0>

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

    参考文献:#3062

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

    参考文献:#3093#3051

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

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

0.8.6 ¶ T0>

发布日期:2014年3月28日

一般¶ T0>

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

    参考文献:#2986

ORM ¶ T0>

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

    参考文献:#3006

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

    参考文献:#2995

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

  • [orm] [bug] sqlalchemy.orm.interfaces.__all__中删除了过期名称,并使用当前名称刷新,以便导入> *再次运作。

    参考文献:#2975

SQL ¶ T0>

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

    参考文献:#2977

的PostgreSQL ¶ T0>

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

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

    参考文献:#3000

杂项¶ T0>

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

    参考文献:#2997

0.8.5 ¶ T0>

发布日期:2014年2月19日

ORM ¶ T0>

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

    参考文献:#2951

  • 当一个迭代器对象被传递给class_mapper()或类似的错误消息时,修正错误消息,其中错误将无法在字符串格式上呈现。[orm] [bug] Pullleq礼貌Kyle Stark。

    参考文献:请求github:58

  • [orm] [bug] 调整subqueryload()策略,确保查询在加载过程开始后运行;这是为了使得子查询优先于其他装载者,因为其他的加载者可能在错误的时间因为其他的预先/非加载情况而触及相同的属性。

    参考文献:#2887

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

    参考文献:#2885

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

    参考文献:#2889

发动机¶ T0>

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

    参考文献:#2964#2880

SQL ¶ T0>

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

    参考文献:#2944

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

    参考文献:#2957

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

    参考文献:#2896

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

    参考文献:#2895

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

的PostgreSQL ¶ T0>

  • [postgresql] [bug] 增加了psycopg2断开连接检测的附加信息,“无法将数据发送到服务器”,补充了现有的“无法接收来自服务器的数据”并被用户观察到。 ¶ T2>

    参考文献:#2936

  • [postgresql] [bug]

    Postgresql在Postgresql的旧版本(之前的版本)以及其他PG引擎(如Redshift)(假设Redshift的版本报告为<8.1)时对Postgresql反射行为的支持得到了改进。查询“索引”以及“主键”依赖于检查所谓的“int2vector”数据类型,该数据类型在8.1之前拒绝胁迫数组,导致查询中使用的“ANY()”运算符失败。当PG版本<8.1被使用时,大量的搜索引擎已经找到了非常黑客但推荐的PG核心开发者查询,因此索引和主键约束反映现在可用于这些版本。

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

    参考文献:#2291

MySQL的¶ T0>

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

    参考文献:#2941

  • [mysql] [bug] 添加了对分区 BYPARTITIONS MySQL的支持将表关键字指定为mysql_partition_by='value'mysql_partitions='value'Table拉玛请求提供Marcus McCurdy。

    References: #2966, pull request bitbucket:12

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

    参考文献:#2933

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

    参考文献:pull request github:61

源码¶ T0>

  • [sqlite] [bug] 将唯一约束反射的回溯端口中遗漏的更改恢复为0.8,如果名称中包含保留关键字,那么带有SQLite的UniqueConstraint列。拉请求罗马Podolyaka。

    参考文献:请求github:72

MSSQL ¶ T0>

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

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

    参考文献:请求github:51

火鸟¶ T0>

  • [firebird] [bug] 火鸟方言会引用以下划线开头的标识符。Courtesy Treeve Jelbert。

    参考文献:#2897

  • [firebird] [bug] 修正了Firebird索引反射中索引内的列未正确排序的错误;现在它们按照RDB $ FIELD_POSITION的顺序排序。

杂项¶ T0>

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

    参考文献:pull request github:63

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

    参考文献:#2888

0.8.4 ¶ T0>

发布日期:2013年12月8日

ORM ¶ T0>

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

    参考文献:#2818

发动机¶ T0>

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

    参考文献:#2881

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

    参考文献:#2880

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

    参考文献:#2522

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

    参考文献:#2871

SQL ¶ T0>

的PostgreSQL ¶ T0>

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

    参考文献:#2855

MSSQL ¶ T0>

  • [mssql] [bug] 修正了在0.8.0版本中引入索引的DROP INDEX如果索引处于备用模式中,MSSQL将不正确地渲染; schemaname / tablename将被颠倒。该格式也进行了修改以符合当前的MSSQL文档。Courtesy Derek Harland。

    参考文献:pull request bitbucket:7

预言¶ T0>

  • [oracle] [bug] 增加了ORA-02396“最大空闲时间”的错误代码到cx_oracle的“is disconnect”代码列表。

    参考文献:#2864

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

    参考文献:#2870

杂项¶ T0>

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

    参考文献:#2869

0.8.3 ¶ T0>

发布日期:2013年10月26日

ORM ¶ T0>

  • [orm] [feature] 添加了relationship() distinct_target_key的新选项。这使得子查询预热加载器策略能够将DISTINCT应用到最内层的SELECT子查询中,以协助处理与该关系相对应的最内层查询生成重复行的情况(目前还没有解决内部dupe行问题的一般解决方案但是,当加入最内层子查询之外的子查询会产生欺骗)。当标志被设置为True时,DISTINCT被无条件渲染,当它被设置为None时,如果最内层关系针对不包含完整的主键。该选项在0.8中默认为False(例如,在所有情况下默认关闭),0.9中的None(例如默认为自动)。感谢Alexander Koval为此提供帮助。

    参考文献:#2836

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

    This change is also backported to: 0.7.11

    参考文献:#2807

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

    参考文献:#2813

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

    参考文献:#2818

  • [orm] [bug] 从0.9反向移植了一个变化,即在多态继承加载中使用的映射器层次的迭代是排序的,这允许为多态查询生成的SELECT语句具有确定性渲染,转向可以帮助缓存SQL字符串本身的缓存方案。

    参考文献:#2779

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

    参考文献:#2794

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

    参考文献:#2786

  • [orm] [bug] 性能修正与加载映射实体时使用defer()选项有关。在加载时将每个对象的延迟可调用应用于实例的函数开销显着高于仅从该行加载数据的开销(请注意,defer()旨在减少DB /网络开销,不一定函数调用计数);在所有情况下,函数调用开销都小于从列中加载数据的开销。每个负载创建的“惰性可调用”对象的数量也从N(结果中的总延迟值)减少到1(延迟列的总数)。

    参考文献:#2778

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

    参考文献:#2773

orm declarative

发动机¶ T0>

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

    参考文献:#2821

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

    This change is also backported to: 0.7.11

    参考文献:#2851

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

    参考文献:#2776

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

    参考文献:#2772

SQL ¶ T0>

  • [sql] [feature] insert()结构Insert.from_select()添加了新方法。Given a list of columns and a selectable, renders INSERT INTO (table) (columns) SELECT ...

    参考文献:#722

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

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

  • [sql] [bug] 固定回归到0.7.9,如果CTE的名称在多个FROM子句中被引用,那么它的名称可能不会被正确引用。

    This change is also backported to: 0.7.11

    参考文献:#2801

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

    This change is also backported to: 0.7.11

    参考文献:#2783

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

    This change is also backported to: 0.7.11

    参考文献:#2784

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

    参考文献:#2849

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

    参考文献:#2842

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

    参考文献:#2825

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

    参考文献:#2742

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

    参考文献:#2815

  • [sql] [bug] 不推荐使用ForeignKey上的非工作“模式”参数;提出警告。在0.9中删除。

    参考文献:#2831

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

    参考文献:#2811

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

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

    参考文献:#2780

的PostgreSQL ¶ T0>

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

    参考文献:#2844

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

    参考文献:#2742

  • [postgresql] [bug] 修复了Postgresql版本字符串在前缀“Postgresql”或“EnterpriseDB”之前的前缀不会被解析的错误。Courtesy Scott Schaefer。

    参考文献:#2819

MySQL的¶ T0>

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

    This change is also backported to: 0.7.11

    参考文献:#2791

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

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

    参考文献:#2721#2839

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

    参考文献:#2515

源码¶ T0>

  • [sqlite] [bug] 新添加的SQLite DATETIME参数storage_format和regexp显然没有完全正确地实现;当论据被接受时,实际上它们将不起作用;这已被修复。

    参考文献:#2781

预言¶ T0>

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

    参考文献:#2853

杂项¶ T0>

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

  • [feature] [examples] 改进了examples/generic_associations中的示例,包括discriminator_on_association.py利用单个表继承进行工作“鉴别者”。还添加了一个真正的“通用外键”示例,该示例与其他流行框架的工作方式类似,因为它使用开放式整数指向任何其他表,前面提到了传统的参照完整性。虽然我们不推荐这种模式,但信息要免费。

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

0.8.2 ¶ T0>

发布时间:2013年7月3日

ORM ¶ T0>

  • [orm] [feature] 添加了一个新的方法Query.select_entity_from(),它将在0.9中替换Query.select_from()在0.8中,这两种方法执行相同的功能,以便代码可以根据需要进行迁移以使用Query.select_entity_from()方法。有关详细信息,请参阅0.9迁移指南。

    参考文献:#2736

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

    参考文献:#2750

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

    参考文献:#2759

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

    参考文献:#2754

  • [orm] [bug] 修复了复合属性与aliased()函数之间的交互。以前,当应用别名时,组合属性在比较操作中无法正确工作。

    参考文献:#2755

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

    参考文献:#2730

  • [orm] [bug] Fixed a regression caused by #2682 whereby the evaluation invoked by Query.update() and Query.delete() would hit upon unsupported True and False symbols which now appear due to the usage of IS.

    参考文献:#2737

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

    参考文献:#2481

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

    参考文献:#2718

orm declarative

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

    参考文献:#2761

发动机¶ T0>

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

    参考文献:请求github:6

  • [engine] [bug] [sybase] Fixed a bug where the routine to detect the correct kwargs being sent to create_engine() would fail in some cases, such as with the Sybase dialect.

    参考文献:#2732

SQL ¶ T0>

  • [sql] [feature] TypeDecorator提供了一个名为TypeDecorator.coerce_to_is_types的新属性,以便更容易控制如何使用==!= to None和布尔类型用于生成IS表达式,参数。¶ T16>

    参考文献:#2734#2744

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

    • 为了满足这样的用例,其中FROM条目应该向外关联到一个包含另一个的SELECT,然后包含这个SELECT,当通过Select.correlate()建立显式相关性时,前提是目标选择位于WHERE / ORDER BY / columns子句所包含的链中,而不仅仅是嵌套的FROM子句。This makes Select.correlate() act more compatibly to that of 0.7 again while still maintaining the new “smart” correlation.
    • 当不使用显式关联时,通常的“隐式”关联将其行为限制为立即封闭的SELECT,以最大化与0.7应用程序的兼容性,并且还防止在这种情况下嵌套FROM之间的相关性,保持与0.8.0 / 0.8的兼容性。 1。
    • Select.correlate_except()方法在所有情况下都不会阻止给定的FROM子句相关,并且也会导致FROM子句完全被错误地省略(更像0.7会做的),这已经固定。
    • 调用select.correlate_except(None)将按照预期将所有FROM子句输入到相关中。

    参考文献:#2668#2746

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

    参考文献:#2738

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

    参考文献:#2728

  • [sql] [bug] 删除了来自基类ColumnOperators类的“未实现”__iter__()调用,而这是在0.8中引入的。 0,以防止在自定义运算符上实现__getitem__()方法,然后在该对象上错误地调用list()时出现无限的内存增长循环,导致列元素报告它们实际上是可迭代类型,当您尝试迭代时会抛出错误。没有真正的方式让双方都在这里,所以我们坚持使用Python的最佳实践。仔细在自定义运算符上实现__getitem__()

    参考文献:#2726

  • [sql] [bug] [mssql] 来自此票证的回归导致不支持的关键字“true”呈现,并添加了逻辑以将此转换为SQL服务器的1/0. ¶ t2 >

    参考文献:#2682

的PostgreSQL ¶ T0>

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

  • [postgresql] [feature] 在使用psycopg2 DBAPI时增加了对“AUTOCOMMIT”隔离的支持。该关键字可通过isolation_level执行选项使用。Pope礼貌Roman Podolyaka。

    参考文献:#2072

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

    参考文献:#2740

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

    参考文献:#2766

  • [postgresql] [bug] 修复了多列Postgresql索引中的列顺序将以错误顺序反映的错误。Courtesy Roman Podolyaka。

    参考文献:#2767

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

    参考文献:#2735请求github:2

MySQL的¶ T0>

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

    参考文献:#2704

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

    参考文献:#2768

  • [mysql] [bug] mysql+gaerdbms方言添加了另一个条件,用于检测所谓的“开发”模式,我们应该使用rdbms_mysqldb补丁礼貌Brett Slatkin。

    参考文献:#2715

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

    参考文献:#2721

  • [mysql] [bug] 更新mysqlconnector方言,根据异常中发送的明显字符串消息检查断开连接;针对mysqlconnector 1.0.9进行了测试。

源码¶ T0>

MSSQL ¶ T0>

  • 当在SQL Server 2000上查询信息模式时,删除了在0.8.1中添加的CAST调用,以帮助解决驱动程序问题,这在2000年显然不兼容。[mssql] [bug] CAST保持适用于SQL Server 2005及更高版本。

    参考文献:#2747

火鸟¶ T0>

  • [firebird] [feature] 为kinterbasdb和fdb方言添加了新的标志retaining=True这将控制发送到DBAPI连接的commit()rollback()方法的retaining标志的值。由于历史原因,该标志在0.8.2中默认为True,但在0.9.0b1中,该标志默认为False

    参考文献:#2763

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

    参考文献:#2757

杂项¶ T0>

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

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

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

  • [requirements] 现在需要Python mock库来运行单元测试套件。作为Python 3.3的标准库的一部分,以前的Python安装将需要安装它,以便运行单元测试或使用外部方言的sqlalchemy.testing包。 T2>

0.8.1 ¶ T0>

发布日期:2013年4月27日

ORM ¶ T0>

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

    参考文献:#2673

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

    This change is also backported to: 0.7.11

    参考文献:#2699

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

    This change is also backported to: 0.7.11

    参考文献:#2689

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

    参考文献:#2698

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

    参考文献:#2714

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

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

    参考文献:#2710

  • [orm] [bug] 改进了在Session内创建强引用的实例管理行为;如果对象处于过渡状态或进入分离状态,对象将不再创建内部引用循环 - 仅当对象连接到会话时才会创建强引用,并在分离对象时将其删除。这使得对象拥有一个__ del __()方法更为安全,尽管不推荐这样做,因为与backrefs的关系也会产生循环。当带有__ del __()方法的类被映射时,警告已被添加。

    参考文献:#2708

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

    参考文献:#2697

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

orm declarative

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

    参考文献:#2656

SQL ¶ T0>

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

  • [sql] [bug] [mysql] 完全实现了IS和IS NOT运算符的True / False常量。An expression like col.is_(True) will now render col IS true on the target platform, rather than converting the True/ False constant to an integer bound parameter. 当给定True / False常量时,这允许is_()运算符在MySQL上工作。

    参考文献:#2682

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

    参考文献:#2702

  • [sql] [bug] 修复了在Connection对象已经关闭后引发错误时断开连接检测错误会引发属性错误的问题。

    参考文献:#2691

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

    参考文献:#2703

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

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

    参考文献:#2695

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

的PostgreSQL ¶ T0>

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

    参考文献:#2712

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

    参考文献:#2681

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

    参考文献:#2680

MySQL的¶ T0>

  • [mysql] [bug] 修复了支持最新的cymysql DBAPI,礼貌Hajime Nakagami。

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

    参考文献:#2663

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

MSSQL ¶ T0>

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

    参考文献:#2355

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

  • [mssql] [bug] 修正了关于“binary”类型和pymssql的Py3K错误。感谢Marc Abramowitz。

    参考文献:#2683

杂项¶ T0>

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

0.8.0 ¶ T0>

发布日期:2013年3月9日

ORM ¶ T0>

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

    参考文献:#2675

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

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

    参考文献:#2658

  • [orm] [feature] 扩展了Runtime Inspection API系统,以便可以检索与ORM或其扩展相关联的所有Python描述符。这满足了除了hybrid_propertyAssociationProxy之类的扩展类型之外,还能够检查所有QueryableAttribute描述符的常见要求。参见Mapper.all_orm_descriptors

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

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

    参考文献:#2674

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

    参考文献:#2674

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

    参考文献:#2674

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

    参考文献:#2662

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

    参考文献:#2665

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

    参考文献:#2658

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

    参考文献:#2661

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

    参考文献:#1768

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

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

    参考文献:#2655

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

    参考文献:#2653

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

    参考文献:#2654

  • [orm] [bug] 修复了创建任意数量的sessionmaker对象时可能发生的内存泄漏。由sessionmaker创建的匿名子类在取消引用时不会被垃圾收集,因为事件包中剩余的类级别引用。此问题也适用于任何使用ad-hoc子类与事件分派器结合使用的自定义系统。同样在0.7.10.

    参考文献:#2650

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

    参考文献:#2640

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

    参考文献:#2637

SQL ¶ T0>

  • [sql] [feature] Added a new argument to Enum and its base SchemaType inherit_schema. 当设置为True时,该类型将设置与其相关联的Tableschema属性。这也发生在Table.tometadata()操作中;在Table.tometadata()发生的情况下,现在SchemaType被复制,并且如果inherit_schema=True,类型将采用新模式名称传递给方法。The schema is important when used with the Postgresql backend, as the type results in a CREATE TYPE statement.

    参考文献:#2657

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

    参考文献:#695

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

    参考文献:#2668

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

    参考文献:#1768#2660

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

    参考文献:#2496

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

    参考文献:#2643

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

    参考文献:#2629

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

    参考文献:#2648

架构¶ T0>

的PostgreSQL ¶ T0>

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

    This change is also backported to: 0.7.11

    参考文献:#2676

  • [postgresql] [feature] 添加了postgresql.ARRAY.Comparator.any()postgresql.ARRAY.Comparator.all()方法,以及独立的表达结构。非常感谢AudriusKažukauskas在这里的出色工作。

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

MySQL的¶ T0>

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

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

  • [mysql] [bug] [gae] gaerdbms方言添加了条件导入,它试图导入rdbms_apiproxy与rdbms_googleapi以在开发平台和生产平台上工作。现在也尊重instance属性。Courtesy Sean Lynch。同样在0.7.10.

    参考文献:#2649

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

MSSQL ¶ T0>

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

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

    参考文献:#2644

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

    参考文献:#2638

  • [mssql] [bug] 修复了字符类型CHAR,NCHAR等的“校对”参数的回归停止工作,因为基本字符串类型现在支持“整理”。MSSQL方言中的TEXT,NCHAR,CHAR,VARCHAR类型现在是基本类型的同义词。

预言¶ T0>

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

杂项¶ T0>

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

    参考文献:#2669

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

0.8.0b2 ¶ T0>

发布时间:2012年12月14日

ORM ¶ T0>

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

    参考文献:#2601

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

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

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

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

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

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

    请注意,此行为与Query.select_from()的原始较旧用例形成对比,这是使用不同的可选项重新表示映射实体的情况:

    session.query(User.name).\
      select_from(user_table.select().where(user_table.c.id > 5))

    其中产生:

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

    后一个用例的“别名”行为阻碍了前一个用例。该方法现在特别考虑像expression.select()expression.alias()这样的SQL表达式,与像aliased()

    参考文献:#2635

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

    参考文献:#2624

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

    参考文献:#2614

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

    参考文献:#2617

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

    参考文献:#2602

发动机¶ T0>

SQL ¶ T0>

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

    也可以看看

    Multiple-VALUES support for Insert的多个VALUES支持

    参考文献:#2623

  • [sql] [bug] Fixed bug where using server_onupdate= without passing the “for_update=True” flag would apply the default object to the server_default, blowing away whatever was there. 明确的for_update = True参数不应该与此用法一起使用(尤其是因为文档显示的示例没有使用它),因此现在使用给定的默认对象的副本在内部进行排列,如果该标志未设置为什么对应于这个参数。

    This change is also backported to: 0.7.10

    参考文献:#2631

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

    参考文献:#2633

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

    参考文献:#2610

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

    参考文献:#2618

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

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

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

    参考文献:#2621

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

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

    参考文献:#2603

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

    参考文献:#2597

的PostgreSQL ¶ T0>

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

    参考文献:#2606

源码¶ T0>

  • [sqlite] [bug] 对0.7.9版本中发布的SQLite相关问题进行更多调整,以便在反映外键时拦截旧版SQLite引用字符。除了拦截双引号外,其他引号字符(如括号,反引号和单引号)现在也被拦截。

    This change is also backported to: 0.7.10

    参考文献:#2568

MSSQL ¶ T0>

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

    参考文献:#2600

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

    This change is also backported to: 0.7.10

预言¶ T0>

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

    参考文献:#2619

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

    参考文献:#2620

  • [oracle] [bug] Repaired the usage of .prepare() in conjunction with cx_Oracle so that a return value of False will result in no call to connection.commit(), hence avoiding “no transaction” errors. 现在已经证明两阶段事务以SQLAlchemy和cx_oracle的方式发挥作用,但是在驱动程序中观察到警告;检查文档的细节。同样在0.7.10.

    参考文献:#2611

火鸟¶ T0>

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

    参考文献:#2622

杂项¶ T0>

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

    参考文献:#1753

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

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

    参考文献:#2611

  • [feature] [pool] 添加新的PoolEvents.reset()挂钩以在连接自动回滚之前捕获该事件,然后返回到池。ConnectionEvents.rollback()一起,这允许拦截所有回滚事件。

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

0.8.0b1 ¶ T0>

发布时间:2012年10月30日

一般¶ T0>

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

    参考文献:#2433

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

ORM ¶ T0>

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

    参考文献:#1401

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

    参考文献:#2333

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

    参考文献:#1106#2438

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

    参考文献:#2585

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

    参考文献:#2485

  • [orm] [feature] 增加了新的核心函数“inspect()”,它作为一个通用的网关来映射到映射器,对象等等。Mapper和InstanceState对象已通过公共API进行了增强,该API允许检查映射属性,包括列绑定或关系绑定属性的过滤器,当前对象状态的检查,属性的历史记录等。¶ t0 >

    参考文献:#2208

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

    参考文献:#2452

  • [orm] [feature] 增加了实用程序功能Session.enable_relationship_loading(),取代了relationship.load_on_pending。但是,这两个功能都应该避免。

    参考文献:#2372

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

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

    参考文献:#2229

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

    参考文献:#2229

  • [orm] [feature] 对于正在更新的表,Query.update()方法现在更加宽松。现在更好地支持Plain Table对象,并且update();可以使用附加的继承子类。子类表将成为更新的目标,如果在WHERE子句中引用了父表,编译器将调用UPDATE..FROM语法,如方言所允许的,以满足WHERE子句。MySQL的多表更新功能也受支持,如果列在“值”字段中由对象指定。PG的DELETE..USING在Core中也不可用。

  • [orm] [feature] 新会话事件after_transaction_create和after_transaction_end允许跟踪新的SessionTransaction对象。如果检查对象,可用于确定会话首次变为活动状态以及何时停用。

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

    参考文献:#2592

  • [orm] [feature] 默认查询“自动关联”,与select()一样。以前,在另一个查询中用作子查询将需要显式调用correlate()方法,以便将内部表与外部关联起来。与往常一样,关联(无)禁用关联。

    参考文献:#2179

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

    参考文献:#2464

  • [orm] [feature] 当在flush的“execute”部分中使用不支持的方法时,会话将产生警告。这些是熟悉的方法add(),delete()等。以及像在after_insert(),after_update()等mapper级别的刷新事件中调用的集合和相关对象操作。很长时间以来,SQLAlchemy无法保证结果在执行flush计划时被操纵,但用户仍在执行此操作,因此现在有警告。也许有一天会话会被增强以支持flush中的这些操作,但现在,结果不能得到保证。

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

    参考文献:#2245

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

    参考文献:#2245

  • [orm] [feature] declarative_base()中的类的注册表现在是一个WeakValueDictionary。因此,取消引用的“Base”的子类将被垃圾收集,如果它们没有被任何其他映射器/超类映射器引用,则为请参阅此票证的下一个注释。

    参考文献:#2526

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

    参考文献:#2472

  • [orm] [feature] declared_attr现在可以在非mixin类上使用,即使这通常仅用于单继承子类列冲突解决方法。

    参考文献:#2472

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

    参考文献:#2517

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

    参考文献:#2526

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

    参考文献:#2338

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

    参考文献:#2535

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

    参考文献:#1729

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

    参考文献:#2476

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

    参考文献:#2442

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

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

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

    参考文献:#2527

  • [orm] [bug] The instrumentation events class_instrument(), class_uninstrument(), and attribute_instrument() will now fire off only for descendant classes of the class assigned to listen(). 以前,无论传递的“目标”参数如何,都会分配一个事件侦听器来侦听所有类中的所有类。

    参考文献:#2590

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

    参考文献:#1900

  • [orm] [bug] 改进了加入/子查询加载处理共享公共基础的子类实体链,没有提供特定的“连接深度”。在检测到“循环”之前,将单独链接到每个子类映射器,而不是将基类视为“循环”的源。

    参考文献:#2481

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

    参考文献:#2320

  • [orm] [bug] 使用delete-orphan级联与一对多或多对多而没有single-parent = True时发出的警告现在是一个错误。在任何情况下,ORM将无法在此警告后发挥作用。

    参考文献:#2405

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

    参考文献:#2350

  • [orm] [bug] 继续处理由于事件侦听器引起的额外状态后冲刷;任何从属性角度标记为“脏”的状态,通常是通过after_insert(),after_update()等内的列属性设置事件,都会在所有情况下重置“历史记录”标志,而不是只有那些实例那是冲洗的一部分。这具有这样的效果,即该“脏”状态在刷新后不会结转并且不会导致UPDATE语句。为此发出警告; set_committed_state()方法可用于在不产生历史事件的情况下为对象分配属性。

    参考文献:#2582#2566

  • [orm] [bug] 修复了@declared_attr列和mixin上直接定义的列之间缓慢发展的断开连接。在这两种情况下,列将被应用到声明的类的表中,但不会应用到已连接的继承子类的表中。以前,直接定义的列将被放置在基本表和子表上,这通常不是我们所期望的。

    参考文献:#2565

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

    参考文献:#2549

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

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

发动机¶ T0>

  • [engine] [feature] 连接事件侦听器现在可以与单个Connection对象关联,而不仅仅是Engine对象。

    参考文献:#2511

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

    参考文献:#2459

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

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

    参考文献:#2462

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

    参考文献:#2556

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

  • [engine] [feature] Inspector.get_primary_keys()已弃用;使用Inspector.get_pk_constraint()。Courtesy Diana Clarke。

    参考文献:#2422

  • [engine] [feature] 由于我们有时间实现,新的C扩展模块“utils”已被添加用于其他功能加速。

  • [engine] [bug] Inspector.get_table_names()order_by =“foreign_key”功能现在首先按照dependee对表进行排序,以与util.sort_tables和metadata.sorted_tables保持一致。 T2>

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

    参考文献:#2522

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

    参考文献:#2397

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

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

    参考文献:#2498

  • [engine] 删除ResultProxy.last_inserted_ids,替换为inserted_primary_key。

SQL ¶ T0>

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

  • [sql] [feature] Major rework of operator system in Core, to allow redefinition of existing operators as well as addition of new operators at the type level. 新的类型可以从现有的类型创建,这些类型可以添加或重新定义输出到列表达式的操作,类似于ORM如何允许comparator_factory。新架构将此功能移入Core,以便在任何情况下始终如一地使用该功能,并使用现有类型的传播行为干净地传播。

    参考文献:#2547

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

    参考文献:#1534#2547

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

    请注意,此更改的效果是ORM与synonym()或其他“描述符包装”方案结合使用的基于描述符的__getitem__方案需要开始使用自定义比较器来维护此行为。

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

    参考文献:#2537

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

    参考文献:#2276

  • [sql] [feature] 现在可以通过将operators.custom_op()与UnaryExpression()结合使用自定义一元运算符。

  • [sql] [feature] 增强的GenericFunction和func。*允许通过func使用用户定义的GenericFunction子类。*名称空间自动按类名,可选地使用包名称,以及能够使所呈现的名称与func中识别的名称不同。* ¶ T0>

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

    参考文献:#2562

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

    参考文献:#2208

  • [sql] [feature] column_reflect事件现在接受Inspector对象作为第一个参数,位于“table”之前。使用这个新事件的0.7版本的代码将需要修改以添加“检查器”对象作为第一个参数。

    参考文献:#2418

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

    参考文献:#2423

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

    参考文献:#2415

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

    参考文献:#2502

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

    参考文献:#2507

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

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

    参考文献:#2431

  • [sql] [feature] 添加了reduce_columns()方法来选择()构造,使用util.reduce_columns实用程序函数内联列替换列以删除等效列。reduce_columns()还添加了“with_only_synonyms”,以将缩减限制为具有相同名称的列。弃用的fold_equivalents()功能被删除。

    参考文献:#1729

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

    参考文献:#2470

  • [sql] [feature] 为渲染CREATE TABLE的系统添加了一个钩子,通过针对新的schema.CreateColumn构造函数构造一个@compiles函数,为每个Column单独提供对渲染的访问。¶ T2>

    参考文献:#2463

  • [sql] [feature] “标量”选择现在有一个WHERE方法来帮助生成构建。关于SS如何“关联”列的细微调整;新方法不再适用于所选基础Table列的含义。这改善了一些相当深奥的情况,并且那里的逻辑似乎没有任何目的。

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

    参考文献:#2455

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

    参考文献:#2580

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

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

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

    参考文献:#2593

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

    参考文献:#2595

  • [sql] [bug] 调整列优先级,使“concat”和“match”运算符与“is”,“like”等相同。当与“IS”结合使用时,这有助于加括号渲染。

    参考文献:#2564

  • [sql] [bug] 使用带有或不带有其他修饰结构的标签将列表达式应用于select语句将不再将该表达“定位到”底层Column;这会影响依赖列定位以检索结果的ORM操作。也就是说,查询(User.id,User.id.label('foo'))这样的查询现在将分别跟踪每个“User.id”表达式的值,而不是将它们一起使用。预计任何用户都不会受到此影响;然而,如果select()命名的Column对象具有任意的.label()名称,则使用select()与query.from_statement()一起使用并试图加载完全组合的ORM实体的功能可能无法正常工作,因为这些将不会对该实体映射的Column对象更长的目标。

    参考文献:#2591

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

    参考文献:#2520

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

    参考文献:#2410

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

    参考文献:#2594

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

    参考文献:#2168

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

的PostgreSQL ¶ T0>

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

    参考文献:#2441

  • [postgresql] [feature] postgresql.ARRAY现在支持索引和切片。Python []运算符在所有类型为ARRAY的SQL表达式上可用;可以传递整数或简单的片段。切片也可以在UPDATE语句的SET子句的赋值端使用,方法是将它们传入Update.values();请参阅文档以获取示例。

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

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

    参考文献:#2506

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

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

    补丁礼貌ÉricLemoine。

MySQL的¶ T0>

  • [mysql] [feature] 为mysql语言添加了TIME类型,接受“fst”参数,它是最近MySQL版本的新“小数秒”说明符。数据类型将解释从驱动程序接收的微秒部分,但请注意,此时大多数/所有MySQL DBAPI都不支持返回该值。

    参考文献:#2534

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

    参考文献:#2404

源码¶ T0>

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

    参考文献:#2363

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

    参考文献:rc3addcc9ffad

MSSQL ¶ T0>

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

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

  • [mssql] [bug] 删除了传统行为,通过这种方式将标量SELECT via ==的列比较强制转换为SQL服务器方言的IN。这是隐含的行为,在其他情况下失败,因此被删除。依赖于此的代码需要修改以明确使用column.in_(select)。

    参考文献:#2277

预言¶ T0>

  • [oracle] [feature] 使用exclude_setinputsizes dialect参数,可以通过发送要排除的字符串DBAPI类型名称列表来定制从setinputsizes()集中排除的列的类型。此列表先前已修复。该列表现在默认为STRING,UNICODE,从列表中删除CLOB,NCLOB。

    参考文献:#2561

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

    参考文献:#2437

  • [oracle] [bug] Oracle中的CreateIndex构造现在将索引的名称限定为父表的名称。以前这个名字被省略了,这显然是在默认模式中创建索引,而不是在表中创建索引。

火鸟¶ T0>

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

    参考文献:#2470

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

    参考文献:#2504

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

    参考文献:#2505

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

  • [firebird] [bug] 支持在Firebird中使用DateTime类型时传递datetime作为日期;其他方言支持这一点。

杂项¶ T0>