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

SQLAlchemy 1.1文档

0.4更新日志

0.4.8 ¶ T0>

发布日期:2008年10月12日

ORM ¶ T0>

  • [orm] Fixed bug regarding inherit_condition passed with “A=B” versus “B=A” leading to errors

    参考文献:#1039

  • [orm] 在SessionExtension.before_flush()中对新的,脏的和删除的集合所做的更改将对该刷新生效。

  • [orm] Added label() method to InstrumentedAttribute to establish forwards compatibility with 0.5.

SQL ¶ T0>

  • [sql] column.in_(someselect) can now be used as a columns-clause expression without the subquery bleeding into the FROM clause

    参考文献:#1074

MySQL的¶ T0>

  • [mysql] 新增MSMediumInteger类型

    参考文献:#1146

源码¶ T0>

预言¶ T0>

  • [oracle] has_sequence()现在将模式名称考虑在内

    参考文献:#1155

  • [oracle] 将BFILE添加到反射类型列表

    参考文献:#1121

0.4.7p1 ¶ T0>

发布日期:2008年7月31日

ORM ¶ T0>

  • [orm] 在scoped_session方法中添加了“add()”和“add_all()”。0.4.7的解决方法:

    from sqlalchemy.orm.scoping import ScopedSession, instrument
    setattr(ScopedSession, "add", instrument("add"))
    setattr(ScopedSession, "add_all", instrument("add_all"))

  • [orm] 修正了relation()中set()和generator表达式的非2.3兼容用法。

0.4.7 ¶ T0>

发布日期:2008年7月26日星期六

ORM ¶ T0>

  • [orm] The contains() operator when used with many-to-many will alias() the secondary (association) table so that multiple contains() calls will not conflict with each other

    参考文献:#1058

  • [orm] fixed bug preventing merge() from functioning in conjunction with a comparable_property()

  • [orm] the enable_typechecks=False setting on relation() now only allows subtypes with inheriting mappers. 完全不相关的类型或未针对目标映射器设置映射器继承的子类型仍然是不允许的。

  • [orm] 为会话添加了is_active标志以检测事务何时正在进行。这个标志总是与真正的“事务性”(0.5在一个非“autocommit”)会话。

    参考文献:#976

SQL ¶ T0>

  • [sql] Fixed bug when calling select([literal(‘foo’)]) or select([bindparam(‘foo’)]).

架构¶ T0>

  • [schema] create_all(), drop_all(), create(), drop() all raise an error if the table name or schema name contains more characters than that dialect’s configured character limit. 某些数据库可以在使用过程中处理太长的表名,SQLA也可以处理这些。但是,由于我们正在数据库的目录表中查找名称,因此各种反射/ checkfirst-during-create方案失败。

    参考文献:#571

  • [schema] 当您在列上表示“index = True”时生成的索引名称被截断为适合该方言的长度。另外,名称太长的索引不能通过Index.drop()显式删除,类似于。

    参考文献:#571#820

MySQL的¶ T0>

  • [mysql] 将'CALL'添加到返回结果行的SQL关键字列表中。

预言¶ T0>

  • [oracle] Oracle get_default_schema_name()在返回之前“标准化”名称,这意味着当标识符被检测为不区分大小写时,它返回一个小写名称

  • [oracle] 在创建/删除表时,在搜索现有表时要考虑模式名,以便其他所有者名称空间中具有相同名称的表不会发生冲突

    参考文献:#709

  • [oracle] Cursors now have “arraysize” set to 50 by default on them, the value of which is configurable using the “arraysize” argument to create_engine() with the Oracle dialect. 这将考虑到cx_oracle的默认设置为“1”,这会导致很多往返行程被发送到Oracle。这实际上与BLOB / CLOB绑定游标一起运行良好,其中有任何可用的数字,但仅限于该行请求的生命周期(因此BufferedColumnRow仍然需要,但更少)。

    参考文献:#1062

  • [oracle]

    源码
    • 添加SLFloat类型,该类型与SQLite REAL类型关联相匹配。以前,只提供SLNumeric来满足NUMERIC的亲和力,但这与REAL不一样。

杂项¶ T0>

  • [postgres] 修复了server_side_cursors以正确检测text()子句。

  • [postgres] 添加了PGCidr类型

    参考文献:#1092

0.4.6 ¶ T0>

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

ORM ¶ T0>

  • [orm] 解决了最近的关系()重构问题,它修复了多次连接本地表和远程表的异域查看关系,并在连接之间共享一个公共列。

  • [orm] 还重新建立了连接多个表的viewonly关系()配置。

  • [orm] Added experimental relation() flag to help with primaryjoins across functions, etc., _local_remote_pairs=[tuples]. 这补充了一个复杂的primaryjoin条件,允许您提供组成关系的本地和远程端的各个列对。还改进了懒加载SQL生成以处理在函数和其他表达式中放置绑定参数。(部分进展)

    参考文献:#610

  • [orm] 修复了单个表继承,这样你就可以从一个连接表中继承一个没有问题的映射器。

    参考文献:#1036

  • [orm] 修正了发生在Query.order_by()if子句自适应发生时的“串联元组”bug。

    参考文献:#1027

  • [orm] 删除了映射选择器需要“别名”的古老断言 - 如果没有映射器存在,映射器现在会创建自己的别名。尽管在这种情况下,您需要使用类而不是映射的可选项作为列属性的来源 - 因此仍然会发出警告。

  • [orm] fixes to the “exists” function involving inheritance (any(), has(), ~contains()); the full target join will be rendered into the EXISTS clause for relations that link to subclasses.

  • [orm] 在主查询行中恢复了对append_result()扩展方法的使用,当扩展存在时并且仅返回单个实体结果时

  • [orm] 还重新建立了连接多个表的viewonly关系()配置。

  • [orm] removed ancient assertion that mapped selectables require “alias names” - the mapper creates its own alias now if none is present. 尽管在这种情况下,您需要使用类而不是映射的可选项作为列属性的来源 - 因此仍然会发出警告。

  • [orm] refined mapper._save_obj() which was unnecessarily calling __ne__() on scalar values during flush

    参考文献:#1015

  • [orm] added a feature to eager loading whereby subqueries set as column_property() with explicit label names (which is not necessary, btw) will have the label anonymized when the instance is part of the eager join, to prevent conflicts with a subquery or column of the same name on the parent object.

    参考文献:#1019

  • [orm] set-based collections |=, -=, ^= and &= are stricter about their operands and only operate on sets, frozensets or subclasses of the collection type. 以前,他们会接受任何duck-typed集合。

  • [orm] 添加了一个dynamic_dict / dynamic_dict.py示例,说明了如何将一个简单的方法放置在dynamic_loader之上。

SQL ¶ T0>

  • [sql] 通过.collat​​e()表达式运算符和collat​​e()sql函数添加COLLATE支持。 T3> T2>

  • [sql] Fixed bug with union() when applied to non-Table connected select statements

  • [sql] improved behavior of text() expressions when used as FROM clauses, such as select().select_from(text(“sometext”))

    参考文献:#1014

  • [sql] Column.copy() respects the value of “autoincrement”, fixes usage with Migrate

    参考文献:#1021

MSSQL ¶ T0>

  • [mssql] 在引擎/ dburi参数中添加了“odbc_autotranslate”参数。任何给定的字符串将被传递给ODBC连接字符串,如下所示:

    “AutoTranslate =%s”%odbc_autotranslate

    参考文献:#1005

  • [mssql] 在引擎/ dburi参数中添加了“odbc_options”参数。给定的字符串仅附加到SQLAlchemy生成的odbc连接字符串。

    这应该可以避免将来添加大量的ODBC选项。

火鸟¶ T0>

  • [firebird] 处理“SUBSTRING(:string FROM:start FOR:length)”builtin。

杂项¶ T0>

  • [declarative] [extension] 联合表继承映射器使用稍微宽松的函数为父表创建“继承条件”,以便尚未声明Table对象的其他外键不会触发一个错误。

  • [declarative] [extension] fixed reentrant mapper compile hang when a declared attribute is used within ForeignKey, ie. ForeignKey的(MyOtherClass.someattribute)¶ T0>

  • [engines] 现在,可以将池侦听器作为可调用的字典或(可能部分)鸭式PoolListener的字典提供,您可以选择。

  • [engines] 将“rollback_returned”选项添加到池,这将禁用连接返回时发出的回滚()。这个标志只适用于不支持事务的数据库(即MySQL / MyISAM)。

  • [ext] 基于集合的关联代理| =, - =,^ =和&=对它们的操作数更严格,仅对集合,frozensets或其他关联代理进行操作。以前,他们会接受任何duck-typed集合。

0.4.5 ¶ T0>

发布日期:2008年4月4日

ORM ¶ T0>

  • [orm] 对session.merge()行为的一个小改动 - 根据主键属性检查现有对象,而不一定是_instance_key。所以广泛要求的能力,即:

    x = MyObject(id = 1)x = sess.merge(x)

    实际上将加载数据库中ID为1的MyObject(如果存在),现在可用。merge()仍将给定对象的状态复制到持久对象,因此类似上述的示例通常会将“x”的所有属性的“None”复制到持久副本上。这些可以使用session.expire(x)来恢复。

  • [orm] 在merge()中也有固定的行为,因此收集元素出现在目的地但不是合并的集合中没有被从目标中移除

  • [orm] 为“未编译的映射器”添加了更积极的检查,特别有助于声明层

    参考文献:#995

  • [orm] The methodology behind “primaryjoin”/”secondaryjoin” has been refactored. 行为应该稍微更智能一些,主要是通过减少错误信息来提高可读性。在少数情况下,它可以比以前更好地解析正确的外键。

  • [orm] 新增了comparable_property(),将查询Comparator行为添加到常规非托管Python属性中

  • [orm] [‘machines’] [Company.employees.of_type(Engineer)] the functionality of query.with_polymorphic() has been added to mapper() as a configuration option.

    它通过几种形式设置:
    with_polymorphic ='*'with_polymorphic = [mappers] with_polymorphic =('*',可选)with_polymorphic =([mappers],可选)

    这将控制继承的映射器的默认多态加载策略。如果没有给出selectable,则为所有请求的连接表继承映射器创建外部连接。请注意,自动创建连接与具体的表继承不兼容。

    mapper()现有的select_table标志现在已被弃用,并与with_polymorphic('*',select_table)同义。请注意,select_table的底层“内核”已被完全删除,并被更新,更灵活的方法所取代。

    新方法还会自动允许急切加载为子类(如果存在)工作,例如:

    sess.query(Company).options(
     eagerload_all(
    ))

    加载公司对象,他们的员工以及碰巧是工程师的'机器'员工集合。应该尽快引入“with_polymorphic”查询选项,这将允许每个查询控制with_polymorphic()关系。

  • [orm] added two “experimental” features to Query, “experimental” in that their specific name/behavior is not carved in stone just yet: _values() and _from_self(). 我们希望对这些反馈意见。

    • 给_values(*列)一列列表达式,并返回一个新的查询,它只返回那些列。评估时,返回值是一个元组列表,就像使用add_column()或add_entity()时一样,唯一的区别是“实体零”即映射的类不包含在结果中。这意味着在查询中使用group_by()和having(),这是最终有意义的,直到现在,Query一直是无用的。

      对这种方法的未来改变可能包括它加入,过滤和允许与“结果集”无关的其他选项的能力被删除,所以我们正在寻找的反馈是人们如何使用_values()...即,在最后,还是人们喜欢在被调用后继续生成。

    • _from_self()编译查询的SELECT语句(减去任何渴望的加载器),并返回一个新的从该SELECT中选择的Query。所以基本上你可以从查询中查询而不需要手动提取SELECT语句。这为查询[3:5] ._ from_self()。filter(某些标准)等操作提供了意义。除了可以快速创建效率较低的高度嵌套查询之外,这里没有太多争议,我们希望对命名选择提供反馈。

  • [orm] query.order_by() and query.group_by() will accept multiple arguments using *args (like select() already does).

  • [orm] Added some convenience descriptors to Query: query.statement returns the full SELECT construct, query.whereclause returns just the WHERE part of the SELECT construct.

  • [orm] Fixed/covered case when using a False/0 value as a polymorphic discriminator.

  • [orm] 修正了阻止同义词()属性被用于继承的错误

  • [orm] 修正后缀下划线的SQL函数截断

    参考文献:#996

  • [orm] 当一个挂起的实例的属性到期时,当刷新动作被触发并且没有找到结果时,将不会引发错误。

  • [orm] Session.execute can now find binds from metadata

  • [orm] 将“self-referential”的定义调整为任何具有公共父元素的两个映射器(这会影响与Query连接时是否需要aliased = True)。¶< / T2>

  • [orm] Made some fixes to the “from_joinpoint” argument to query.join() so that if the previous join was aliased and this one isn’t, the join still happens successfully.

  • [orm]

    什锦“级联删除”修复:
    • 修复了动态关系的“级联删除”操作,该操作仅在0.4.2中针对外键清零行为实施,而不是实际的级联删除
    • 在父对象上调用session.delete()之前,多对一删除没有删除孤立级联的级联不会删除与父级断开连接的孤儿(一对多已经有此)。
    • 使用delete-orphan删除级联将删除孤儿,而不管它是否仍然连接到其还被删除的父级。
    • 当使用继承时,在超类中存在的关系上正确检测到delete-orphan casacde。

    参考文献:#895

  • [orm] Fixed order_by calculation in Query to properly alias mapper-config’ed order_by when using select_from()

  • [orm] 重构了将集合替换为另一个集合时使用的差异逻辑,存入collections.bulk_replace中,对构建多级集合的任何人都有用。

  • [orm] 级联遍历算法从递归转换为迭代以支持深对象图。

SQL ¶ T0>

  • [sql] schema-qualified tables now will place the schemaname ahead of the tablename in all column expressions as well as when generating column labels. 这可以防止所有情况下的跨模式名称冲突

    参考文献:#999

  • [sql] can now allow selects which correlate all FROM clauses and have no FROM themselves. 这些通常用于标量环境中,即SELECT x,(SELECT x WHERE y)FROM table。需要显式的correlate()调用。

  • [sql] ‘name’ is no longer a required constructor argument for Column(). 它(和.key)现在可以推迟到列被添加到表中。

  • [sql] like(), ilike(), contains(), startswith(), endswith() take an optional keyword argument “escape=”, which is set as the escape character using the syntax “x LIKE y ESCAPE ‘’”.

    参考文献:#791#993

  • [sql] random() is now a generic sql function and will compile to the database’s random implementation, if any.

  • [sql] update()。values()和insert()。values()接受关键字参数

  • [sql] Fixed an issue in select() regarding its generation of FROM clauses, in rare circumstances two clauses could be produced when one was intended to cancel out the other. 一些有很多急切加载的ORM查询可能已经看到了这种症状。

  • [sql] The case() function now also takes a dictionary as its whens parameter. 它还将“THEN”表达式解释为默认值,意思是case([(x == y,“foo”)])会将“foo”解释为绑定值,而不是SQL表达式。在这种情况下,使用文本(expr)作为文字SQL表达式。对于标准本身,只有存在“value”关键字时,这些才可以是文字字符串,否则SA将强制显式使用text()或literal()。

MySQL的¶ T0>

  • [mysql] 方言用于缓存服务器设置的connection.info键已更改,现在命名空间

MSSQL ¶ T0>

  • [mssql] 反射表现在会自动加载自动加载表中外键引用的其他表,

    参考文献:#979

  • [mssql] 添加了executemany检查以跳过标识获取,

    参考文献:#916

  • [mssql] 添加小日期类型的存根

    参考文献:#884

  • [mssql] 为pyodbc方言添加了一个新的'driver'关键字参数。如果提供,将替换为ODBC连接字符串,默认为'SQL Server'。

  • [mssql] 为pyodbc方言增加了一个新的'max_identifier_length'关键字参数。

  • [mssql] 改进pyodbc + Unix。如果您之前无法使用该组合,请再试一次。

预言¶ T0>

  • [oracle] 表中的“owner”关键字现在已被弃用,并且与“schema”关键字完全同义。现在可以使用替代的“所有者”属性来反映表,这些属性在Table对象中明确声明或不使用“schema”。

  • [oracle] 搜索同义词的所有“魔法”,DBLINK等。在表反射期间默认情况下是禁用的,除非您在表对象上指定“oracle_resolve_synonyms = True”。解析同义词必然会导致一些混乱的猜测,我们宁愿在默认情况下离开。设置标志时,表格和相关表格将在所有情况下针对同义词进行解析,这意味着如果某个特定表格存在同义词,则反映将在反映相关表格时使用它。这比以前更加粘性,这就是为什么它默认关闭。

  • [oracle] 表中的“owner”关键字现在已被弃用,并且与“schema”关键字完全同义。现在可以使用替代的“所有者”属性来反映表,这些属性在Table对象中明确声明或不使用“schema”。

  • [oracle] 搜索同义词的所有“魔法”,DBLINK等。在表反射期间默认情况下是禁用的,除非您在表对象上指定“oracle_resolve_synonyms = True”。解析同义词必然会导致一些混乱的猜测,我们宁愿在默认情况下离开。设置标志时,表格和相关表格将在所有情况下针对同义词进行解析,这意味着如果某个特定表格存在同义词,则反映将在反映相关表格时使用它。这比以前更加粘性,这就是为什么它默认关闭。

杂项¶ T0>

  • [declarative] [extension] “同义词”功能现在可直接与“声明式”使用。使用“描述符”关键字参数传递装饰属性,例如:somekey = synonym('_ somekey',descriptor = property(g,s))

  • [declarative] [extension] “延迟”功能可用于“声明式”。最简单的用法是将deferred和Column声明在一起,例如:data = deferred(Column(Text))

  • [declarative] [extension] Declarative also gained @synonym_for(...) and @comparable_using(...), front-ends for synonym and comparable_property.

  • [declarative] [extension] 在使用声明性时改进了mapper编译;当使用时,已编译的映射器仍然会触发编译其他未编译的映射器

    参考文献:#995

  • [declarative] [extension] Declarative will complete setup for Columns lacking names, allows a more DRY syntax.

    Foo类(基地):
    __tablename__ ='foos'id =列(整型,primary_key = True)

  • [declarative] [extension] inheritance in declarative can be disabled when sending “inherits=None” to __mapper_args__.

  • [declarative] [extension] declarative_base() takes optional kwarg “mapper”, which is any callable/class/method that produces a mapper, such as declarative_base(mapper=scopedsession.mapper). 这个属性也可以使用“__mapper_cls__”属性在单独的声明式类中设置。

  • [postgres] 将PG服务器端游标恢复成形,添加固定单元测试作为默认测试套件的一部分。为光标ID 添加了更好的唯一性

    参考文献:#1001

0.4.4 ¶ T0>

发布日期:2008年3月12日

ORM ¶ T0>

  • [orm] any(), has(), contains(), ~contains(), attribute level == and != now work properly with self-referential relations - the clause inside the EXISTS is aliased on the “remote” side to distinguish it from the parent table. 这适用于单表自我引用以及基于继承的自引用。

  • [orm] 当与一对一关系的NULL进行比较时,关系()级别的==和!=运算符的修复行为

    参考文献:#985

  • [orm] Fixed bug whereby session.expire() attributes were not loading on an polymorphically-mapped instance mapped by a select_table mapper.

  • [orm] 新增了query.with_polymorphic() - 指定从基类继承的类的列表,该列将被添加到查询的FROM子句中。允许在filter()标准中使用子类,并且急切地加载这些子类的属性。

  • [orm] Your cries have been heard: removing a pending item from an attribute or collection with delete-orphan expunges the item from the session; no FlushError is raised. 请注意,如果session.save()显式地处理了待处理项目,那么属性/集合删除仍会将其敲除。

  • [orm] session.refresh() and session.expire() raise an error when called on instances which are not persistent within the session

  • [orm] 修复了使用join()方法生成多个查询对象时使用相同Query的潜在生成bug。

  • [orm] Fixed bug which was introduced in 0.4.3, whereby loading an already-persistent instance mapped with joined table inheritance would trigger a useless “secondary” load from its joined table, when using the default “select” polymorphic_fetch. 这是由于属性在第一次加载过程中被标记为过期,并且没有从先前的“次要”加载取消标记。在任何加载或提交操作成功之后,基于__dict__中的存在,属性现在未到期。

  • [orm] Deprecated Query methods apply_sum(), apply_max(), apply_min(), apply_avg(). 更好的方法来了......

  • [orm] relation() can accept a callable for its first argument, which returns the class to be related. 这是为了协助声明性包来定义关系,而没有使用类。

  • [orm] Added a new “higher level” operator called “of_type()”: used in join() as well as with any() and has(), qualifies the subclass which will be used in filter criterion, e.g.:

    query.filter(Company.employees.of_type(工程师)。
    任何(Engineer.name ==”富”))

    要么

    query.join(Company.employees.of_type(工程师))。
    过滤(Engineer.name ==”富”)

  • [orm] 针对flush()中潜在的丢失引用错误的预防代码。

  • [orm] Expressions used in filter(), filter_by() and others, when they make usage of a clause generated from a relation using the identity of a child object (e.g., filter(Parent.child==)), evaluate the actual primary key value of at execution time so that the autoflush step of the Query can complete, thereby populating the PK value of in the case that was pending.

  • [orm] setting the relation()-level order by to a column in the many-to-many “secondary” table will now work with eager loading, previously the “order by” wasn’t aliased against the secondary table’s alias.

  • [orm] 现有描述符之上的同义词现在是这些描述符的完整代理。

SQL ¶ T0>

  • [sql] 可以根据文本FROM子句再次创建选择别名。

    参考文献:#975

  • [sql] bindparam()的值可以是一个可调用的,在这种情况下,它会在语句执行时计算以获取该值。

  • [sql] 增加了异常包装/重新连接支持以获取结果集。重新连接适用于那些在结果期间引发可捕获数据错误的数据库(即,不适用于MySQL)

    参考文献:#978

  • [sql] 通过engine.begin_twophase(),engine.prepare()实现“threadlocal”引擎的两阶段API。

    参考文献:#936

  • [sql] 修正了阻止UNION被克隆的bug。

    参考文献:#986

  • [sql] Added “bind” keyword argument to insert(), update(), delete() and DDL(). .bind属性现在可以在这些语句以及select()上分配。

  • [sql] Insert statements can now be compiled with extra “prefix” words between INSERT and INTO, for vendor extensions like MySQL’s INSERT IGNORE INTO table.

杂项¶ T0>

  • [dialects] 无效的SQLite连接URL现在引发错误。

  • [dialects] postgres TIMESTAMP正确呈现

    参考文献:#981

  • [dialects] 默认情况下,postgres PGArray是一个“可变”类型;当与ORM一起使用时,可变样式相等/写时复制技术用于测试更改。

  • [extensions] 添加了一个新的超小型“声明式”扩展,它允许Table和mapper()配置在类声明下以内联方式进行。这个扩展不同于ActiveMapper和Elixir,因为它根本不重新定义任何SQLAlchemy语义;文字Column,Table和relation()构造用于定义类的行为和表定义。

0.4.3 ¶ T0>

发布日期:2008年2月14日

一般¶ T0>

  • [general] 修正了Python 2.3中各种隐藏和一些不那么隐藏的兼容性问题,这要归功于在2.3上运行完整测试套件的新支持。

  • [general] 警告现在发布为类型exceptions.SAWarning。

ORM ¶ T0>

  • [orm] Every Session.begin() must now be accompanied by a corresponding commit() or rollback() unless the session is closed with Session.close(). 这还包括用transactional = True创建的会话隐含的begin()。这里介绍的最大变化是,当使用transactional = True创建的会话在flush()期间引发异常时,必须调用Session.rollback()或Session.close()以便该会话在异常后继续。¶ T0>

  • [orm] 固定merge()集合 - 当将瞬态实体与backref的集合合并时加倍的bug。

    参考文献:#961

  • [orm] merge(dont_load=True) does not accept transient entities, this is in continuation with the fact that merge(dont_load=True) does not accept any “dirty” objects either.

  • [orm] 添加了由scoped_session生成的独立“查询”类属性。这提供了MyClass.query而不使用Session.mapper。使用途径:

    MyClass.query = Session.query_property()

  • [orm] 尝试访问过期实例属性时没有会话存在时,会引发正确的错误消息

  • [orm] dynamic_loader() / lazy=”dynamic” now accepts and uses the order_by parameter in the same way in which it works with relation().

  • [orm] 为Session添加了expire_all()方法。调用所有持久实例的expire()。这与... 相结合

  • [orm] 已经部分或完全过期的实例将在定期查询操作期间填充它们的过期属性,从而影响这些对象,从而为每个实例阻止不必要的第二条SQL语句。 T2>

  • [orm] Dynamic relations, when referenced, create a strong reference to the parent object so that the query still has a parent to call against even if the parent is only created (and otherwise dereferenced) within the scope of a single expression.

    参考文献:#938

  • [orm] 添加了mapper()标志“eager_defaults”。如果设置为True,则在INSERT或UPDATE操作期间生成的缺省值会立即被后取回,而不会延迟到稍后。这模仿了旧的0.3行为。

  • [orm] query.join() can now accept class-mapped attributes as arguments. 这些可以用于或与琴弦结合使用。特别是,这允许构建多态关系上的子类的连接,即:

    查询(公司).join(['employees',Engineer.name])

  • [orm] [people.join(engineer))] [(‘employees’] [Engineer.name] query.join() can also accept tuples of attribute name/some selectable as arguments. 这允许从多态关系的子类建立连接,即:

    查询(公司)。加入(

    )

  • [orm] 结合多态映射器的join()行为的一般改进,即从/到多态映射器的连接和正确应用别名。

  • [orm] Fixed/improved behavior when a mapper determines the natural “primary key” of a mapped join, it will more effectively reduce columns which are equivalent via foreign key relation. 这会影响需要将多少个参数发送到query.get()等。

    参考文献:#933

  • [orm] 延迟加载器现在可以处理连接条件,其中“绑定”列(即获取作为绑定参数发送的父代码的列)在连接条件中多次出现。具体来说,这允许包含父相关子查询的关系()的常见任务,比如“只选择最近的子项”。

    参考文献:#946

  • [orm] Fixed bug in polymorphic inheritance where an incorrect exception is raised when base polymorphic_on column does not correspond to any columns within the local selectable of an inheriting mapper more than one level deep

  • [orm] Fixed bug in polymorphic inheritance which made it difficult to set a working “order_by” on a polymorphic mapper.

  • [orm] 在Query中修复了一个相当昂贵的调用,它减缓了多态查询的速度。

  • 如果需要,可以在flush()调用期间加载“被动默认值”和其他“内联”默认值; [orm] 特别是,这允许在外键列引用服务器端生成的非主键列的情况下构建关系()。

    参考文献:#954

  • [orm]

    其他会话事务修正/更改:
    • 修正会话事务管理的错误:在向嵌套事务添加连接时,父连接事务未在连接上启动。
    • session.transaction现在始终引用最内层的活动事务,即使在会话事务对象上直接调用commit / rollback时也是如此。
    • 现在可以准备两阶段交易。
    • 在一个连接上准备两阶段事务失败时,所有连接都会回滚。
    • 当使用嵌套事务时,session.close()没有关闭所有事务。
    • rollback()以前错误地将当前事务直接设置为可以回滚到的事务的父级。现在它回滚可以处理它的下一个事务,但将当前事务设置为其父项,并停用它们之间的事务。非活动事务只能回滚或关闭,任何其他调用都会导致错误。
    • 对于简单的子事务,commit()的autoflush不会冲洗。
    • 当会话不在事务中并且提交事务失败时,unitofwork flush没有关闭失败的事务。

  • [orm] 其他票据:

    参考文献:#964#940

SQL ¶ T0>

  • [sql] 添加了“schema.DDL”,一个可执行的自由格式的DDL语句。DDL可以独立执行或附加到Table或MetaData实例,并在创建和/或删除对象时自动执行。

  • [sql] Table columns and constraints can be overridden on a an existing table (such as a table that was already reflected) using the ‘useexisting=True’ flag, which now takes into account the arguments passed along with it.

  • [sql] 添加了一个基于可调用的DDL事件接口,在Tables和MetaData创建和删除之前和之后添加了钩子。

  • [sql] Added generative where() method to delete() and update() constructs which return a new object with criterion joined to existing criterion via AND, just like select().where().

  • [sql] Added “ilike()” operator to column operations. 在postgres上编译为ILIKE,在所有其他上编译为(lower)(y)。

    参考文献:#727

  • [sql] 将“now()”添加为通用函数;在SQLite上,Oracle和MSSQL编译为“CURRENT_TIMESTAMP”; “now()”在所有其他上。

    参考文献:#943

  • [sql] The startswith(), endswith(), and contains() operators now concatenate the wildcard operator with the given operand in SQL, i.e. “’%’ || ” in all cases, accept text(‘something’) operands properly

    参考文献:#962

  • [sql] cast()正确接受文本('something')和其他非文字操作数

    参考文献:#962

  • [sql] 修复了结果代理中的bug,其中匿名生成的列标签无法使用其直接字符串名称访问

  • [sql] 现在可以定义可延迟的约束。

  • [sql] Added “autocommit=True” keyword argument to select() and text(), as well as generative autocommit() method on select(); for statements which modify the database through some user-defined means other than the usual INSERT/UPDATE/ DELETE etc. 如果没有事务正在进行,该标志将在执行期间启用“自动提交”行为。

    参考文献:#915

  • [sql] 现在selectable上的'.c。'属性在其columns子句中为每个列表达式获取一个条目。以前,像函数和CASE语句这样的“未命名”列没有放在那里。现在,如果没有“名称”可用,他们将使用完整的字符串表示形式。

  • [sql] a CompositeSelect, i.e. any union(), union_all(), intersect(), etc. 现在断言每个可选项包含相同数量的列。这符合相应的SQL要求。

  • [sql] The anonymous ‘label’ generated for otherwise unlabeled functions and expressions now propagates outwards at compile time for expressions like select([select([func.foo()])]).

  • [sql] Building on the above ideas, CompositeSelects now build up their ”.c.” collection based on the names present in the first selectable only; corresponding_column() now works fully for all embedded selectables.

  • [sql] Oracle and others properly encode SQL used for defaults like sequences, etc., even if no unicode idents are used since identifier preparer may return a cached unicode identifier.

  • [sql] Column and clause comparisons to datetime objects on the left hand side of the expression now work (d < table.c.col). (RHS上的日期时间一直有效,LHS异常是日期时间实现的一个怪癖。)

杂项¶ T0>

  • [dialects] 更好地支持SQLite中的模式(通过ATTACH DATABASE ... AS名称链接)。在过去的某些情况下,为SQLite生成的SQL中省略了模式名称。这不再是这种情况。

  • [dialects] SQLite上的table_names现在也会选取临时表。

  • [dialects] 在反射操作期间自动检测未指定的MySQL ANSI_QUOTES模式,支持在中途更改模式。如果不使用反射,仍然需要手动模式设置。

  • [dialects] 修正了SQLite的TIME列的反映。

  • [dialects] 最后将PGMacAddr类型添加到postgres

    参考文献:#580

  • [dialects] 在Firebird 下反映与PK字段关联的序列(通常使用BEFORE INSERT触发器)

  • [dialects] Oracle assembles the correct columns in the result set column mapping when generating a LIMIT/OFFSET subquery, allows columns to map properly to result sets even if long-name truncation kicks in

    参考文献:#941

  • [dialects] MSSQL现在在_is_select regexp中包含EXEC,它应该允许使用行返回存储过程。

  • [dialects] MSSQL现在使用ANSI SQL row_number()函数包含LIMIT / OFFSET的实验性实现,因此它需要MSSQL-2005或更高版本。要启用该功能,请将“has_window_funcs”添加到连接的关键字参数中,或将“?has_window_funcs = 1”添加到您的dburi查询参数中。

  • [ext] 更改了ext.activemapper以使用对象库的非事务性会话。

  • [ext] 在关联代理列表中修复了“['a'] + obj.proxied”二元运算的输出顺序。

0.4.2p3 ¶ T0>

发布于:2008年1月09日

一般¶ T0>

  • [general] 子版本编号方案更改为套件setuptools版本号规则; easy_install -u现在应该获得0.4.2以上的版本。

ORM ¶ T0>

  • [orm] 在使用“可变标量”(如PickleTypes)时修复了session.dirty的错误

  • [orm] added a more descriptive error message when flushing on a relation() that has non-locally-mapped columns in its primary or secondary join condition

  • 在InstanceState .__ cleanup()现在,[orm] 现在抑制所有错误。

  • [orm] 修复了一个属性历史记录错误,因此将新集合分配给已具有未决更改的基于集合的属性会生成不正确的历史记录

    参考文献:#922

  • [orm] fixed delete-orphan cascade bug whereby setting the same object twice to a scalar attribute could log it as an orphan

    参考文献:#925

  • [orm] 固定级联在+ =赋值给基于列表的关系上

  • [orm] synonyms can now be created against props that don’t exist yet, which are later added via add_property(). 这通常包括backrefs。(即,您可以为backrefs制作同义词而不用担心操作顺序)

    参考文献:#919

  • [orm] 修复了多态“联合”映射器可能发生的错误,该映射器可以回退到“延迟”加载继承表

  • [orm] the “columns” collection on a mapper/mapped class (i.e. ‘c’) is against the mapped table, not the select_table in the case of polymorphic “union” loading (this shouldn’t be noticeable).

  • [orm] 修复了相当严重的错误,因此可以在unitofwork.new集合中多次列出相同的实例;在使用继承映射器和ScopedSession.mapper的组合时最为典型,因为每个实例的多个__init__调用可以使用不同的_state对象保存()该对象

  • [orm] 为Query添加了非常基本的产生迭代器行为。调用query.yield_per()并在迭代上下文中评估查询; N行的每个集合都将被打包并生成。 T0>使用此方法时要格外小心,因为它不会尝试在结果批处理边界上协调加载的集合,如果同一个实例出现在多个批处理中,它的行为也不会很好。这意味着如果一个批量加载的集合在多个批次中被引用,那么它将被清除,并且在所有情况下,属性将被覆盖在多个批次中发生的实例上。

  • [orm] 修正集合集合和关联代理集合的set in-set集合变异操作符。

    参考文献:#920

SQL ¶ T0>

  • [sql] 现在正确导出文本类型,并且不会在DDL创建时发出警告;没有长度的字符串类型只会在CREATE TABLE 期间引发警告

    参考文献:#912

  • [sql] 添加新的UnicodeText类型,以指定编码的,不变的文本类型

  • [sql] fixed bug in union() so that select() statements which don’t derive from FromClause objects can be unioned

  • [sql] 由于其“通用”类型,所以将TEXT的名称更改为文本; TEXT名称不推荐使用,直到0.5。没有长度时,字符串到文本的“升级”行为也被弃用,直到0.5;将在用于CREATE TABLE语句时发出警告(对于SQL表达式,没有长度的字符串仍然正常)

    参考文献:#912

  • [sql] generative select.order_by(None) / group_by(None) was not managing to reset order by/group by criterion, fixed

    参考文献:#924

杂项¶ T0>

  • [dialects] 固定反映mysql空字符串列的默认值。

  • [ext] '+','*','+ ='和'* ='支持关联代理列表。

  • [dialects] mssql - narrowed down the test for “date”/”datetime” in MSDate/ MSDateTime subclasses so that incoming “datetime” objects don’t get mis-interpreted as “date” objects and vice versa.

    参考文献:#923

  • [dialects] 修正了对PGArray类型的子类型结果处理器缺少的调用。

    参考文献:#913

0.4.2 ¶ T0>

发布于:2008年1月2日

ORM ¶ T0>

  • [orm] 对基于收集的backrefs的主要行为改变:它们不再触发延迟加载!“反向”添加和删除将排队并在实际读取和加载时与集合合并;但不要事先触发负载。对于已经注意到这种行为的用户,这应该比在某些情况下使用动态关系更方便;对于那些没有的人来说,在某些情况下,你可能会注意到你的应用比以前少了很多查询。

    参考文献:#871

  • [orm] 可变主键支持。主键列可以自由更改,并且实例的身份将在刷新时更改。另外,支持与关系的外键引用(主键或不键)更新级联,或者与数据库的ON UPDATE CASCADE(对于像Postgres这样的DB所需的)或由UPDATE语句形式的ORM直接发布的设置标志“passive_cascades = False”。

  • [orm] inheriting mappers now inherit the MapperExtensions of their parent mapper directly, so that all methods for a particular MapperExtension are called for subclasses as well. 与往常一样,任何MapperExtension都可以返回EXT_CONTINUE以继续扩展处理,或者返回EXT_STOP以停止处理。The order of mapper resolution is: .

    请注意,如果您分别实例化相同的扩展类,然后将其单独应用于同一继承链中的两个映射器,则该扩展将应用两次到继承类,并且每个方法将被调用两次。

    要将映射器扩展显式应用于每个继承类,但每个操作只调用一次每个方法,请为两个映射器使用扩展的相同实例。

    参考文献:#490

  • [orm] MapperExtension.before_update() and after_update() are now called symmetrically; previously, an instance that had no modified column attributes (but had a relation() modification) could be called with before_update() but not after_update()

    参考文献:#907

  • [orm] 在Query的select语句中丢失的列现在在加载期间自动延迟。

  • [orm] mapped classes which extend “object” and do not provide an __init__() method will now raise TypeError if non-empty *args or **kwargs are present at instance construction time (and are not consumed by any extensions such as the scoped_session mapper), consistent with the behavior of normal Python classes

    参考文献:#908

  • [orm] 修正了filter_by()与None无关的查询错误

    参考文献:#899

  • [orm] improved support for pickling of mapped entities. 每个实例的lazy / deferred / expired可调参数现在都是可序列化的,以便它们使用_state进行序列化和反序列化。

  • [orm] new synonym() behavior: an attribute will be placed on the mapped class, if one does not exist already, in all cases. 如果某个属性已经存在于该类中,则同义词将使用适当的比较运算符修饰该属性,以便与列表表达式中的任何其他映射属性一样使用该属性(即可用于filter()等)“代理=真”标志被弃用,不再意味着任何东西。此外,标志“map_column = True”将自动生成与同义词名称对应的ColumnProperty,即:'somename':synonym('_ somename',map_column = True)将名为'somename'的列映射到属性' _somename”。请参阅映射器文档中的示例。

    参考文献:#801

  • [orm] Query.select_from()现在用给定的参数替换所有现有的FROM标准;之前构造FROM子句列表的行为通常不是有用的,因为需要filter()调用来创建连接标准,并且filter()中引入的新表已将自己添加到FROM子句中。新行为不仅允许从主表连接,还允许选择语句。过滤标准,顺序bys,预先加载子句将被“别名”为给定语句。

  • [orm] this month’s refactoring of attribute instrumentation changes the “copy-on-load” behavior we’ve had since midway through 0.3 with “copy-on-modify” in most cases. 这需要大量的延迟加载操作,总体上工作量更少,因为只有实际修改的属性才能复制其“已提交状态”。只有“可变标量”属性(即腌渍对象或其他可变项目)(首先是加载拷贝改变的原因)才保留旧行为。

  • [orm] [attrname] 属性的轻微行为改变是,除了not属性外,会导致该属性的lazyloader再次触发; “del”使属性“无”的有效值。要重新触发属性的“加载器”,请使用session.expire(instance,)。

  • [orm] query.filter(SomeClass.somechild == None), when comparing a many-to-one property to None, properly generates “id IS NULL” including that the NULL is on the right side.

  • [orm] query.order_by() takes into account aliased joins, i.e. query.join(‘orders’, aliased=True).order_by(Order.id)

  • [orm] eagerload(), lazyload(), eagerload_all() take an optional second class-or-mapper argument, which will select the mapper to apply the option towards. 这可以选择使用add_entity()添加的其他映射器。

  • [orm] eagerloading可以通过add_entity()添加映射器。

  • [orm] 将“级联删除”行为添加到“动态”关系中,就像正常关系一样。如果passive_deletes标志(也就是刚刚添加的)没有设置,则父项的删除将触发子项的全部加载,以便可以相应地删除或更新它们。

  • [orm] 还包含动态的,实现的正确的count()行为以及其他辅助方法。

  • [orm] 修复了多态关系中的级联,使得从一个对象到多态集合的级联沿着集合中每个元素所特有的属性集继续级联。

  • [orm] query.get() and query.load() do not take existing filter or other criterion into account; these methods always look up the given id in the database or return the current instance from the identity map, disregarding any existing filter, join, group_by or other criterion which has been configured.

    参考文献:#893

  • [orm] 与继承映射器一起增加了对version_id_col的支持。version_id_col通常在继承关系中设置在基本映射器上,对所有继承映射器都有效。

    参考文献:#883

  • [orm] 放宽了具有标签的column_property()表达式的规则;现在接受任何ColumnElement,因为编译器现在会自动标记未标记的ColumnElement。像select()语句那样,selectable仍然需要通过as_scalar()或label()来转换为ColumnElement。

  • [orm] 固定的backref bug如果attr是None,那么你不能删除instance.attr

  • [orm] several ORM attributes have been removed or made private: mapper.get_attr_by_column(), mapper.set_attr_by_column(), mapper.pks_by_table, mapper.cascade_callable(), MapperProperty.cascade_callable(), mapper.canload(), mapper.save_obj(), mapper.delete_obj(), mapper._mapper_registry, attributes.AttributeManager

  • [orm] 为关系属性分配不兼容的集合类型现在引发TypeError而不是sqlalchemy的ArgumentError

  • [orm] 如果传入字典中的密钥与集合的keyfunc将用于该值的密钥不匹配,则MappedCollection的批量分配现在会引发错误。

    参考文献:#886

  • [orm] [newval2] [newval1] Custom collections can now specify a @converter method to translate objects used in “bulk” assignment into a stream of values, as in:

    obj.col =
    # or
    obj.dictcol = {'foo': newval1, 'bar': newval2}

    MappedCollection使用这个钩子来确保从集合的角度来看传入的键/值对是合理的。

  • [orm] 在双向关系的两侧使用lazy =“dynamic”时修复了无限循环问题

    参考文献:#872

  • [orm] 更多修正了应用Query + eagerloads的LIMIT / OFFSET别名,在这种情况下,映射到select语句

    参考文献:#904

  • [orm] 修复了自引用预加载,以便如果同一个映射实例出现在同一个结果集中的两个或多个不同的列集中,则无论是并非所有行都包含该集合的一组“热切”列。当在join_depth打开的情况下获取结果时,这也会显示为KeyError。

  • [orm] 固定的错误,其中当LIMIT与继承映射器一起使用时,Query不会将子查询应用于SQL,其中只有在父映射器中才有加载器。¶ t2 >

  • [orm] 澄清了当您尝试更新()具有与会话中已存在的实例相同的身份关键字的实例时发生的错误消息。

  • [orm] 一些澄清和修复合并(实例,dont_load = True)。修复了懒惰加载程序在返回的实例上被禁用的问题。此外,我们目前不支持合并其中未提交更改的实例,在使用dont_load = True的情况下....现在会引发错误。这是由于合并给定实例的“已提交状态”以正确对应于新复制的实例以及其他已修改状态的复杂性。由于dont_load = True的用例是缓存,因此给定的实例无论如何不应有任何未提交的更改。我们也复制实例而不使用任何事件,这样新会话上的'dirty'列表就不受影响。

  • [orm] fixed bug which could arise when using session.begin_nested() in conjunction with more than one level deep of enclosing session.begin() statements

  • [orm] 修正session.refresh()与实例具有自定义entity_name

    参考文献:#914

SQL ¶ T0>

  • [sql] 通用功能!我们引入一个已知SQL函数的数据库,例如current_timestamp,coalesce,并创建表示它们的显式函数对象。这些对象具有受约束的参数列表,可识别类型,并且可以按照特定于方言的方式进行编译。所以说func.char_length(“foo”,“bar”)会产生一个错误(太多的参数),func.coalesce(datetime.date(2007,10,5),datetime.date(2005,10,15))知道它的返回类型是Date。我们目前只有几个函数,但会继续添加到系统

    参考文献:#615

  • [sql] auto-reconnect support improved; a Connection can now automatically reconnect after its underlying connection is invalidated, without needing to connect() again from the engine. 这允许绑定到单个连接的ORM会话不需要重新连接。在连接失效后,必须回滚连接上的打开事务,否则会引发错误。还修复了断开连接检测未被调用cursor(),rollback()或commit()的错误。

  • [sql] 为String和create_engine()添加了新的标志,assert_unicode =(True | False |'warn'| None)。对于Unicode类型的create_engine()和String,'warn',默认为FalseTrue时,导致所有unicode转换操作在将非Unicode字节串作为绑定参数传递时引发异常。'警告'会导致警告。强烈建议所有支持unicode的应用程序正确使用Python unicode对象(即u'hello'而不是'hello'),以便数据准确地返回。

  • [sql] generation of “unique” bind parameters has been simplified to use the same “unique identifier” mechanisms as everything else. 这不会影响用户代码,除非可能已针对生成的名称进行了硬编码的任何代码。生成的绑定参数现在具有“_ ”的形式,而之前只有同名的第二个绑定才具有此形式。

  • [sql] select().as_scalar() will raise an exception if the select does not have exactly one expression in its columns clause.

  • [sql] bindparam() objects themselves can be used as keys for execute(), i.e. statement.execute({bind1:’foo’, bind2:’bar’})

  • [sql] 向TypeDecorator,process_bind_param()和process_result_value()添加了新的方法,该方法自动利用底层类型的处理。非常适合使用Unicode或Pickletype。TypeDecorator现在应该成为增强任何现有类型(包括其他TypeDecorator子类,如PickleType)的行为的主要方式。

  • [sql] selectables(及其他)在其导出列集合中的两列根据名称冲突时将发出警告。

  • [sql] 表格仍然可以在sqlite中使用,firebird,模式名称只是被丢弃

    参考文献:#890

  • [sql] changed the various “literal” generation functions to use an anonymous bind parameter. 没有太多的变化,除了他们的标签现在看起来像“:param_1”,“:param_2”而不是“:literal”

  • [sql] 列标签的格式为“tablename.columname”,即现在支持。

  • [sql] select()的from_obj关键字参数可以是标量或列表。

火鸟¶ T0>

  • [firebird] [backend] 确实反映了域名(部分修复)和PassiveDefaults

    参考文献:#410

  • [firebird] [3562] [backend] 恢复为使用默认poolclass(为了测试目的,在0.4.0中设置为SingletonThreadPool)

  • [firebird] [backend] 将func.length()映射到'char_length'(在Firebird的旧版本中,可轻松覆盖UDF'strlen')

杂项¶ T0>

  • [dialects] sqlite SLDate类型不会错误地呈现日期时间或时间对象的“微秒”部分。

  • [dialects]

    神谕
    • 为Oracle增加了断开连接检测支持
    • 一些清理到二进制/原始类型,以便临时检测到cx_oracle.LOB

    参考文献:#902

  • [dialects]

    MSSQL
    • PyODBC不再拥有一个全球性的“设定数量”。
    • 修复autload上的非身份整数PK
    • 更好地支持convert_unicode
    • pyodbc / adodbapi的日期转换不太严格
    • 符合模式的表格/自动加载

    References: #824, #839, #842, #901

0.4.1 ¶ T0>

发布于:2007年11月18日

ORM ¶ T0>

  • [orm] eager loading with LIMIT/OFFSET applied no longer adds the primary table joined to a limited subquery of itself; the eager loads now join directly to the subquery which also provides the primary table’s columns to the result set. 这消除了使用LIMIT / OFFSET从所有急切加载的JOIN。

    参考文献:#843

  • [orm] session.refresh() and session.expire() now support an additional argument “attribute_names”, a list of individual attribute keynames to be refreshed or expired, allowing partial reloads of attributes on an already-loaded instance.

    参考文献:#802

  • [orm] 将op()运算符添加到了检测属性;即User.name.op('ilike')('%somename%')

    参考文献:#767

  • [orm] 映​​射类现在可以定义具有任意语义的__eq__,__hash__和__nonzero__方法。orm现在处理仅基于身份的所有映射实例。(例如'is'vs'==')

    参考文献:#676

  • [orm] Mapper上的“属性”访问器被删除;它现在会抛出一个信息异常,解释mapper.get_property()和mapper.iterate_properties

  • [orm] 将having()方法添加到Query中,以与filter()附加到WHERE子句相同的方式将HAVING应用于生成的语句。

  • [orm] The behavior of query.options() is now fully based on paths, i.e. an option such as eagerload_all(‘x.y.z.y.x’) will apply eagerloading to only those paths, i.e. and not ‘x.y.x’; eagerload(‘children.children’) applies only to exactly two-levels deep, etc.

    参考文献:#777

  • [orm] PickleType will compare using == when set up with mutable=False, and not the is operator. 要使用或任何其他比较器,请使用PickleType(comparator = my_custom_comparator)发送自定义比较函数。

  • [orm] query doesn’t throw an error if you use distinct() and an order_by() containing UnaryExpressions (or other) together

    参考文献:#848

  • [orm] order_by() expressions from joined tables are properly added to columns clause when using distinct()

    参考文献:#786

  • [orm] 固定错误,其中Query.add_column()不接受类绑定属性作为参数;如果将一个无效参数发送到add_column()(在instances()时间),则查询也会引发错误

    参考文献:#858

  • [orm] added a little more checking for garbage-collection dereferences in InstanceState.__cleanup() to reduce “gc ignored” errors on app shutdown

  • [orm] 会话API已经固化:

  • [orm] session.save()是已经存在的对象的错误

    参考文献:#840

  • [orm] session.delete()是不是持久对象的错误。

  • [orm] session.update() and session.delete() raise an error when updating or deleting an instance that is already in the session with a different identity.

  • [orm] The session checks more carefully when determining “object X already in another session”; e.g. if you pickle a series of objects and unpickle (i.e. as in a Pylons HTTP session or similar), they can go into a new session without any conflict

  • [orm] merge()包含关键字参数“dont_load = True”。设置此标志将导致合并操作不会响应传入的分离对象加载数据库中的任何数据,并且会接受传入的分离对象,就好像它已经存在于该会话中一样。使用它可以将来自外部缓存系统的分离对象合并到会话中。

  • [orm] 当属性分配给时,延迟列属性不再触发加载操作。在这些情况下,新分配的值将无条件存在于刷新的UPDATE语句中。

  • [orm] 修复了重新分配集合子集时的截断错误(obj.relation = obj.relation [1:])

    参考文献:#834

  • [orm] 未定义的backref配置代码,在现有属性上引入的backrefs现在会引发错误

    参考文献:#832

  • [orm] 改进了add_property()等行为,固定涉及同义词/ deferred。

    参考文献:#831

  • [orm] 修正了clear_mappers()行为,以便更好地清理它自己。

  • [orm] Fix to “row switch” behavior, i.e. when an INSERT/DELETE is combined into a single UPDATE; many-to-many relations on the parent object update properly.

    参考文献:#841

  • [orm] 修正了关联代理的__hash__,这些集合是不可更改的,就像它们的可变Python对象一样。

  • [orm] 为范围会话添加了save_or_update,__contains__和__iter__方法的代理。

  • [orm] 固定了非常难以复制的问题,其中Query的FROM子句可能会受到某些生成调用的污染

    参考文献:#852

SQL ¶ T0>

  • [sql] bindparam()上的“shortname”关键字参数已被弃用。

  • [sql] 添加了包含运算符(生成“LIKE%%”子句)。

  • [sql] anonymous column expressions are automatically labeled. 例如选择([x * 5])会产生“SELECT x * 5 AS anon_1”。这允许labelname出现在cursor.description中,然后可以适当地匹配结果列处理规则。(因为text()表达式可能代表多列),所以我们不能可靠地使用位置跟踪来处理结果列匹配。

  • [sql] operator overloading is now controlled by TypeEngine objects - the one built-in operator overload so far is String types overloading ‘+’ to be the string concatenation operator. 用户定义的类型也可以通过重写adapt_operator(self,op)方法来定义自己的运算符重载。

  • [sql] untyped bind parameters on the right side of a binary expression will be assigned the type of the left side of the operation, to better enable the appropriate bind parameter processing to take effect

    参考文献:#819

  • [sql] 从大多数语句编译中删除正则表达式步骤。还修复了

    参考文献:#833

  • [sql] Fixed empty (zero column) sqlite inserts, allowing inserts on autoincrementing single column tables.

  • [sql] 修正text()子句的表达式转换;这修复了各种ORM方案,其中文本文本用于SQL表达式

  • [sql] 删除了ClauseParameters对象; compiled.params现在返回一个常规字典,以及result.last_inserted_pa​​rams()/ last_updated_pa​​rams()。

  • [sql] 修正了INSERT语句w.r.t.主键列上具有基于SQL表达式的默认生成器; SQL表达式正常执行内联,但不会触发列的“后取”条件,对于那些通过cursor.lastrowid 提供的数据库

  • [sql] func。对象可以被腌制/取消剔除

    参考文献:#844

  • [sql] rewrote and simplified the system used to “target” columns across selectable expressions. 在SQL方面,这由“对应列()”方法表示。ORM很大程度上使用该方法来将表达式的元素“修改”为类似的别名表达式,以及将最初绑定到表的结果集列或可选择的别名“对应”表达式作为目标。新的重写功能具有完全一致和准确的行为。

  • [sql] 添加了一个字段(“info”),用于存储架构项目的任意数据

    参考文献:#573

  • [sql] Connections上的“properties”集合已重命名为“info”以匹配模式的可写集合。访问仍然可以通过“属性”名称直到0.5.

  • [sql] 使用strategy ='threadlocal'时修正了Transaction上的close()方法

  • [sql] 修复编译后的绑定参数,使其不会错误填充None

    参考文献:#853

  • [sql] ._execute_clauseelement becomes a public method Connectable.execute_clauseelement

杂项¶ T0>

  • [dialects] 增加了对MaxDB的实验性支持(版本> = 7.6.03.007)。

  • [dialects] oracle现在将“DATE”反映为OracleDateTime列,而不是OracleDate

  • [dialects] 增加了对oracle table_names()函数中模式名称的了解,修复了metadata.reflect(schema ='someschema')

    参考文献:#847

  • [dialects] 用于选择功能的MSSQL匿名标签使确定性

  • [dialects] sqlite会将“DECIMAL”反映为数字列。

  • [dialects] 使访问道检测更加可靠

    参考文献:#828

  • [dialects] 将方言属性'preexecute_sequences'重命名为'preexecute_pk_sequences'。一个属性porxy适用于使用旧名称的out-of-tree方言。

  • [dialects] 为未知类型的反射增加了测试覆盖率。修正了未知类型反射类型的sqlite / mysql处理。

  • [dialects] 增加了对于mysql方言的REAL(对于开发REAL_AS_FLOAT sql模式的人)。

  • [dialects] 现在,没有参数的mysql Float,MSFloat和MSDouble产生无参数DDL,例如'FLOAT'。

  • [misc] 删除未使用的util.hash()。

0.4.0 ¶ T0>

发布时间:2007年10月17日
  • (请参阅0.4.0beta1开始对0.3进行主要更改,以及http://www.sqlalchemy.org/trac/wiki/WhatsNewIn04¶ T2>

  • 增加了对Sybase的支持(目前为止,mxODBC)

    参考文献:#785

  • 为PostgreSQL增加了部分索引支持。在索引上使用postgres_where关键字。

  • 基于字符串的查询参数解析/配置文件解析器理解布尔值的更广泛的字符串值

    参考文献:#817

  • 如果另一侧的集合不包含该项目,则支持noload集合的backref移除对象操作不会失败

    参考文献:#813

  • 将__len__从“动态”集合中删除,因为它需要发出SQL“count()”操作,因此迫使所有列表评估发出冗余SQL

    参考文献:#818

  • inline optimizations added to locate_dirty() which can greatly speed up repeated calls to flush(), as occurs with autoflush=True

    参考文献:#816

  • IdentifierPreprarer的_requires_quotes测试现在是基于正则表达式的。任何提供legal_characters或illegal_initial_characters自定义集合的out-of-tree方言都需要移动到正则表达式或覆盖_requires_quotes。

  • Firebird has supports_sane_rowcount and supports_sane_multi_rowcount set to False due to ticket #370 (right way).

  • Firebird反射的改进和修复:
    • 现在,FBDialect模仿OracleDialect,关于TABLE和COLUMN名称的区分大小写(请参阅当前文件中的'case_sensitive remotion'主题)。
    • FBDialect.table_names()不带系统表(票证:796)。
    • FB现在正确反映了Column的可空属性。

  • Fixed SQL compiler’s awareness of top-level column labels as used in result-set processing; nested selects which contain the same column names don’t affect the result or conflict with result-column metadata.

  • query.get() and related functions (like many-to-one lazyloading) use compile-time-aliased bind parameter names, to prevent name conflicts with bind parameters that already exist in the mapped selectable.

  • 修正了三层和多层次的select和deferred继承加载(即没有select_table的abc继承)。

    参考文献:#795

  • 在shard.py中传递给id_chooser的标识永远是一个列表。

  • 无参数ResultProxy._row_processor()现在是类属性_process_row

  • 增加了对PostgreSQL 8.2 +插入和更新返回值的支持。

    参考文献:#797

  • PG reflection, upon seeing the default schema name being used explicitly as the “schema” argument in a Table, will assume that this is the user’s desired convention, and will explicitly set the “schema” argument in foreign-key-related reflected tables, thus making them match only with Table constructors that also use the explicit “schema” argument (even though its the default schema). 换句话说,SA假定用户在这种用法中是一致的。

  • fixed sqlite reflection of BOOL/BOOLEAN

    参考文献:#808

  • 增加了对MySQL的UPDATE和LIMIT的支持。

  • m2o上的null外键不会触发lazyload

    参考文献:#803

  • oracle does not implicitly convert to unicode for non-typed result sets (i.e. when no TypeEngine/String/Unicode type is even being used; previously it was detecting DBAPI types and converting regardless). 应该修正

    参考文献:#800

  • 修复长表/列名的匿名标签生成

    参考文献:#806

  • Firebird dialect now uses SingletonThreadPool as poolclass.

  • Firebird now uses dialect.preparer to format sequences names

  • 修复了postgres和多个两阶段事务的破坏情况。两阶段提交和回滚并不会像通常的dbapi提交/回滚那样自动以新事务结束。

    参考文献:#810

  • 为_ScopedExt映射器扩展添加了一个选项,不会在对象初始化时自动将新对象保存到会话中。

  • 修正了Oracle非ansi连接语法

  • PickleType and Interval types (on db not supporting it natively) are now slightly faster.

  • 为Firebird添加了浮点和时间类型(FBFloat和FBTime)。修正了用于TEXT和二进制类型的BLOB SUB_TYPE。

  • 更改了in_运算符的API。in_()现在接受一个参数,它是一个值序列或一个可选参数。传递值作为可变参数的旧API仍然有效,但不推荐使用。

0.4.0beta6 ¶ T0>

发布于:2007年9月27日
  • 默认情况下,会话标识映射现在弱引用,请使用weak_identity_map = False来使用常规字典。我们正在使用的弱字典是为了检测“脏”的实例而定制的,并且保持对这些实例的临时强引用,直到刷新变化为止。

  • Mapper compilation has been reorganized such that most compilation occurs upon mapper construction. 这使我们对mapper.compile()的调用更少,并允许基于类的属性强制编译(即User.addresses == 7将编译所有映射器;这是)。唯一需要注意的是,继承的映射器现在在构建时寻找它的继承映射器;因此继承关系中的映射器需要以继承顺序构建(无论如何,这应该是正常情况)。

    参考文献:#758

  • 将“FETCH”添加到Postgres检测到的关键字中,以指示结果行保留语句(即除了“SELECT”)。

  • 添加了SQLite保留关键字的完整列表,以便它们正确转义。

  • 强化了Query的“紧急加载”别名的生成和Query.instances()之间的关系,这些关键字实际上会抓取热切加载的行。如果别名不是由EagerLoader为该语句专门生成的,那么在获取行时EagerLoader不会生效。这样可以防止列被意外抓取,因为它们并非意味着这种情况,这可能会发生在文本SQL以及一些继承情况中。这一点尤其重要,因为列的“匿名别名”现在使用简单的整数计数来生成标签。

  • 从clauseelement.compile()中删除了“parameters”参数,替换为“column_keys”。发送到execute()的参数只与列名称存在的insert / update语句编译过程交互,但不与这些列的值相关。产生更一致的execute / executemany行为,在内部简化了一些事情。

  • 在PickleType中增加了'comparator'关键字参数。默认情况下,“可变”PickleType使用它们的dump()表示法对对象进行“深层比较”。但是这对字典不起作用。提供足够的__eq __()实现的Pickled对象可以使用“PickleType(comparator = operator.eq)”来设置。

    参考文献:#560

  • 新增session.is_modified(obj)方法;执行与在刷新操作中发生的相同的“历史”比较操作;设置include_collections = False的结果与flush时确定是否为实例行发出UPDATE时所使用的结果相同。

  • 将序列添加了“模式”参数;当序列位于备用模式中时,将其与Postgres / Oracle一起使用。实施的一部分,应该修复。

    参考文献:#584#761

  • 固定反映mysql枚举的空字符串。

  • 改变了MySQL方言使用旧的LIMIT 语法,而不是LIMIT OFFSET ,用于使用3.23的人。 T3> T2> T1>

    参考文献:#794

  • Added ‘passive_deletes=”all”’ flag to relation(), disables all nulling-out of foreign key attributes during a flush where the parent object is deleted.

  • 内联执行的列缺省值和onupdates将为子查询和其他括号需求表达式添加括号

  • The behavior of String/Unicode types regarding that they auto-convert to TEXT/CLOB when no length is present now occurs only for an exact type of String or Unicode with no arguments. 如果使用VARCHAR或NCHAR(String / Unicode的子类)而没有长度,则它们将被方言解释为VARCHAR / NCHAR;没有“魔术”转换发生在那里。这并不令人惊讶,特别是这有助于Oracle将基于字符串的绑定参数保存为VARCHAR,而不是CLOB。

    参考文献:#793

  • 修复ShardedSession与延迟列一起工作

    参考文献:#771

  • User-defined shard_chooser() function must accept “clause=None” argument; this is the ClauseElement passed to session.execute(statement) and can be used to determine correct shard id (since execute() doesn’t take an instance.)

  • Adjusted operator precedence of NOT to match ‘==’ and others, so that ~(x y) produces NOT (x y), which is better compatible with older MySQL versions.. 这不适用于像〜0.3那样的“〜(x == y)”,因为〜(x == y)编译为“x!= y”,但仍然适用于像BETWEEN这样的运算符。¶< / T0>

    参考文献:#764

  • 其他门票:,null,。

    References: #757, #768, #779, #728

0.4.0beta5 ¶ T0>

没有发布日期
  • 连接池修复; beta4的性能更好,但修复了“连接溢出”和其他存在的bug(如)。

    参考文献:#754

  • 修正了从自定义继承条件中确定合适的同步子句的错误。

    参考文献:#769

  • 针对QueuePool大小/溢出扩展'engine_from_config'强制

    参考文献:#763

  • mysql视图可以再次被反映出来。

    参考文献:#748

  • AssociationProxy现在可以使用自定义的getter和setter。

  • Fixed malfunctioning BETWEEN in orm queries.

  • 固定OrderedProperties酸洗

    参考文献:#762

  • SQL-expression defaults and sequences now execute “inline” for all non-primary key columns during an INSERT or UPDATE, and for all columns during an executemany()-style call. inline =任何插入/更新语句上的True标志也会强制执行单个execute()的相同行为。result.postfetch_cols()是以前的单个插入或更新语句包含SQL端默认表达式的列的集合。

  • 修正了PG的executemany()行为。

    参考文献:#759

  • 对于没有默认值的主键列,postgres反映表的autoincrement = False。

  • postgres no longer wraps executemany() with individual execute() calls, instead favoring performance. 由于psycopg2不报告executemany()的正确行数,因此使用PG禁用“使用executemany”的已删除项目的“rowcount”/“concurrency”。

  • [tickets] [fixed]

    参考文献:#742

  • [tickets] [fixed]

    参考文献:#748

  • [tickets] [fixed]

    参考文献:#760

  • [tickets] [fixed]

    参考文献:#762

  • [tickets] [fixed]

    参考文献:#763

0.4.0beta4 ¶ T0>

发布时间:2007年8月22日星期三
  • 当你从'sqlalchemy import *'中清理完名字空间时:

  • '表'和'列'不再导入。它们通过直接引用(如'sql.table'和'sql.column')或sql包中的glob导入保持可用。当刚开始使用SQLAlchemy时,意外地使用sql.expressions.table代替schema.Table太容易了,同样也是列。

  • Internal-ish classes like ClauseElement, FromClause, NullTypeEngine, etc., are also no longer imported into your namespace

  • The ‘Smallinteger’ compatibility name (small i!) 不再导入,但现在仍保留在schema.py中。SmallInteger(大我!)仍然是导入的。

  • The connection pool uses a “threadlocal” strategy internally to return the same connection already bound to a thread, for “contextual” connections; these are the connections used when you do a “connectionless” execution like insert().execute(). 这就像“threadlocal”引擎策略的“部分”版本,但没有线程本地事务部分。我们希望它可以减少连接池开销以及数据库使用量。但是,如果它证明以负面方式影响稳定性,我们会马上回滚。

  • 修复绑定参数处理,使得“假”值(如空白字符串)仍然得到处理/编码。

  • Fix to select() “generative” behavior, such that calling column(), select_from(), correlate(), and with_prefix() does not modify the original select object

    参考文献:#752

  • Added a “legacy” adapter to types, such that user-defined TypeEngine and TypeDecorator classes which define convert_bind_param() and/or convert_result_value() will continue to function. 还支持调用这些方法的super()版本。

  • 添加了session.prune(),修剪了会话中缓存的实例,这些实例不再在别处引用。(用于强引用身份映射的实用程序)。

  • 为Transaction添加了close()方法。如果是最外层的事务,则使用回滚关闭事务,否则只会在不影响外层事务的情况下结束。

  • 事务性和非事务性会话与绑定连接更好地集成; close()将确保连接事务状态与绑定到Session之前的连接事务状态相同。

  • 已修改的SQL运算符函数为模块级运算符,允许SQL表达式为pickleable。

    参考文献:#735

  • 对mapper类的小调整.__ init__允许Py2.6对象.__ init __()行为。

  • 修正了select()的'prefix'参数

  • Connection.begin()不再接受nested = True,这个逻辑现在全部在begin_nested()中。

  • 修复了涉及级联的新“动态”关系加载器

  • [tickets] [fixed]

    参考文献:#735

  • [tickets] [fixed]

    参考文献:#752

0.4.0beta3 ¶ T0>

发布日期:2007年8月16日
  • SQL类型优化:

  • 新的性能测试显示,结合质量插入/质量选择测试的功能调用少于相同测试运行的0.3%。

  • 结果集迭代的一般性能提升约为10-20%。

  • In types.AbstractType, convert_bind_param() and convert_result_value() have migrated to callable-returning bind_processor() and result_processor() methods. 如果不返回可调用对象,则不会调用前/后处理函数。

  • Hooks added throughout base/sql/defaults to optimize the calling of bind aram/result processors so that method call overhead is minimized.

  • 为executemany()方案添加了支持,以便不需要的“最后一行id”逻辑无法启动,参数不会被过度遍历。

  • 将'inherit_foreign_keys'arg添加到mapper()。

  • 在sqlite中增加了对字符串日期传递的支持。

  • [tickets] [fixed]

    参考文献:#738

  • [tickets] [fixed]

    参考文献:#739

  • [tickets] [fixed]

    参考文献:#743

  • [tickets] [fixed]

    References: #744

0.4.0beta2 ¶ T0>

发布时间:2007年8月14日

预言¶ T0>

  • [oracle] [improvements.] 在LOAD DATA INFILE之后自动提交给mysql。

  • [oracle] [improvements.] 已经添加了一个基本的SessionExtension类,允许用户定义的功能在flush(),commit()和rollback()边界发生。

  • [oracle] [improvements.] 添加了engine_from_config()函数,以帮助从.ini样式配置文件中创建create_engine()。

  • [oracle] [improvements.] base_mapper()变成一个纯属性。

  • [oracle] [improvements.] session.execute()和scalar()可以使用给定的ClauseElement来搜索要绑定的表。

  • [oracle] [improvements.] 会话使用绑定自动从映射器推断表,还使用base_mapper,以便继承层次结构自动绑定。

  • [oracle] [improvements.] 将ClauseVisitor遍历移回内联非递归。

杂项¶ T0>

  • [tickets] [fixed]

    参考文献:#730

  • [tickets] [fixed]

    参考文献:#732

  • [tickets] [fixed]

    参考文献:#733

  • [tickets] [fixed]

    参考文献:#734

0.4.0beta1 ¶ T0>

发布日期:2007年8月12日

ORM ¶ T0>

  • [orm] 速度!随着最近对ResultProxy的加速,大负载的函数调用总数大大减少。

  • [orm] test/perf/masseagerload.py reports 0.4 as having the fewest number of function calls across all SA versions (0.1, 0.2, and 0.3).

  • [orm] 新的collection_class api和实现。集合现在通过装饰而不是代理进行装饰。您现在可以拥有管理其自己成员资格的集合,并且您的类实例将直接显示在关系属性中。对于大多数用户来说,这些更改是透明的。

    参考文献:#213

  • [orm] InstrumentedList (as it was) is removed, and relation properties no longer have ‘clear()’, ‘.data’, or any other added methods beyond those provided by the collection type. 当然,您可以将它们添加到自定义类中。

  • [orm] __ setitem __-现在就像现在的赋值一样,为现有值激发删除事件(如果有的话)。

  • [orm] 用作集合类的dict-likes不再需要更改__iter__语义 - itervalues()默认使用。这是一个向后不兼容的变化。

  • [orm] 在大多数情况下,映射集合的子类化字典不再需要。orm.collections通过指定的列或您选择的自定义函数提供了关键对象的固定实现。

  • [orm] 集合赋值现在需要一个兼容类型 - 赋值None来清除一个集合或者将一个列表赋给一个dict集合现在会引发一个参数错误。

  • [orm] 将AttributeExtension移动到接口,并且.delete现在是.remove事件方法签名也已被交换。

  • [orm] 对Query进行大修:

  • [orm] 不推荐使用所有selectXXX方法。生成方法现在是执行任务的标准方法,即filter(),filter_by(),all(),one()等。不赞成使用的方法是用新替代文件串入。

  • [orm] 类级属性现在可用作查询元素...不再有'.c。'!“Class.c.propname”现在被“Class.propname”取代。支持所有子句运算符,以及更高级别的运算符,如用于标量属性的Class.prop == ,用于收集的Class.prop.contains()和Class.prop.any(基于属性(全部也是否定的)。 T2> T1> T0>基于表格的列表达式以及通过'c'在映射类上安装的列当然仍然完全可用,并且可以与新属性自由混合。

    参考文献:#643

  • [orm] 删除了古老的query.select_by_attributename()功能。

  • [orm] 通过加载加载使用的别名逻辑已被推广,因此它也为Query添加了全自动别名支持。It’s no longer necessary to create an explicit Alias to join to the same tables multiple times; even for self-referential relationships.

    • join()和outerjoin()接受参数“aliased = True”。Yhis使他们的连接建立在别名表上;随后对filter()和filter_by()的调用会将所有表表达式(是的,使用原始映射表的实际表达式)转换为连接()的持续时间(即直到reset_joinpoint()或另一个连接) 叫做)。
    • join()和outerjoin()接受参数“id = ”。 T0>当与“aliased = True”一起使用时,可以通过add_entity(cls,id = )引用该id,以便即使它们来自别名,也可以选择已加入的实例。
    • join()和outerjoin()现在可以与自引用关系一起工作!使用“aliased = True”,你可以根据需要加入尽可能多的层次,例如query.join(['children','children'],aliased = True);过滤标准将针对最右边的连接表

  • [orm] 添加了query.populate_existing(),将查询标记为重新加载查询中接触的所有实例的所有属性和集合,包括加载实体的实例。

    参考文献:#660

  • [orm] 新增eagerload_all(),允许eagerload_all('x.y.z')指定给定路径中所有属性的预加载。

  • [orm] 对Session进行大修:

  • [orm] “配置”一个名为“sessionmaker()”的会话的新函数。发送各种关键字参数给这个函数一次,返回一个新的类,它根据这个原型创建一个Session。

  • [orm] SessionTransaction removed from “public” API. 您现在可以在Session本身上调用begin()/ commit()/ rollback()。

  • [orm] 会话也支持SAVEPOINT事务;调用begin_nested()。

  • [orm] Session supports two-phase commit behavior when vertically or horizontally partitioning (i.e., using more than one engine). 使用twophase = True。

  • [orm] Session flag “transactional=True” produces a session which always places itself into a transaction when first used. 在commit(),rollback()或close()时,事务结束;但是从下一次使用开始。

  • [orm] 会话支持“autoflush = True”。这会在每个查询之前发出flush()。与事务相结合使用,你可以保存()/ update()然后查询,新的对象将在那里。在末尾使用commit()(如果是非事务性的,则使用flush())来清除剩余的变化。

  • [orm] 新的scoped_session()函数取代了SessionContext和assignmapper。构建到“sessionmaker()”概念上,以产生一个Session()构造返回线程本地会话的类。或者,将所有Session方法作为类方法调用,即Session.save(foo); Session.commit()。就像旧的“objectstore”日子一样。

  • [orm] 为Session添加了新的“绑定”参数,以支持使用sessionmaker()函数配置多个绑定。

  • [orm] 添加了一个基本的SessionExtension类,允许在flush(),commit()和rollback()边界上执行用户定义的功能。

  • [orm] dynamic_loader()可用的基于查询的关系()。这是一个可写集合(支持append()和remove()),它也是一个实时查询对象。理想的处理非常大的集合,只需要部分加载。

  • [orm] flush() - 嵌入式行内INSERT / UPDATE表达式。将任何SQL表达式(如“sometable.c.column + 1”)分配给实例的属性。在flush()之后,映射器检测表达式并将其直接嵌入INSERT或UPDATE语句中;该属性在实例中被延迟,以便在下次访问它时加载新值。

  • [orm] 引入了一个基本的分片(水平缩放)系统。该系统使用修改的会话,该会话可以根据定义“分片策略”的用户定义函数在多个数据库之间分配读写操作。可以根据属性值,循环方法或任何其他用户定义的系统在多个数据库中分发和查询实例及其依赖项。

    参考文献:#618

  • [orm] Eager装载已得到增强,可以在更多地方实现更多连接。它现在可以在任意深度上沿着自我指涉和周期性结构发挥作用。加载循环结构时,在relation()上指定“join_depth”,表示您希望表加入自己的次数;每个级别都有一个不同的表别名。别名名称本身是在编译时使用简单的计数方案生成的,并且在眼睛上更容易,当然也是完全确定性的。

    参考文献:#659

  • [orm] 添加了复合列属性。这允许您在使用ORM时创建一个由多个列表示的类型。新类型的对象在查询表达式,比较,query.get()子句等中是完全可用的。并且就好像他们是常规的单列标量......除非他们不是!在映射器的“属性”字典中使用函数composite(cls,* columns),并将cls的实例创建/映射到单个属性,由与*列对应的值组成。

    参考文献:#211

  • [orm] 改进了对具有相关子查询的自定义column_property()属性的支持,现在可以更好地加载现有的

  • [orm] Primary key “collapse” behavior; the mapper will analyze all columns in its given selectable for primary key “equivalence”, that is, columns which are equivalent via foreign key relationship or via an explicit inherit_condition. 主要用于连接表继承方案,其中继承表中的不同名为PK列的应该“折叠”为单值(或更少值)的主键。修复诸如。之类的内容

    参考文献:#611

  • [orm] 连接表继承现在将仅针对连接的根表生成所有继承类的主键列。这意味着根表中的每一行都不同于单个实例。如果由于某种罕见的原因,这是不可取的,那么在各个映射器上显式的primary_key设置将覆盖它。

  • [orm] When “polymorphic” flags are used with joined-table or single-table inheritance, all identity keys are generated against the root class of the inheritance hierarchy; this allows query.get() to work polymorphically using the same caching semantics as a non-polymorphic get. 请注意,这目前不适用于具体的继承。

  • [orm] 辅助继承加载:多态映射器可以在没有 select_table参数的情况下构造继承其初始加载中不表示的映射器将立即发出第二个SQL查询,每个实例一次(即对于大型列表不是很有效),以加载剩余列。

  • [orm] Secondary inheritance loading can also move its second query into a column-level “deferred” load, via the “polymorphic_fetch” argument, which can be set to ‘select’ or ‘deferred’

  • [orm] 现在可以使用include_columns / exclude_columns仅将可用的可选列的子集映射到映射器属性上。

    参考文献:#696

  • [orm] 添加了undefer_group()MapperOption,设置一组由“group”加入的“deferred”列作为“undeferred”加载。

  • [orm] Rewrite of the “deterministic alias name” logic to be part of the SQL layer, produces much simpler alias and label names more in the style of Hibernate

SQL ¶ T0>

  • [sql] 速度!子句编译以及SQL结构的机制已经被精简和简化到了显着的程度,对0.3的语句构建/编译开销提高了20-30%。

  • [sql] 所有“type”关键字参数,如bindparam(),column(),Column()和func的关键字参数(),重命名为“type_”。 T2>这些对象仍将其“type”属性命名为“type”。

  • [sql] case_sensitive=(True|False) setting removed from schema items, since checking this state added a lot of method call overhead and there was no decent reason to ever set it to False. 表和列名都是小写,将被视为不区分大小写(是的,我们也调整了Oracle的大写样式)。

MySQL的¶ T0>

  • [mysql] 通过反射加载的表名和列名现在是Unicode。

  • [mysql] 现在支持所有标准列类型,包括SET。

  • [mysql] 现在可以在一次往返中执行表反射。

  • [mysql] 现在支持ANSI和ANSI_QUOTES sql模式。

  • [mysql] 索引现在反映出来。

预言¶ T0>

  • [oracle] 添加了对OUT参数的非常基本的支持;使用sql.outparam(name,type)来设置一个OUT参数,就像bindparam();执行后,值可通过result.out_parameters字典获得。

    参考文献:#507

杂项¶ T0>

  • [transactions] 添加了对事务的上下文管理器(带语句)支持。

  • [transactions] 添加了对两阶段提交的支持,到目前为止可以使用mysql和postgres。

  • [transactions] 增加了一个使用保存点的子事务实现。

  • [transactions] 增加了对保存点的支持。

  • [metadata] 可以从数据库en-masse中反映表,而无需事先声明它们。MetaData(engine,reflect = True)会加载数据库中的所有表,或者使用metadata.reflect()进行更好的控制。

  • [metadata] DynamicMetaData已重命名为ThreadLocalMetaData

  • [metadata] ThreadLocalMetaData构造函数现在不带参数。

  • [metadata] BoundMetaData已被删除 - 常规MetaData等同于

  • [metadata] 数字和浮点类型现在有一个“asdecimal”标志;对于数字,默认为True,对于Float,默认为False。当为True时,值以十进制形式返回。当False时,值返回为float()。True / False的缺省值已经是PG和MySQL的DBAPI模块的行为。

    参考文献:#646

  • [metadata] 新的SQL运算符实现,它从表达式结构中移除所有硬编码的运算符并将它们转移到编译中;允许操作员编译更大的灵活性;例如,“+”在字符串上下文中使用时编译为“||”,或者在MySQL上使用“concat(a,b)”;而在数字上下文中则编译为“+”。修复。¶ T0>

    参考文献:#475

  • [metadata] “匿名”别名和标签名称现在在SQL编译时以完全确定性的方式生成...不再是随机的十六进制ID

  • [metadata] 对SQL元素(ClauseElement)的重要架构检修。所有元素都有一个共同的“可变性”框架,允许采用一致的方法对元素进行就地修改以及生成行为。提高ORM的稳定性,从而大量使用SQL表达式的突变。

  • [metadata] select() and union()’s now have “generative” behavior. 像order_by()和group_by()这样的方法返回一个新的实例 - 原始实例保持不变。非生成方法仍然存在。

  • [metadata] The internals of select/union vastly simplified- all decision making regarding “is subquery” and “correlation” pushed to SQL generation phase. select()元素现在从不被它们的封闭容器或任何方言的编译过程所突变

    参考文献:#569#52

  • [metadata] select(scalar = True)参数已弃用;使用select(..)。as_scalar()。得到的对象服从完整的“列”接口,并在表达式中播放更好。

  • 添加select()。with_prefix('foo')允许在SELECT 的columns子句之前放置任何关键字集合。[metadata]

    参考文献:#504

  • [metadata] 增加了对行[] 的数组切片支持

    参考文献:#686

  • [metadata] 结果集可以更好地尝试将cursor.description中存在的DBAPI类型与方言定义的TypeEngine对象进行匹配,然后将其用于结果处理。注意这只对文本SQL有效;构造的SQL语句总是有一个明确的类型映射。

  • [metadata] Result sets from CRUD operations close their underlying cursor immediately and will also autoclose the connection if defined for the operation; this allows more efficient usage of connections for successive CRUD operations with less chance of “dangling connections”.

  • [metadata] 列默认和onupdate Python函数(即传递给ColumnDefault)可能需要零个或一个参数;一个参数是ExecutionContext,您可以从中调用“context.parameters [someparam]”来访问附加到该语句的其他绑定参数值。用于执行的连接也可用,以便您可以预执行语句。

    参考文献:#559

  • [metadata] 新增了“explcit”创建/删除/执行序列支持(即,您可以将“可连接”传递给序列中的每个方法)

  • [metadata] 在操作模式时更好地引用标识符

  • [metadata] 标准化无法定位类型的表反射行为; NullType被替换,引发警告。

  • [metadata] ColumnCollection(即表上的'c'属性)遵循“__contains __”的字典语义

    参考文献:#606

  • [engines] 速度!结果处理和绑定参数处理的机制已被彻底改进,精简和优化,以尽可能少地发出方法调用。质量INSERT和质量行集迭代的台架测试显示,0.4的速度比0.3快两倍,使用的函数调用次数减少了68%。

  • [engines] You can now hook into the pool lifecycle and run SQL statements or other logic at new each DBAPI connection, pool check-out and check-in.

  • [engines] 连接获得一个.properties集合,其内容范围为基础DBAPI连接的生命周期

  • [engines] 从池中删除了auto_close_cursors和disallow_open_cursors参数;由于游标通常由ResultProxy和Connection关闭,因此减少开销。

  • [extensions] proxyengine暂时被移除,等待实际工作替换。

  • [extensions] SelectResults已被Query取代。SelectResults / SelectResultsExt仍然存在,但只是返回一个稍微修改的Query对象以实现向后兼容。来自SelectResults的join_to()方法不再存在,需要使用join()。

  • [postgres] 添加了使用postgres数组数据类型的PGArray数据类型。