[Sqlalchemy-commits] sqlalchemy: - [bug] Fixed bug in relationship comparisons
Brought to you by:
zzzeek
From: <co...@sq...> - 2012-04-26 16:00:19
|
details: http://hg.sqlalchemy.org/sqlalchemy/sqlalchemy/rev/29f608de0f4e changeset: 8266:29f608de0f4e user: Mike Bayer <mi...@zz...> date: Thu Apr 26 11:58:54 2012 -0400 description: - [bug] Fixed bug in relationship comparisons whereby calling unimplemented methods like SomeClass.somerelationship.like() would produce a recursion overflow, instead of NotImplementedError. Subject: sqlalchemy: backport of relationshipproperty comparison bug fix details: http://hg.sqlalchemy.org/sqlalchemy/sqlalchemy/rev/813168d05065 changeset: 8267:813168d05065 user: Mike Bayer <mi...@zz...> date: Thu Apr 26 11:59:50 2012 -0400 description: backport of relationshipproperty comparison bug fix diffstat: AUTHORS | 1 + CHANGES | 228 ++++++- doc/build/conf.py | 6 +- doc/build/core/connections.rst | 46 + doc/build/core/tutorial.rst | 4 +- doc/build/core/types.rst | 6 - doc/build/index.rst | 3 +- doc/build/intro.rst | 10 +- doc/build/orm/extensions/index.rst | 1 - doc/build/orm/extensions/sqlsoup.rst | 10 - doc/build/orm/inheritance.rst | 514 ++++++++------ doc/build/orm/relationships.rst | 7 + doc/build/orm/tutorial.rst | 4 +- examples/inheritance/joined.py | 135 +++ examples/inheritance/polymorph.py | 125 --- lib/sqlalchemy/__init__.py | 12 +- lib/sqlalchemy/dialects/__init__.py | 28 + lib/sqlalchemy/dialects/firebird/base.py | 7 +- lib/sqlalchemy/dialects/informix/base.py | 10 +- lib/sqlalchemy/dialects/mssql/base.py | 57 +- lib/sqlalchemy/dialects/mysql/base.py | 8 +- lib/sqlalchemy/dialects/oracle/base.py | 33 +- lib/sqlalchemy/dialects/postgresql/base.py | 141 +-- lib/sqlalchemy/dialects/sqlite/base.py | 132 ++- lib/sqlalchemy/engine/__init__.py | 6 + lib/sqlalchemy/engine/base.py | 68 +- lib/sqlalchemy/engine/default.py | 3 + lib/sqlalchemy/engine/reflection.py | 34 +- lib/sqlalchemy/engine/url.py | 57 +- lib/sqlalchemy/events.py | 6 +- lib/sqlalchemy/exc.py | 7 + lib/sqlalchemy/ext/associationproxy.py | 8 +- lib/sqlalchemy/ext/declarative.py | 6 +- lib/sqlalchemy/ext/sqlsoup.py | 808 ----------------------- lib/sqlalchemy/inspection.py | 44 + lib/sqlalchemy/orm/__init__.py | 19 + lib/sqlalchemy/orm/attributes.py | 213 ++--- lib/sqlalchemy/orm/descriptor_props.py | 3 +- lib/sqlalchemy/orm/dynamic.py | 12 +- lib/sqlalchemy/orm/identity.py | 15 +- lib/sqlalchemy/orm/instrumentation.py | 10 +- lib/sqlalchemy/orm/mapper.py | 39 +- lib/sqlalchemy/orm/properties.py | 749 +++++---------------- lib/sqlalchemy/orm/query.py | 208 +++-- lib/sqlalchemy/orm/relationships.py | 919 ++++++++++++++++++++++++++ lib/sqlalchemy/orm/session.py | 168 ++-- lib/sqlalchemy/orm/state.py | 260 ++---- lib/sqlalchemy/orm/strategies.py | 102 +-- lib/sqlalchemy/orm/unitofwork.py | 20 +- lib/sqlalchemy/orm/util.py | 197 ++++- lib/sqlalchemy/processors.py | 8 +- lib/sqlalchemy/schema.py | 17 +- lib/sqlalchemy/sql/compiler.py | 20 +- lib/sqlalchemy/sql/expression.py | 80 +- lib/sqlalchemy/sql/operators.py | 11 +- lib/sqlalchemy/sql/util.py | 164 +++- lib/sqlalchemy/sql/visitors.py | 12 +- lib/sqlalchemy/types.py | 183 +----- lib/sqlalchemy/util/__init__.py | 2 +- lib/sqlalchemy/util/langhelpers.py | 59 +- test/aaa_profiling/test_memusage.py | 48 - test/aaa_profiling/test_orm.py | 6 +- test/aaa_profiling/test_resultset.py | 8 +- test/aaa_profiling/test_zoomark.py | 4 +- test/base/test_inspect.py | 62 + test/base/test_utils.py | 21 + test/dialect/test_mssql.py | 11 +- test/dialect/test_postgresql.py | 120 +-- test/dialect/test_sqlite.py | 103 ++- test/engine/test_parseconnect.py | 39 + test/engine/test_reflection.py | 81 +- test/ext/test_associationproxy.py | 10 +- test/ext/test_declarative.py | 22 + test/ext/test_serializer.py | 25 +- test/ext/test_sqlsoup.py | 447 ------------- test/orm/_fixtures.py | 45 +- test/orm/inheritance/test_abc_inheritance.py | 6 +- test/orm/inheritance/test_basic.py | 8 +- test/orm/inheritance/test_with_poly.py | 113 +++ test/orm/test_attributes.py | 137 +--- test/orm/test_backref_mutations.py | 4 +- test/orm/test_cascade.py | 21 +- test/orm/test_events.py | 21 +- test/orm/test_froms.py | 82 ++- test/orm/test_inspect.py | 290 ++++++++ test/orm/test_joins.py | 12 +- test/orm/test_legacy_mutable.py | 375 ---------- test/orm/test_mapper.py | 10 +- test/orm/test_query.py | 67 +- test/orm/test_rel_fn.py | 927 +++++++++++++++++++++++++++ test/orm/test_relationships.py | 759 +++++++++++++++------- test/orm/test_session.py | 7 +- test/orm/test_transaction.py | 71 +- test/sql/test_compiler.py | 12 +- test/sql/test_constraints.py | 43 +- test/sql/test_generative.py | 98 ++- test/sql/test_query.py | 70 +- test/sql/test_selectable.py | 122 +++- 98 files changed, 5845 insertions(+), 4527 deletions(-) diffs (truncated from 14539 to 300 lines): diff -r aa81142470a5 -r 813168d05065 AUTHORS --- a/AUTHORS Tue Apr 24 18:29:40 2012 -0400 +++ b/AUTHORS Thu Apr 26 11:59:50 2012 -0400 @@ -5,6 +5,7 @@ - Michael Bayer <mi...@zz...> - Jason Kirtland <je...@di...> - Gaetan de Menten <gde...@gm...> +- Diana Clarke <dia...@gm...> - Michael Trier <mt...@gm...> - Philip Jenvey <pj...@un...> - Ants Aasma <ant...@gm...> diff -r aa81142470a5 -r 813168d05065 CHANGES --- a/CHANGES Tue Apr 24 18:29:40 2012 -0400 +++ b/CHANGES Thu Apr 26 11:59:50 2012 -0400 @@ -3,20 +3,116 @@ ======= CHANGES ======= -0.7.7 -===== + +0.8.0b1 +======= +- general + - SQLAlchemy 0.8 now targets Python 2.5 and + above. Python 2.4 is no longer supported. + + - [removed] The "sqlalchemy.exceptions" + synonym for "sqlalchemy.exc" is removed + fully. [ticket:2433] + - orm + - [removed] The legacy "mutable" system of the + ORM, including the MutableType class as well + as the mutable=True flag on PickleType + and postgresql.ARRAY has been removed. + In-place mutations are detected by the ORM + using the sqlalchemy.ext.mutable extension, + introduced in 0.7. The removal of MutableType + and associated constructs removes a great + deal of complexity from SQLAlchemy's internals. + The approach performed poorly as it would incur + a scan of the full contents of the Session + when in use. [ticket:2442] + + - [feature] Major rewrite of relationship() + internals now allow join conditions which + include columns pointing to themselves + within composite foreign keys. A new + API for very specialized primaryjoin conditions + is added, allowing conditions based on + SQL functions, CAST, etc. to be handled + by placing the annotation functions + remote() and foreign() inline within the + expression when necessary. Previous recipes + using the semi-private _local_remote_pairs + approach can be upgraded to this new + approach. [ticket:1401] + + - [feature] New standalone function with_polymorphic() + provides the functionality of query.with_polymorphic() + in a standalone form. It can be applied to any + entity within a query, including as the target + of a join in place of the "of_type()" modifier. + [ticket:2333] + + - [feature] Added new core function "inspect()", + which serves as a generic gateway to + introspection into mappers, objects, + others. The Mapper and InstanceState + objects have been enhanced with a public + API that allows inspection of mapped + attributes, including filters for column-bound + or relationship-bound properties, inspection + of current object state, history of + attributes, etc. [ticket:2208] + + - [feature] Calling rollback() within a + session.begin_nested() will now only expire + those objects that had net changes within the + scope of that transaction, that is objects which + were dirty or were modified on a flush. This + allows the typical use case for begin_nested(), + that of altering a small subset of objects, to + leave in place the data from the larger enclosing + set of objects that weren't modified in + that sub-transaction. [ticket:2452] + + - [bug] Fixed bug in relationship comparisons + whereby calling unimplemented methods like + SomeClass.somerelationship.like() would + produce a recursion overflow, instead + of NotImplementedError. Also in 0.7.7. + + - [bug] The "passive" flag on Session.is_modified() + no longer has any effect. is_modified() in + all cases looks only at local in-memory + modified flags and will not emit any + SQL or invoke loader callables/initializers. + [ticket:2320] + + - [bug] The warning emitted when using + delete-orphan cascade with one-to-many + or many-to-many without single-parent=True + is now an error. The ORM + would fail to function subsequent to this + warning in any case. [ticket:2405] + + - [feature] Query now "auto correlates" by + default in the same way as select() does. + Previously, a Query used as a subquery + in another would require the correlate() + method be called explicitly in order to + correlate a table on the inside to the + outside. As always, correlate(None) + disables correlation. [ticket:2179] + - [feature] Added prefix_with() method to Query, calls upon select().prefix_with() to allow placement of MySQL SELECT directives in statements. Courtesy Diana Clarke [ticket:2443] + also in 0.7.7. - [bug] Fixed bug in 0.7.6 introduced by [ticket:2409] whereby column_mapped_collection used against columns that were mapped as joins or other indirect selectables would fail to function. + also in 0.7.7. - [feature] Added new flag to @validates include_removes. When True, collection @@ -24,47 +120,146 @@ will also be sent to the validation function, which accepts an additional argument "is_remove" when this flag is used. + also in 0.7.7. + + - [feature] The after_attach event is now + emitted after the object is established + in Session.new or Session.identity_map + upon Session.add(), Session.merge(), + etc., so that the object is represented + in these collections when the event + is called. [ticket:2464] - [bug] Fixed bug whereby polymorphic_on column that's not otherwise mapped on the class would be incorrectly included in a merge() operation, raising an error. [ticket:2449] + also in 0.7.7. - [bug] Fixed bug in expression annotation mechanics which could lead to incorrect rendering of SELECT statements with aliases and joins, particularly when using column_property(). [ticket:2453] + also in 0.7.7. - [bug] Fixed bug which would prevent OrderingList from being pickleable [ticket:2454]. Courtesy Jeff Dairiki + also in 0.7.7. + +- engine + - [feature] Added a new system + for registration of new dialects in-process + without using an entrypoint. See the + docs for "Registering New Dialects". + [ticket:2462] + + - [bug] The names of the columns on the + .c. attribute of a select().apply_labels() + is now based on <tablename>_<colkey> instead + of <tablename>_<colname>, for those columns + that have a distinctly named .key. + [ticket:2397] + + - [feature] Inspector.get_primary_keys() is + deprecated; use Inspector.get_pk_constraint(). + Courtesy Diana Clarke. [ticket:2422] - sql + - [feature] The Inspector object can now be + acquired using the new inspect() service, + part of [ticket:2208] + + - [feature] The column_reflect event now + accepts the Inspector object as the first + argument, preceding "table". Code which + uses the 0.7 version of this very new + event will need modification to add the + "inspector" object as the first argument. + [ticket:2418] + + - [feature] The behavior of column targeting + in result sets is now case sensitive by + default. SQLAlchemy for many years would + run a case-insensitive conversion on these values, + probably to alleviate early case sensitivity + issues with dialects like Oracle and + Firebird. These issues have been more cleanly + solved in more modern versions so the performance + hit of calling lower() on identifiers is removed. + The case insensitive comparisons can be re-enabled + by setting "case_insensitive=False" on + create_engine(). [ticket:2423] + + - [feature] The "unconsumed column names" warning emitted + when keys are present in insert.values() or update.values() + that aren't in the target table is now an exception. + [ticket:2415] + + - [bug] All of UniqueConstraint, ForeignKeyConstraint, + CheckConstraint, and PrimaryKeyConstraint will + attach themselves to their parent table automatically + when they refer to a Table-bound Column object directly + (i.e. not just string column name), and refer to + one and only one Table. Prior to 0.8 this behavior + occurred for UniqueConstraint and PrimaryKeyConstraint, + but not ForeignKeyConstraint or CheckConstraint. + [ticket:2410] + + - [bug] column.label(None) now produces an + anonymous label, instead of returning the + column object itself, consistent with the behavior + of label(column, None). [ticket:2168] + - [bug] Removed warning when Index is created with no columns; while this might not be what the user intended, it is a valid use case as an Index could be a placeholder for just an index of a certain name. + also in 0.7.7. - [feature] Added new connection event dbapi_error(). Is called for all DBAPI-level errors passing the original DBAPI exception before SQLAlchemy modifies the state of the cursor. + also in 0.7.7. - [bug] If conn.begin() fails when calling "with engine.begin()", the newly acquired Connection is closed explicitly before propagating the exception onward normally. + also in 0.7.7. + +- sqlite + - [feature] the SQLite date and time types + have been overhauled to support a more open + ended format for input and output, using + name based format strings and regexps. A + new argument "microseconds" also provides + the option to omit the "microseconds" + portion of timestamps. Thanks to + Nathan Wright for the work and tests on + this. [ticket:2363] - mssql + - [bug] removed legacy behavior whereby + a column comparison to a scalar SELECT via + == would coerce to an IN with the SQL server + dialect. This is implicit + behavior which fails in other scenarios + so is removed. Code which relies on this + needs to be modified to use column.in_(select) + explicitly. [ticket:2277] + - [feature] Added interim create_engine flag supports_unicode_binds to PyODBC dialect, to force whether or not the dialect passes Python unicode literals to PyODBC or not. + also in 0.7.7. - [bug] Repaired the use_scope_identity create_engine() flag when using the pyodbc @@ -74,6 +269,7 @@ INSERT to get at the last inserted ID, for those tables which have "implicit_returning" set to False. + also in 0.7.7. - [bug] UPDATE..FROM syntax with SQL Server requires that the updated table be present @@ -83,6 +279,7 @@ in the FROM, when FROM is present in the first place. Courtesy sayap. [ticket:2468] + also in 0.7.7. - postgresql - [feature] Added new for_update/with_lockmode() @@ -92,7 +289,14 @@ with_lockmode("read_nowait"). These emit "FOR SHARE" and "FOR SHARE NOWAIT", respectively. Courtesy Diana Clarke |