summaryrefslogtreecommitdiff
path: root/test/orm/mapper.py
Commit message (Collapse)AuthorAgeFilesLines
* - unit tests have been migrated from unittest to nose.Mike Bayer2009-06-101-2467/+0
| | | | | See README.unittests for information on how to run the tests. [ticket:970]
* - Fixed bug introduced in 0.5.4 whereby Composite typesMike Bayer2009-05-261-0/+7
| | | | fail when default-holding columns are flushed.
* - Significant performance enhancements regarding Sessions/flush()Mike Bayer2009-05-171-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in conjunction with large mapper graphs, large numbers of objects: - The Session's "weak referencing" behavior is now *full* - no strong references whatsoever are made to a mapped object or related items/collections in its __dict__. Backrefs and other cycles in objects no longer affect the Session's ability to lose all references to unmodified objects. Objects with pending changes still are maintained strongly until flush. [ticket:1398] The implementation also improves performance by moving the "resurrection" process of garbage collected items to only be relevant for mappings that map "mutable" attributes (i.e. PickleType, composite attrs). This removes overhead from the gc process and simplifies internal behavior. If a "mutable" attribute change is the sole change on an object which is then dereferenced, the mapper will not have access to other attribute state when the UPDATE is issued. This may present itself differently to some MapperExtensions. The change also affects the internal attribute API, but not the AttributeExtension interface nor any of the publically documented attribute functions. - The unit of work no longer genererates a graph of "dependency" processors for the full graph of mappers during flush(), instead creating such processors only for those mappers which represent objects with pending changes. This saves a tremendous number of method calls in the context of a large interconnected graph of mappers. - Cached a wasteful "table sort" operation that previously occured multiple times per flush, also removing significant method call count from flush(). - Other redundant behaviors have been simplified in mapper._save_obj().
* - Fixed bug where column_prefix wasn't being checked beforeMike Bayer2009-03-111-1/+8
| | | | | not mapping an attribute that already had class-level name present.
* - a forward and complementing backwards reference which are bothMike Bayer2009-03-091-1/+1
| | | | | | of the same direction, i.e. ONETOMANY or MANYTOONE, is now detected, and an error message is raised. Saves crazy CircularDependencyErrors later on.
* - Query won't fail with weakref error when a non-mapper/classMike Bayer2009-02-201-0/+32
| | | | | instrumented descriptor is passed, raises "Invalid column expession".
* - Adjusted the attribute instrumentation change from 0.5.1 toMike Bayer2009-01-221-1/+9
| | | | | | fully establish instrumentation for subclasses where the mapper was created after the superclass had already been fully instrumented. [ticket:1292]
* - The "clear()", "save()", "update()", "save_or_update()"Mike Bayer2009-01-171-42/+42
| | | | | | Session methods have been deprecated, replaced by "expunge_all()" and "add()". "expunge_all()" has also been added to ScopedSession.
* Ensure RowTuple names are correct by adding "key" to QueryableAttribute.Mike Bayer2009-01-121-0/+5
|
* - Concrete inheriting mappers now instrument attributes which are inherited ↵Mike Bayer2009-01-111-2/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | from the superclass, but are not defined for the concrete mapper itself, with an InstrumentedAttribute that issues a descriptive error when accessed. [ticket:1237] - Added a new `relation()` keyword `back_populates`. This allows configuation of backreferences using explicit relations. [ticket:781] This is required when creating bidirectional relations between a hierarchy of concrete mappers and another class. [ticket:1237] - Test coverage added for `relation()` objects specified on concrete mappers. [ticket:1237] - A short documentation example added for bidirectional relations specified on concrete mappers. [ticket:1237] - Mappers now instrument class attributes upon construction with the final InstrumentedAttribute object which remains persistent. The `_CompileOnAttr`/`__getattribute__()` methodology has been removed. The net effect is that Column-based mapped class attributes can now be used fully at the class level without invoking a mapper compilation operation, greatly simplifying typical usage patterns within declarative. [ticket:1269] - Index now accepts column-oriented InstrumentedAttributes (i.e. column-based mapped class attributes) as column arguments. [ticket:1214] - Broke up attributes.register_attribute into two separate functions register_descriptor and register_attribute_impl. The first assembles an InstrumentedAttribute or Proxy descriptor, the second assembles the AttributeImpl inside the InstrumentedAttribute. register_attribute remains for outside compatibility. The argument lists have been simplified. - Removed class_manager argument from all but MutableScalarAttributeImpl (the branch had removed class_ as well but this has been reverted locally to support the serializer extension). - Mapper's previous construction of _CompileOnAttr now moves to a new MapperProperty.instrument_class() method which is called on all MapperProperty objects at the moment the mapper receives them. All MapperProperty objects now call attributes.register_descriptor within that method to assemble an InstrumentedAttribute object directly. - InstrumentedAttribute now receives the "property" attribute from the given PropComparator. The guesswork within the constructor is removed, and allows "property" to serve as a mapper compilation trigger. - RelationProperty.Comparator now triggers compilation of its parent mapper within a util.memoized_property accessor for the "property" attribute, which is used instead of "prop" (we can probably remove "prop"). - ColumnProperty and similar handle most of their initialization in their __init__ method since they must function fully at the class level before mappers are compiled. - SynonymProperty and ComparableProperty move their class instrumentation logic to the new instrument_class() method. - LoaderStrategy objects now add their state to existing InstrumentedAttributes using attributes.register_attribute_impl. Both column and relation-based loaders instrument in the same way now, with a unique InstrumentedAttribute *and* a unique AttributeImpl for each class in the hierarchy. attribute.parententity should now be correct in all cases. - Removed unitofwork.register_attribute, and simpified the _register_attribute methods into a single function in strategies.py. unitofwork exports the UOWEventHandler extension directly. - To accomodate the multiple AttributeImpls across a class hierarchy, the sethasparent() method now uses an optional "parent_token" attribute to identify the "parent". AbstractRelationLoader sends the MapperProperty along to serve as this token. If the token isn't present (which is only the case in the attributes unit tests), the AttributeImpl is used instead, which is essentially the same as the old behavior. - Added new ConcreteInheritedProperty MapperProperty. This is invoked for concrete mappers within _adapt_inherited_property() to accomodate concrete mappers which inherit unhandled attributes from the base class, and basically raises an exception upon access. [ticket:1237] - attributes.register_attribute and register_descriptor will now re-instrument an attribute unconditionally without checking for a previous attribute. Not sure if this is controversial. It's needed so that ConcreteInheritedProperty instrumentation can be overridden by an incoming legit MapperProperty without any complexity. - Added new UninstrumentedColumnLoader LoaderStrategy. This is used by the polymorphic_on argument when the given column is not represented within the mapped selectable, as is typical with a concrete scenario which maps to a polymorphic union. It does not configure class instrumentation, keeping polymorphic_on from getting caught up in the new concrete attribute-checking logic. - RelationProperty now records its "backref" attributes using a set assigned to `_reverse_property` instead of a scalar. The `back_populates` keyword allows any number of properties to be involved in a single bidirectional relation. Changes were needed to RelationProperty.merge(), DependencyProcessor to accomodate for the new multiple nature of this attribute. - Generalized the methodology used by ManyToManyDP to check for "did the other dependency already handle this direction", building on the `_reverse_property` collection. - post_update logic within dependency.py moves to use the same methodology as ManyToManyDP so that "did the other dependency do this already" checks are made to be specific to the two dependent instances. - Caught that RelationProperty.merge() was writing to instance.__dict__ directly (!) - repaired to talk to instance_state.dict. - Removed needless eager loading example from concrete mapper docs. - Added test for [ticket:965]. - Added the usual Node class/nodes table to orm/_fixtures.py, but haven't used it for anything yet. We can potentially update test/orm/query.py to use this fixture. - Other test/documentation cleanup.
* - query.order_by() accepts None which will remove any pendingMike Bayer2009-01-031-11/+14
| | | | | | | order_by state from the query, as well as cancel out any mapper/relation configured ordering. This is primarily useful for overriding the ordering specified on a dynamic_loader(). [ticket:1079]
* Marked mssql test as failing since it cannot update identity columns.Michael Trier2009-01-021-5/+8
|
* - Custom comparator classes used in conjunction withMike Bayer2009-01-021-0/+43
| | | | | | | | | | column_property(), relation() etc. can define new comparison methods on the Comparator, which will become available via __getattr__() on the InstrumentedAttribute. In the case of synonym() or comparable_property(), attributes are resolved first on the user-defined descriptor, then on the user-defined comparator.
* yes ive been watching the IRC channel. restored setup_instance() to ↵Mike Bayer2008-12-311-1/+16
| | | | ClassManager and added coverage for mapper's usage of it.
* - Can pass mapped attributes and column objects as keysMike Bayer2008-12-281-0/+15
| | | | | | | | | to query.update({}). [ticket:1262] - Mapped attributes passed to the values() of an expression level insert() or update() will use the keys of the mapped columns, not that of the mapped attribute.
* - Exceptions raised during compile_mappers() are nowMike Bayer2008-12-241-1/+9
| | | | | | | | | preserved to provide "sticky behavior" - if a hasattr() call on a pre-compiled mapped attribute triggers a failing compile and suppresses the exception, subsequent compilation is blocked and the exception will be reiterated on the next compile() call. This issue occurs frequently when using declarative.
* *most* py3k warnings are resolved, with the exception of the various ↵Mike Bayer2008-12-181-0/+12
| | | | | | __setslice__ related warnings I don't really know how to get rid of
* - Query() can be passed a "composite" attributeMike Bayer2008-12-181-0/+3
| | | | | | | | | | | | | | | | | | | | | | | as a column expression and it will be expanded. Somewhat related to [ticket:1253]. - Query() is a little more robust when passed various column expressions such as strings, clauselists, text() constructs (which may mean it just raises an error more nicely). - select() can accept a ClauseList as a column in the same way as a Table or other selectable and the interior expressions will be used as column elements. [ticket:1253] - removed erroneous FooTest from test/orm/query -This line, and those below, will be ignored-- M test/orm/query.py M test/orm/mapper.py M test/sql/select.py M lib/sqlalchemy/orm/query.py M lib/sqlalchemy/sql/expression.py M CHANGES
* Modified fails_on testing decorator to take a reason for the failure.Michael Trier2008-12-121-4/+4
| | | | | This should assist with helping to document the reasons for testing failures. Currently unspecified failures are defaulted to 'FIXME: unknown'.
* - PickleType now favors == comparison by default,Mike Bayer2008-12-111-38/+0
| | | | | | | if the incoming object (such as a dict) implements __eq__(). If the object does not implement __eq__() and mutable=True, a deprecation warning is raised.
* - reworked the "SQL assertion" code to something more flexible and based off ↵Mike Bayer2008-12-101-8/+8
| | | | | | of ConnectionProxy. upcoming changes to dependency.py will make use of the enhanced flexibility.
* - Improved mapper() check for non-class classes.Mike Bayer2008-12-011-0/+2
| | | | [ticket:1236]
* - comparator_factory is accepted by all MapperProperty constructors. ↵Mike Bayer2008-11-241-4/+78
| | | | | | | | | | | | [ticket:1149] - added other unit tests as per [ticket:1149] - rewrote most of the "joined table inheritance" documentation section, removed badly out of date "polymorphic_fetch" and "select_table" arguments. - "select_table" raises a deprecation warning. converted unit tests to not use it. - removed all references to "ORDER BY table.oid" from mapping docs. - renamed PropertyLoader to RelationProperty. Old symbol remains. - renamed ColumnProperty.ColumnComparator to ColumnProperty.Comparator. Old symbol remains.
* - Fixed bug in composite types which prevented a primary-keyMike Bayer2008-11-051-0/+7
| | | | composite type from being mutated [ticket:1213].
* - 0.5.0rc3, dohMike Bayer2008-10-181-7/+7
| | | | | | | | | | | | - The internal notion of an "OID" or "ROWID" column has been removed. It's basically not used by any dialect, and the possibility of its usage with psycopg2's cursor.lastrowid is basically gone now that INSERT..RETURNING is available. - Removed "default_order_by()" method on all FromClause objects. - profile/compile/select test is 8 function calls over on buildbot 2.4 for some reason, will adjust after checking the results of this commit
* - column_property(), composite_property(), and relation() nowMike Bayer2008-09-021-1/+43
| | | | | | | | | | accept a single or list of AttributeExtensions using the "extension" keyword argument. - Added a Validator AttributeExtension, as well as a @validates decorator which is used in a similar fashion as @reconstructor, and marks a method as validating one or more mapped attributes. - removed validate_attributes example, the new methodology replaces it
* - starargs_as_list was not actually issuing SAPendingDeprecationWarning, fixedMike Bayer2008-08-281-16/+3
| | | | - implemented code cleanup from [ticket:1152] but not including using the decorators module
* - Fixed bug whereby deferred() columns with a group in conjunctionMike Bayer2008-08-281-0/+11
| | | | | with an otherwise unrelated synonym() would produce an AttributeError during deferred load.
* - Another old-style mixin fix and an explicit mapper() test for it.Jason Kirtland2008-08-211-2/+20
|
* temporary check for unmapped class, until [ticket:1142] is resolvedMike Bayer2008-08-171-0/+11
|
* - Renamed on_reconstitute to @reconstructor and reconstruct_instanceJason Kirtland2008-08-151-9/+80
| | | | | - Moved @reconstructor hooking to mapper - Expanded reconstructor tests, docs
* - The composite() property type now supportsMike Bayer2008-08-111-3/+138
| | | | | | | | | | a __set_composite_values__() method on the composite class which is required if the class represents state using attribute names other than the column's keynames; default-generated values now get populated properly upon flush. Also, composites with attributes set to None compare correctly. [ticket:1132]
* - The "entity_name" feature of SQLAlchemy mappersMike Bayer2008-08-021-37/+0
| | | | | has been removed. For rationale, see http://groups.google.com/group/sqlalchemy/browse_thread/thread/9e23a0641a88b96d?hl=en
* - An inheriting class can now override an attributeMike Bayer2008-07-201-2/+19
| | | | | | inherited from the base class with a plain descriptor, or exclude an inherited attribute via the include_properties/exclude_properties collections.
* - Removed 2.3 set emulations/enhancements.Jason Kirtland2008-07-151-1/+0
| | | | (sets.Set-based collections & DB-API returns still work.)
* - The "allow_column_override" flag from mapper() hasrel_0_5beta2Mike Bayer2008-07-141-3/+6
| | | | | | been removed. This flag is virtually always misunderstood. Its specific functionality is available via the include_properties/exclude_properties mapper arguments.
* `session.Query().iterate_instances()` has been renamed to just ↵Gaëtan de Menten2008-06-251-2/+2
| | | | | | `instances()`. The old `instances()` method returning a list instead of an iterator no longer exists. If you were relying on that behavior, you should use `list(your_query.instances())`.
* - implemented [ticket:887], refresh readonly props upon saveMike Bayer2008-06-211-2/+2
| | | | | | | | - moved up "eager_defaults" active refresh step (this is an option used by just one user pretty much) to be per-instance instead of per-table - fixed table defs from previous deferred attributes enhancement - CompositeColumnLoader equality comparison fixed for a/b == None; I suspect the composite capability in SA needs a lot more work than this
* - In addition to expired attributes, deferred attributesMike Bayer2008-06-211-1/+84
| | | | | also load if their data is present in the result set [ticket:870]
* - Query.UpdateDeleteTest.test_delete_fallback fails on mysql due to subquery ↵Mike Bayer2008-06-091-53/+19
| | | | | | | | | | | | | | | | | in DELETE; not sure how to do this exact operation in MySQL - added query_cls keyword argument to sessionmaker(); allows user-defined Query subclasses to be generated by query(). - added @attributes.on_reconstitute decorator, MapperExtension.on_reconstitute, both receieve 'on_load' attribute event allowing non-__init__ dependent instance initialization routines. - push memusage to the top to avoid pointless heisenbugs - renamed '_foostate'/'_fooclass_manager' to '_sa_instance_state'/'_sa_class_manager' - removed legacy instance ORM state accessors - query._get() will use _remove_newly_deleted instead of expunge() on ObjectDeleted, so that transaction rollback restores the previous state - removed MapperExtension.get(); replaced by a user-defined Query subclass - removed needless **kwargs from query.get() - removed Session.get(cls, id); this is redundant against Session.query(cls).get(id) - removed Query.load() and Session.load(); the use case for this method has never been clear, and the same functionality is available in more explicit ways
* fixes for PG, MysqlMike Bayer2008-05-141-3/+4
|
* - fixed propagation of operate() for aliased relation descriptorsMike Bayer2008-05-131-1/+1
| | | | - ColumnEntity gets a selectable
* - Reworked test/orm/mapperJason Kirtland2008-05-131-800/+937
| | | | | - Exposed some uncovered (and broken) functionality - Fixed [ticket:1038]
* Added explicit sequences on a few primary keys and minor fixes wrt FirebirdLele Gaifax2008-05-121-11/+10
|
* - fixed a fairly critical bug in clause adaption/corresponding column in ↵Mike Bayer2008-05-091-31/+30
| | | | | | | conjunction with annotations - implicit order by is removed, modified many tests to explicitly set ordering, probably many more to go once it hits the buildbot.
* Test suite modernization in progress. Big changes:Jason Kirtland2008-05-091-2/+2
| | | | | | | | | | | - @unsupported now only accepts a single target and demands a reason for not running the test. - @exclude also demands an exclusion reason - Greatly expanded @testing.requires.<feature>, eliminating many decorators in the suite and signficantly easing integration of multi-driver support. - New ORM test base class, and a featureful base for mapped tests - Usage of 'global' for shared setup going away, * imports as well
* r4695 merged to trunk; trunk now becomes 0.5.Mike Bayer2008-05-091-122/+242
| | | | 0.4 development continues at /sqlalchemy/branches/rel_0_4
* - fixed reentrant mapper compile hang whenMike Bayer2008-05-021-5/+5
| | | | | a declared attribute is used within ForeignKey, ie. ForeignKey(MyOtherClass.someattribute)
* - refined mapper._save_obj() which was unnecessarily callingMike Bayer2008-04-261-11/+36
| | | | __ne__() on scalar values during flush [ticket:1015]
* - restored usage of append_result() extension method for primaryMike Bayer2008-04-181-6/+11
| | | | | query rows, when the extension is present and only a single- entity result is being returned.