版本: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] Fixed non-2.3 compatible usage of set() and generator expression within relation().

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() “normalizes” the name before returning, meaning it returns a lower-case name when the identifier is detected as case insensitive.

  • [oracle] creating/dropping tables takes schema name into account when searching for the existing table, so that tables in other owner namespaces with the same name do not conflict

    参考文献:#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] Fix to the recent relation() refactoring which fixes exotic viewonly relations which join between local and remote table multiple times, with a common column shared between the joins.

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

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

    参考文献:#610

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

    参考文献:#1036

  • [orm] Fixed “concatenate tuple” bug which could occur with Query.order_by() if clause adaption had taken place.

    参考文献:#1027

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

  • [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] 精确的mapper._save_obj(),它在flush 期间不必要地调用标量值的__ne __

    参考文献:#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] Added COLLATE support via the .collate() expression operator and collate(, ) sql function.

  • [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] 在engine / dburi参数中添加了“odbc_options”参数。给定的字符串仅附加到SQLAlchemy生成的odbc连接字符串。

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

火鸟¶ T0>

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

杂项¶ T0>

  • [declarative] [extension] Joined table inheritance mappers use a slightly relaxed function to create the “inherit condition” to the parent table, so that other foreign keys to not-yet-declared Table objects don’t trigger an error.

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

  • [engines] Pool listeners can now be provided as a dictionary of callables or a (possibly partial) duck-type of PoolListener, your choice.

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

  • [ext] set-based association proxies |=, -=, ^= and &= are stricter about their operands and only operate on sets, frozensets or other association proxies. 以前,他们会接受任何duck-typed集合。

0.4.5 ¶ T0>

发布日期:2008年4月4日

ORM ¶ T0>

  • [orm] A small change in behavior to session.merge() - existing objects are checked for based on primary key attributes, not necessarily _instance_key. 所以广泛要求的能力,即:

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

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

  • [orm] Also fixed behavior in merge() whereby collection elements present on the destination but not the merged collection were not being removed from the destination.

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

    参考文献:#995

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

  • [orm] Added comparable_property(), adds query Comparator behavior to regular, unmanaged Python properties

  • [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 =('*',selectable)with_polymorphic =([mappers],selectable)

    这将控制继承的映射器的默认多态加载策略。如果没有给出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(),这是有道理的,直到现在,这个查询一直是无用的。

      对这个方法的将来的改变可能包括它能够加入,过滤和允许与“结果集”不相关的其他选项被删除,所以我们正在寻找的反馈是人们如何使用_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] Fixed bug which was preventing synonym() attributes from being used with inheritance

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

    参考文献:#996

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

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

  • [orm] Adjusted the definition of “self-referential” to be any two mappers with a common parent (this affects whether or not aliased=True is required when joining with Query).

  • [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 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。需要明确的关联()调用。

  • [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() and insert().values() take keyword arguments.

  • [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] Reflected tables will now automatically load other tables which are referenced by Foreign keys in the auto-loaded table,.

    参考文献:#979

  • [mssql] 新增executemany检查以跳过标识获取,

    参考文献:#916

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

    参考文献:#884

  • [mssql] 为pyodbc方言增加了一个新的“driver”关键字参数。如果给定,将会替换成ODBC连接字符串,默认为'SQL Server'。

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

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

预言¶ T0>

  • [oracle] Table上的“owner”关键字现在已经被弃用,并且与“schema”关键字完全同义。现在,表格可以用“表格”对象中明确声明的备用“所有者”属性来反映,也可以不用“模式”来反映。

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

  • [oracle] Table上的“owner”关键字现在已经被弃用,并且与“schema”关键字完全同义。现在,表格可以用“表格”对象中明确声明的备用“所有者”属性来反映,也可以不用“模式”来反映。

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

杂项¶ T0>

  • [declarative] [extension] The “synonym” function is now directly usable with “declarative”. 使用“描述符”关键字参数传递修饰的属性,例如:somekey = synonym('_ somekey',descriptor = property(g,s))

  • [declarative] [extension] “deferred”函数可以用于“declarative”。最简单的用法是将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 = Column(Integer,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] Got PG server side cursors back into shape, added fixed unit tests as part of the default test suite. 为光标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] Repaired behavior of == and != operators at the relation() level when compared against NULL for one-to-one relations

    参考文献:#985

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

  • [orm] Added query.with_polymorphic() - specifies a list of classes which descend from the base class, which will be added to the FROM clause of the query. 允许在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] Fixed potential generative bug when the same Query was used to generate multiple Query objects using join().

  • [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] Preventive code against a potential lost-reference bug in 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] The value of a bindparam() can be a callable, in which case it’s evaluated at statement execution time to get the value.

  • [sql] Added exception wrapping/reconnect support to result set fetching. 重新连接在结果期间引发可捕获数据错误的数据库(即在MySQL上不起作用)

    参考文献:#978

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

    参考文献:#936

  • [sql] Fixed bug which was preventing UNIONS from being cloneable.

    参考文献:#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()。这里引入的最大变化是,当在transaction()中创建一个具有transactional = True的会话时引发一个异常,你必须调用Session.rollback()或者Session.close()来使得这个Session在异常之后继续。¶ T0>

  • [orm] Fixed merge() collection-doubling bug when merging transient entities with backref’ed collections.

    参考文献:#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] Instances which have been partially or fully expired will have their expired attributes populated during a regular Query operation which affects those objects, preventing a needless second SQL statement for each instance.

  • [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. 这些可以用在地方或与字符串的任何组合。特别是,这允许建立连接到多态关系上的子类,即:

    query(Company).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] General improvements to the behavior of join() in conjunction with polymorphic mappers, i.e. joining from/to polymorphic mappers and properly applying aliases.

  • [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] Fixed a rather expensive call in Query that was slowing down polymorphic queries.

  • [orm] “Passive defaults” and other “inline” defaults can now be loaded during a flush() call if needed; in particular, this allows constructing relations() where a foreign key column references a server-side-generated, non-primary-key column.

    参考文献:#954

  • [orm]

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

  • [orm] Miscellaneous tickets:

    参考文献:#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] Added a callable-based DDL events interface, adds hooks before and after Tables and MetaData create and drop.

  • [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,在所有其他上下(x)LIKE 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() accepts text(‘something’) and other non-literal operands properly

    参考文献:#962

  • [sql] fixed bug in result proxy where anonymously generated column labels would not be accessible using their straight string name

  • [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. 如果没有事务正在进行,这个标志将在执行过程中启用“autocommit”行为。

    参考文献:#915

  • [sql] 现在可选择的“.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] Auto-detect an unspecified MySQL ANSI_QUOTES mode during reflection operations, support for changing the mode midstream. 如果不使用反射,仍然需要手动模式设置。

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

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

    参考文献:#580

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

  • 在生成LIMIT / OFFSET子查询时,Oracle在结果集列映射中组合正确的列,允许列正确地映射到结果集,即使长名称截断在中剔除[dialects]

    参考文献:#941

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

  • [dialects] MSSQL now includes an experimental implementation of LIMIT/OFFSET using the ANSI SQL row_number() function, so it requires MSSQL-2005 or higher. 要启用该功能,请将“has_window_funcs”添加到连接的关键字参数中,或将“?has_window_funcs = 1”添加到您的dburi查询参数中。

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

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

0.4.2p3 ¶ T0>

发行日期:2008年1月9日

一般¶ T0>

  • [general] sub version numbering scheme changed to suite setuptools version number rules; easy_install -u should now get this version over 0.4.2.

ORM ¶ T0>

  • [orm] fixed bug with session.dirty when using “mutable scalars” (such as PickleTypes)

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

  • [orm] suppressing all errors in InstanceState.__cleanup() now.

  • [orm] fixed an attribute history bug whereby assigning a new collection to a collection-based attribute which already had pending changes would generate incorrect history

    参考文献:#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。(也就是说,您可以制作后备的同义词而不用担心操作的顺序)

    参考文献:#919

  • [orm] fixed bug which could occur with polymorphic “union” mapper which falls back to “deferred” loading of inheriting tables

  • [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] fixed fairly critical bug whereby the same instance could be listed more than once in the unitofwork.new collection; most typically reproduced when using a combination of inheriting mappers and ScopedSession.mapper, as the multiple __init__ calls per instance could save() the object with distinct _state objects

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

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

    参考文献:#920

SQL ¶ T0>

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

    参考文献:#912

  • [sql] new UnicodeText type is added, to specify an encoded, unlengthed Text type

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

  • [sql] changed name of TEXT to Text since its a “generic” type; TEXT name is deprecated until 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] a major behavioral change to collection-based backrefs: they no longer trigger lazy loads ! “反向”添加和删除排队,并在实际读取和加载时与集合合并;但是不要事先触发负载。对于已经注意到这种行为的用户来说,这应该比在某些情况下使用动态关系更方便;对于那些没有的人来说,在某些情况下,你可能会注意到你的应用比以前少了很多的查询。

    参考文献:#871

  • [orm] mutable primary key support is added. 主键列可以自由更改,并且实例的身份将在刷新时更改。此外,支持与关系的外键引用(主键或不键)更新级联,或者与数据库的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] columns which are missing from a Query’s select statement now get automatically deferred during load.

  • [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] fixed Query bug when filter_by() compares a relation against 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() now replaces all existing FROM criterion with the given argument; the previous behavior of constructing a list of FROM clauses was generally not useful as is required filter() calls to create join criterion, and new tables introduced within filter() already add themselves to the FROM clause. 新的行为不仅允许从主表连接,而且还允许选择语句。过滤条件,顺序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”作为属性“None”的有效值。要重新触发属性的“加载器”,请使用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 will work with mappers added via add_entity().

  • [orm] added “cascade delete” behavior to “dynamic” relations just like that of regular relations. 如果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] relaxed rules on column_property() expressions having labels; any ColumnElement is accepted now, as the compiler auto-labels non-labeled ColumnElements now. 像select()语句那样,selectable仍然需要通过as_scalar()或label()来转换为ColumnElement。

  • [orm] fixed backref bug where you could not del instance.attr if attr was None

  • [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] Bulk assignment of a MappedCollection now raises an error if a key in the incoming dictionary does not match the key that the collection’s keyfunc would use for that value.

    参考文献:#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] more fixes to the LIMIT/OFFSET aliasing applied with Query + eagerloads, in this case when mapped against a select statement

    参考文献:#904

  • [orm] fix to self-referential eager loading such that if the same mapped instance appears in two or more distinct sets of columns in the same result set, its eagerly loaded collection will be populated regardless of whether or not all of the rows contain a set of “eager” columns for that collection. 如果在打开join_depth的情况下获取结果,这也会显示为KeyError。

  • [orm] fixed bug where Query would not apply a subquery to the SQL when LIMIT was used in conjunction with an inheriting mapper where the eager loader was only in the parent mapper.

  • [orm] clarified the error message which occurs when you try to update() an instance with the same identity key as an instance already present in the session.

  • [orm] some clarifications and fixes to merge(instance, dont_load=True). 修复了懒惰加载程序在返回的实例上被禁用的问题。此外,我们目前不支持合并具有未提交更改的实例,在使用dont_load = True的情况下....现在将引发错误。这是由于合并给定实例的“提交状态”以正确对应于新复制的实例以及其他修改状态的复杂性。由于dont_load = True的用例是缓存,因此给定的实例不应该有任何未提交的变化。我们也复制实例而不使用任何事件,这样新会话上的“脏”列表就不会受到影响。

  • [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 (and others) will issue a warning when two columns in their exported columns collection conflict based on name.

  • [sql] tables with schemas can still be used in sqlite, firebird, schema name just gets dropped

    参考文献:#890

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

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

  • [sql] from_obj keyword argument to select() can be a scalar or a list.

火鸟¶ T0>

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

    参考文献:#410

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

  • [firebird] [backend] map func.length() to ‘char_length’ (easily overridable with the UDF ‘strlen’ on old versions of Firebird)

杂项¶ T0>

  • [dialects] sqlite SLDate type will not erroneously render “microseconds” portion of a datetime or time object.

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

    References: #802

  • [orm] added op() operator to instrumented attributes; i.e. User.name.op(‘ilike’)(‘%somename%’)

    参考文献:#767

  • [orm] Mapped classes may now define __eq__, __hash__, and __nonzero__ methods with arbitrary semantics. orm现在只处理一个身份的基础上处理所有映射的实例。(例如'is'vs'==')

    参考文献:#676

  • [orm] the “properties” accessor on Mapper is removed; it now throws an informative exception explaining the usage of mapper.get_property() and mapper.iterate_properties

  • [orm] added having() method to Query, applies HAVING to the generated statement in the same way as filter() appends to the WHERE clause.

  • [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] fixed error where Query.add_column() would not accept a class-bound attribute as an argument; Query also raises an error if an invalid argument was sent to add_column() (at instances() time)

    参考文献:#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() includes a keyword argument “dont_load=True”. 设置此标志将导致合并操作不响应传入的分离对象从数据库加载任何数据,并将接受传入的分离对象,就像它已经存在于该会话中一样。使用它可以将来自外部缓存系统的分离对象合并到会话中。

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

  • [orm] Fixed a truncation error when re-assigning a subset of a collection (obj.relation = obj.relation[1:])

    参考文献:#834

  • [orm] 反驳后退配置代码,在现有属性上跳转的backrefs现在引发错误

    参考文献:#832

  • [orm] Improved behavior of add_property() etc., fixed involving synonym/deferred.

    参考文献:#831

  • [orm] Fixed clear_mappers() behavior to better clean up after itself.

  • [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] Fixed __hash__ for association proxy- these collections are unhashable, just like their mutable Python counterparts.

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

  • [orm] fixed very hard-to-reproduce issue where by the FROM clause of Query could get polluted by certain generative calls

    参考文献:#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] Fixed expression translation of text() clauses; this repairs various ORM scenarios where literal text is used for SQL expressions

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

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

  • [sql] func。对象可以腌制/不沾

    参考文献:#844

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

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

    参考文献:#573

  • [sql] The “properties” collection on Connections has been renamed “info” to match schema’s writable collections. 访问仍然可以通过“属性”名称直到0.5.

  • [sql] fixed the close() method on Transaction when using strategy=’threadlocal’

  • [sql] fix to compiled bind parameters to not mistakenly populate 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] 使得dao检测更加可靠

    参考文献:#828

  • [dialects] 将Dialect属性“preexecute_sequences”重命名为“preexecute_pk_sequences”。对于使用旧名称的out-of-tree方言,使用porxy属性。

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

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

  • [dialects] mysql Float, MSFloat and MSDouble constructed without arguments now produce no-argument DDL, e.g.’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

  • The IdentifierPreprarer’s _requires_quotes test is now regex based. 任何提供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现在正确地反映了列的可空属性。

  • 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_table的abc继承)

    参考文献:#795

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

  • The no-arg ResultProxy._row_processor() is now the class attribute _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上增加了对LIMIT UPDATE的支持。

  • 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

  • Fixed breakage with postgres and multiple two-phase transactions. 两阶段提交和回滚不会像通常的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将编译所有映射器;这是)。The only caveat here is that an inheriting mapper now looks for its inherited mapper upon construction; so mappers within inheritance relationships need to be constructed in inheritance order (which should be the normal case anyway).

    参考文献:#758

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

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

  • 加强了Query的“渴望加载”别名的生成与Query.instances()之间的关系,而Query.instances()实际上是抓取热切加载的行。如果EagerLoader没有为该语句专门生成别名,则在获取行时,EagerLoader不会生效。这可以防止意外抓取列作为急切加载的一部分,当他们不是这样的,这可能发生在文本SQL以及一些继承情况。这一点尤其重要,因为列的“匿名别名”现在使用简单的整数计数来生成标签。

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

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

    参考文献:#560

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

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

    参考文献:#584#761

  • Fixed reflection of the empty string for mysql enums.

  • Changed MySQL dialect to use the older LIMIT , syntax instead of LIMIT OFFSET for folks using 3.23.

    参考文献:#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.. 这不适用于“〜(x == y)”,因为〜(x == y)编译为“x!= y”,但仍然适用于BETWEEN等运算符。

    参考文献:#764

  • Other tickets:,,.

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

0.4.0beta5 ¶ T0>

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

    参考文献:#754

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

    参考文献:#769

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

    参考文献:#763

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

    参考文献:#748

  • AssociationProxy can now take custom getters and setters.

  • Fixed malfunctioning BETWEEN in orm queries.

  • Fixed OrderedProperties pickling

    参考文献:#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端默认表达式的列的集合。

  • Fixed PG executemany() behavior.

    参考文献:#759

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

  • postgres no longer wraps executemany() with individual execute() calls, instead favoring performance. 由于psycopg2没有报告executemany()的适当的行数,所以“PGC”/“concurrency”检查被删除的项目(使用executemany)被PG禁用。

  • [tickets] [fixed]

    参考文献:#742

  • [tickets] [fixed]

    参考文献:#748

  • [tickets] [fixed]

    参考文献:#760

  • [tickets] [fixed]

    参考文献:#762

  • [tickets] [fixed]

    参考文献:#763

0.4.0beta4 ¶ T0>

发布于:2007年8月22日星期三
  • Tidied up what ends up in your namespace when you ‘from 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”引擎策略的“部分”版本,但没有线程本地事务部分。我们希望能够减少连接池的开销以及数据库的使用。但是,如果它证明以负面的方式影响稳定性,我们会马上回滚。

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

  • 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()版本。

  • Added session.prune(), trims away instances cached in a session that are no longer referenced elsewhere. (用于强引用身份映射的实用程序)。

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

  • Transactional and non-transactional Session integrates better with bound connection; a close() will ensure that connection transactional state is the same as that which existed on it before being bound to the Session.

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

    参考文献:#735

  • Small adjustment to mapper class.__init__ to allow for Py2.6 object.__init__() behavior.

  • Fixed ‘prefix’ argument for select()

  • Connection.begin() no longer accepts nested=True, this logic is now all in begin_nested().

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

  • [tickets] [fixed]

    参考文献:#735

  • [tickets] [fixed]

    参考文献:#752

0.4.0beta3 ¶ T0>

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

  • New performance tests show a combined mass-insert/mass-select test as having 68% fewer function calls than the same test run against 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.

  • Support added for executemany() scenarios such that unneeded “last row id” logic doesn’t kick in, parameters aren’t excessively traversed.

  • Added ‘inherit_foreign_keys’ arg to 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.] Added engine_from_config() function for helping to create_engine() from an .ini style config.

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

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

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

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

杂项¶ T0>

  • [tickets] [fixed]

    References: #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 used as collection classes no longer need to change __iter__ semantics- itervalues() is used by default instead. 这是一个向后不兼容的变化。

  • [orm] Subclassing dict for a mapped collection is no longer needed in most cases. orm.collections通过指定的列或您选择的自定义函数提供了关键对象的固定实现。

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

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

  • [orm] 对Query进行大修:

  • [orm] 不推荐使用所有的selectXXX方法。生成方法现在是做事情的标准方法,即filter(),filter_by(),all(),one()等。被弃用的方法是用新的替换文档串起来的。

  • [orm] Class-level properties are now usable as query elements... no more ‘.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”。这使得他们的连接建立在别名表上;随后对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] Added query.populate_existing(), marks the query to reload all attributes and collections of all instances touched in the query, including eagerly-loaded entities.

    参考文献:#660

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

  • [orm] 对Session进行大修:

  • [orm] New function which “configures” a session called “sessionmaker()”. 发送各种关键字参数到这个函数一次,返回一个新的类,创建一个会话对该原型。

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

  • [orm] Session also supports SAVEPOINT transactions; call 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] Session supports “autoflush=True”. 这会在每个查询之前发出flush()。与事务一起使用,你可以保存()/ update()然后查询,新的对象将在那里。在末尾使用commit()(如果是非事务性的,则使用flush())来清除剩余的变化。

  • [orm] New scoped_session() function replaces SessionContext and assignmapper. 构建到“sessionmaker()”的概念上来产生一个Session()构造返回线程本地会话的类。或者,将所有Session方法调用为类方法,即Session.save(foo); Session.commit()。就像旧的“对象库”一样。

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

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

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

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

  • [orm] A rudimental sharding (horizontal scaling) system is introduced. 该系统使用一个修改后的Session,它可以根据定义“分片策略”的用户定义函数在多个数据库之间分配读写操作。可以根据属性值,循环方法或任何其他用户定义的系统在多个数据库之间分发和查询实例及其依赖项。

    参考文献:#618

  • [orm] Eager loading has been enhanced to allow even more joins in more places. 它现在可以在任意的深度沿着自我指涉的和周期性的结构运作。加载循环结构时,在关系()上指定“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] Joined-table inheritance will now generate the primary key columns of all inherited classes against the root table of the join only. 这意味着根表中的每一行都不同于单个实例。如果出于某种罕见的原因,这是不可取的,那么在各个映射器上显式的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] Secondary inheritance loading: polymorphic mappers can be constructed without a select_table argument. 继承初始加载中表未被表示的映射器将立即发出第二个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] It’s now possible to map only a subset of available selectable columns onto mapper properties, using include_columns/exclude_columns..

    参考文献:#696

  • [orm] Added undefer_group() MapperOption, sets a set of “deferred” columns joined by a “group” to load as “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] Speed! 子句编译以及SQL构造的机制已经被精简和简化了很大程度,对0.3的语句构建/编译开销提高了20-30%。

  • [sql] All “type” keyword arguments, such as those to bindparam(), column(), Column(), and func.(), renamed to “type_”. 这些对象仍将其“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] Tables can be reflected from the database en-masse without declaring them in advance. MetaData(engine,reflect = True)会加载数据库中的所有表,或者使用metadata.reflect()进行更好的控制。

  • [metadata] DynamicMetaData has been renamed to ThreadLocalMetaData

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

  • [metadata] BoundMetaData has been removed- regular MetaData is equivalent

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

    参考文献:#646

  • [metadata] New SQL operator implementation which removes all hardcoded operators from expression structures and moves them into compilation; allows greater flexibility of operator compilation; for example, “+” compiles to “||” when used in a string context, or “concat(a,b)” on MySQL; whereas in a numeric context it compiles to “+”. 修复。¶ T0>

    参考文献:#475

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

  • [metadata] Significant architectural overhaul to SQL elements (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) argument is deprecated; use select(..).as_scalar(). 结果对象服从完整的“列”接口,并在表达式中播放更好。

  • [metadata] Added select().with_prefix(‘foo’) allowing any set of keywords to be placed before the columns clause of the SELECT

    参考文献:#504

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

    参考文献:#686

  • [metadata] Result sets make a better attempt at matching the DBAPI types present in cursor.description to the TypeEngine objects defined by the dialect, which are then used for result-processing. 注意这只对文本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] Column defaults and onupdate Python functions (i.e. passed to ColumnDefault) may take zero or one arguments; the one argument is the ExecutionContext, from which you can call “context.parameters[someparam]” to access the other bind parameter values affixed to the statement. 用于执行的连接也是可用的,以便您可以预执行语句。

    参考文献:#559

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

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

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

  • [metadata] ColumnCollection (i.e. the ‘c’ attribute on tables) follows dictionary semantics for “__contains__”

    参考文献:#606

  • [engines] Speed! 结果处理和绑定参数处理的机制已被彻底改进,精简和优化,以尽可能少的方法调用。质量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] Connections gain a .properties collection, with contents scoped to the lifetime of the underlying DBAPI connection

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

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

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

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