summaryrefslogtreecommitdiff
path: root/test/orm/attributes.py
Commit message (Collapse)AuthorAgeFilesLines
* - unit tests have been migrated from unittest to nose.Mike Bayer2009-06-101-1331/+0
| | | | | See README.unittests for information on how to run the tests. [ticket:970]
* - Fixed another 0.5.4 bug whereby mutable attributes (i.e. PickleType)Mike Bayer2009-06-011-2/+4
| | | | | wouldn't be deserialized correctly when the whole object was serialized. [ticket:1426]
* - Significant performance enhancements regarding Sessions/flush()Mike Bayer2009-05-171-38/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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().
* merge the test/ directory from -r5438:5439 of py3k_warnings branch. this givesMike Bayer2008-12-181-0/+2
| | | | us a 2.5-frozen copy of unittest so we're insulated from unittest changes.
* - Duplicate items in a list-based collection willMike Bayer2008-11-251-0/+13
| | | | | | | | | | | | | be maintained when issuing INSERTs to a "secondary" table in a many-to-many relation. Assuming the m2m table has a unique or primary key constraint on it, this will raise the expected constraint violation instead of silently dropping the duplicate entries. Note that the old behavior remains for a one-to-many relation since collection entries in that case don't result in INSERT statements and SQLA doesn't manually police collections. [ticket:1232]
* - Adjustments to the enhanced garbage collection onMike Bayer2008-11-111-1/+18
| | | | | InstanceState to better guard against errors due to lost state.
* - AttributeListener has been refined such that the eventMike Bayer2008-09-021-0/+42
| | | | | | | | | | | | is fired before the mutation actually occurs. Addtionally, the append() and set() methods must now return the given value, which is used as the value to be used in the mutation operation. This allows creation of validating AttributeListeners which raise before the action actually occurs, and which can change the given value into something else before its used. A new example "validate_attributes.py" shows one such recipe for doing this. AttributeListener helper functions are also on the way.
* - Fixed bug whereby changing a primary key attribute on anMike Bayer2008-08-241-1/+39
| | | | | entity where the attribute's previous value had been expired would produce an error upon flush(). [ticket:1151]
* attributes.get_history now reports some zero-length slots as the empty tuple ↵Jason Kirtland2008-08-181-73/+73
| | | | rather than an empty list. nice speed boost and memory reduction.
* - Query.UpdateDeleteTest.test_delete_fallback fails on mysql due to subquery ↵Mike Bayer2008-06-091-2/+0
| | | | | | | | | | | | | | | | | 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
* Test suite modernization in progress. Big changes:Jason Kirtland2008-05-091-169/+170
| | | | | | | | | | | - @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
* identified case where pending upon commit() is needed; since attribute ↵Mike Bayer2008-05-091-0/+13
| | | | rollback functionality is gone its safe to revert to this
* r4695 merged to trunk; trunk now becomes 0.5.Mike Bayer2008-05-091-168/+258
| | | | 0.4 development continues at /sqlalchemy/branches/rel_0_4
* - Raise a friendly error when assigning an unmapped something (like a ↵Jason Kirtland2008-03-021-18/+32
| | | | string) to a scalar-object attribute
* - the value of a bindparam() can be a callable, in whichMike Bayer2008-02-221-0/+20
| | | | | | | | | | | | | | | | case it's evaluated at statement execution time to get the value. - 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==<somechild>)), evaluate the actual primary key value of <somechild> at execution time so that the autoflush step of the Query can complete, thereby populating the PK value of <somechild> in the case that <somechild> was pending. - cleanup of attributes.get_committed_value() to never return the NO_VALUE value; evaluates to None
* - updated the naming scheme of the base test classes in test/testlib/testing.py;Mike Bayer2008-02-111-4/+4
| | | | | tests extend from either TestBase or ORMTest, using additional mixins for special assertion methods as needed
* - testbase is gone, replaced by testenvJason Kirtland2008-01-121-96/+96
| | | | | | - Importing testenv has no side effects- explicit functions provide similar behavior to the old immediate behavior of testbase - testing.db has the configured db - Fixed up the perf/* scripts
* - fixed an attribute history bug whereby assigning a new collectionMike Bayer2008-01-071-8/+23
| | | | | | | | | | | to a collection-based attribute which already had pending changes would generate incorrect history [ticket:922] - fixed delete-orphan cascade bug whereby setting the same object twice to a scalar attribute could log it as an orphan [ticket:925] - generative select.order_by(None) / group_by(None) was not managing to reset order by/group by criterion, fixed [ticket:924]
* - fixed fairly critical bug whereby the same instance could be listedMike Bayer2008-01-051-0/+19
| | | | | | | 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
* - reworked all lazy/deferred/expired callables to beMike Bayer2007-12-211-1/+59
| | | | | | | | serializable class instances, added pickling tests - cleaned up "deferred" polymorphic system so that the mapper handles it entirely - columns which are missing from a Query's select statement now get automatically deferred during load.
* - select().as_scalar() will raise an exception if the select does not haveMike Bayer2007-12-181-1/+49
| | | | | | | | | | | | exactly one expression in its columns clause. - added "helper exception" to select.type access, generic functions raise the chance of this happening - a slight behavioral change to attributes is, del'ing an attribute does *not* cause the lazyloader of that attribute to fire off again; the "del" makes the effective value of the attribute "None". To re-trigger the "loader" for an attribute, use session.expire(instance, [attrname]). - fix ormtutorial for IS NULL
* fixed del historyMike Bayer2007-12-161-0/+6
|
* oof, history on collections were wrong. fixed byroot_tree test as wellMike Bayer2007-12-141-0/+30
|
* - simplified _mapper_registry further. its now just a weakkeydict of ↵Mike Bayer2007-12-141-11/+116
| | | | | | | | | | mapper->True, stores all mappers including non primaries, and is strictly used for the list of "to compile/dispose". - all global references are now weak referencing. if you del a mapped class and any dependent classes, its mapper and all dependencies fall out of scope. - attributes.py still had issues which were barely covered by tests. added way more tests (coverage.py still says 71%, doh) fixed things, took out unnecessary commit to states. attribute history is also asserted for ordering.
* - merged instances_yields branch r3908:3934, minus the "yield" part which ↵Mike Bayer2007-12-141-50/+304
| | | | | | | | | | | | | remains slightly problematic - cleanup of mapper._instance, query.instances(). mapper identifies objects which are part of the current load using a app-unique id on the query context. - attributes refactor; attributes now mostly use copy-on-modify instead of copy-on-load behavior, simplified get_history(), added a new set of tests - fixes to OrderedSet such that difference(), intersection() and others can accept an iterator - OrderedIdentitySet passes in OrderedSet to the IdentitySet superclass for usage in difference/intersection/etc. operations so that these methods actually work with ordering behavior. - query.order_by() takes into account aliased joins, i.e. query.join('orders', aliased=True).order_by(Order.id) - cleanup etc.
* - flush() refactor merged from uow_nontree branch r3871-r3885Mike Bayer2007-12-081-11/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - topological.py cleaned up, presents three public facing functions which return list/tuple based structures, without exposing any internals. only the third function returns the "hierarchical" structure. when results include "cycles" or "child" items, 2- or 3- tuples are used to represent results. - unitofwork uses InstanceState almost exclusively now. new and deleted lists are now dicts which ref the actual object to provide a strong ref for the duration that they're in those lists. IdentitySet is only used for the public facing versions of "new" and "deleted". - unitofwork topological sort no longer uses the "hierarchical" version of the sort for the base sort, only for the "per-object" secondary sort where it still helps to group non-dependent operations together and provides expected insert order. the default sort deals with UOWTasks in a straight list and is greatly simplified. Tests all pass but need to see if svilen's stuff still works, one block of code in _sort_cyclical_dependencies() seems to not be needed anywhere but i definitely put it there for a reason at some point; if not hopefully we can derive more test coverage from that. - the UOWEventHandler is only applied to object-storing attributes, not scalar (i.e. column-based) ones. cuts out a ton of overhead when setting non-object based attributes. - InstanceState also used throughout the flush process, i.e. dependency.py, mapper.save_obj()/delete_obj(), sync.execute() all expect InstanceState objects in most cases now. - mapper/property cascade_iterator() takes InstanceState as its argument, but still returns lists of object instances so that they are not dereferenced. - a few tricks needed when dealing with InstanceState, i.e. when loading a list of items that are possibly fresh from the DB, you *have* to get the actual objects into a strong-referencing datastructure else they fall out of scope immediately. dependency.py caches lists of dependent objects which it loads now (i.e. history collections). - AttributeHistory is gone, replaced by a function that returns a 3-tuple of added, unchanged, deleted. these collections still reference the object instances directly for the strong-referencing reasons mentiontioned, but it uses less IdentitySet logic to generate.
* - a major behavioral change to collection-based backrefs: they noMike Bayer2007-12-051-74/+168
| | | | | | | | | | longer trigger lazy loads ! "reverse" adds and removes are queued up and are merged with the collection when it is actually read from and loaded; but do not trigger a load beforehand. For users who have noticed this behavior, this should be much more convenient than using dynamic relations in some cases; for those who have not, you might notice your apps using a lot fewer queries than before in some situations. [ticket:871]
* - fixed backref bug where you could not del instance.attr if attrMike Bayer2007-12-041-0/+4
| | | | was None
* AttributeManager class and "cached" state removed....attribute listingMike Bayer2007-11-271-94/+98
| | | | is tracked from _sa_attrs class collection
* - session.refresh() and session.expire() now support an additional argumentMike Bayer2007-11-181-18/+22
| | | | | | | | | | | | | | "attribute_names", a list of individual attribute keynames to be refreshed or expired, allowing partial reloads of attributes on an already-loaded instance. - finally simplified the behavior of deferred attributes, deferred polymorphic load, session.refresh, session.expire, mapper._postfetch to all use a single codepath through query._get(), which now supports a list of individual attribute names to be refreshed. the *one* exception still remaining is mapper._get_poly_select_loader(), which may stay that way since its inline with an already processing load operation. otherwise, query._get() is the single place that all "load this instance's row" operation proceeds. - cleanup all over the place
* - split ScalarInstrumentedAttribute into a "scalar" and an "object" version.Mike Bayer2007-10-311-38/+38
| | | | | | | | | | | The "object" version loads the existing value on set/del, fires events, and handles trackparent operations; the "scalar" version does not. - column loaders now use the "scalar" version of InstrumentedAttribute, so that event handlers etc. don't fire off for regular column attribute operations. - some adjustments to AttributeHistory to work properly for non-loaded attributes - deferred column attributes no longer trigger a load operation when the attribute is assigned to. in those cases, the newly assigned value will be present in the flushes' UPDATE statement unconditionally.
* - merged sa_entity branch. the big change here is the attributes systemMike Bayer2007-09-221-11/+11
| | | | | | | | deals primarily with the InstanceState and almost never with the instrumented object directly. This reduces lookups and complexity since we need the state for just about everything, now its the one place for everything internally. we also merged the new weak referencing identity map, which will go out in beta6 and we'll see how that goes !
* merged current entity_management brach r3457-r3462. cleans upMike Bayer2007-09-051-17/+44
| | | | | | | | '_state' mamangement in attributes, moves __init__() instrumntation into attributes.py, and reduces method call overhead by removing '_state' property. future enhancements may include _state maintaining a weakref to the instance and a strong ref to its __dict__ so that garbage-collected instances can get added to 'dirty', when weak-referenced identity map is used.
* -fixed [ticket:555]Mike Bayer2007-07-291-5/+5
| | | | - fixed attribute glitch breaking the build
* merging 0.4 branch to trunk. see CHANGES for details. 0.3 moves to ↵Mike Bayer2007-07-271-33/+71
| | | | maintenance branch in branches/rel_0_3.
* - improved/fixed custom collection classes when giving it "set"/Mike Bayer2007-03-261-2/+46
| | | | | | | "sets.Set" classes or subclasses (was still looking for append() methods on them during lazy loads) - moved CustomCollectionsTest from unitofwork to relationships - added more custom collections test to attributes module
* - attributes module and test suite moves underneath 'orm' packageMike Bayer2006-10-221-0/+333
- fixed table comparison example in metadata.txt - docstrings all over the place - renamed mapper _getattrbycolumn/_setattrbycolumn to get_attr_by_column,set_attr_by_column - removed frommapper parameter from populate_instance(). the two operations can be performed separately - fix to examples/adjacencytree/byroot_tree.py to fire off lazy loaders upon load, to reduce query calling - added get(), get_by(), load() to MapperExtension - re-implemented ExtensionOption (called by extension() function) - redid _ExtensionCarrier to function dynamically based on __getattribute__ - added logging to attributes package, indicating the execution of a lazy callable - going to close [ticket:329]