summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/dependency.py
Commit message (Collapse)AuthorAgeFilesLines
...
* | working through cycles tests...Mike Bayer2010-04-011-33/+43
| |
* | many-to-one completed for self-referentialMike Bayer2010-04-011-14/+15
| |
* | refactor dependency elementsMike Bayer2010-04-011-87/+99
| |
* | this version passes one to many tests so farMike Bayer2010-04-011-50/+48
| |
* | self-referential working to a small degreeMike Bayer2010-04-011-12/+11
| |
* | one more ruleMike Bayer2010-04-011-1/+2
| |
* | beginning to address cycles but its not worked out yetMike Bayer2010-03-311-6/+69
| |
* | deletes, rudimentary many-to-onesMike Bayer2010-03-311-119/+114
| |
* | its alive !Mike Bayer2010-03-311-100/+92
| |
* | This is turning out to be a rewrite of the accounting system of ↵Mike Bayer2010-03-301-10/+34
| | | | | | | | | | | | | | unitofwork.py, but the overarching method of doing things stays the same. it should be easy to add new dependencies between actions and to change the structure of how things are done.
* | start sketching ideas for a rewritten unit of work.Mike Bayer2010-03-191-1/+2
|/ | | | | | | | | | the basic idea is to bring topological back down to the raw function, then the whole UOW constructs itself as very fine grained elements with full dependencies to each other. then a straight execute with a straight sort. the hope is that the mechanism here would be vastly simpler. while the presence of a large number of fine-grained records may be expensive it still is potentially a lot easier to distill into C code, as the uow's structure now consists of data.
* - The official name for the relation() function is nowMike Bayer2010-03-171-6/+6
| | | | | | relationship(), to eliminate confusion over the relational algebra term. relation() however will remain available in equal capacity for the foreseeable future. [ticket:1740]
* - Fixed cascade bug in many-to-one relation() when attributeMike Bayer2010-02-161-8/+14
| | | | | was set to None, introduced in r6711 (cascade deleted items into session during add()).
* - Primary key values can now be changed on a joined-table inheritanceMike Bayer2010-02-021-7/+18
| | | | | | | | | | | | object, and ON UPDATE CASCADE will be taken into account when the flush happens. Set the new "passive_updates" flag to False on mapper() when using SQLite or MySQL/MyISAM. [ticket:1362] - flush() now detects when a primary key column was updated by an ON UPDATE CASCADE operation from another primary key, and can then locate the row for a subsequent UPDATE on the new PK value. This occurs when a relation() is there to establish the relationship as well as passive_updates=True. [ticket:1671]
* - added a failing-so-far test for #1671Mike Bayer2010-02-011-1/+2
|
* happy new yearMike Bayer2010-01-071-1/+1
|
* - Fixed bug which disallowed one side of a many-to-manyMike Bayer2009-09-011-1/+1
| | | | | bidirectional reference to declare itself as "viewonly" [ticket:1507]
* merge 0.6 series to trunk.Mike Bayer2009-08-061-2/+2
|
* - Removed all* O(N) scanning behavior from the flush() process,Mike Bayer2009-05-171-9/+10
| | | | | | | | | | | i.e. operations that were scanning the full session, including an extremely expensive one that was erroneously assuming primary key values were changing when this was not the case. * one edge case remains which may invoke a full scan, if an existing primary key attribute is modified to a new value.
* - Significant performance enhancements regarding Sessions/flush()Mike Bayer2009-05-171-10/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 which prevented "mutable primary key" dependencyMike Bayer2009-05-081-1/+2
| | | | | | logic from functioning properly on a one-to-one relation(). [ticket:1406] - moved MySQL to use innodb for naturalpks tests
* happy new yearMike Bayer2009-01-121-1/+1
|
* - Concrete inheriting mappers now instrument attributes which are inherited ↵Mike Bayer2009-01-111-46/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* - removed creepy exec call for nowMike Bayer2008-12-061-1/+0
| | | | | - removed unnecessary isinstance() from class_mapper() - removed unnecessary and py3k incompatible "dictionary sort" from association table delete
* - added some abstraction to the attributes.History objectMike Bayer2008-10-281-61/+61
| | | | | - Repaired support for "passive-deletes" on a many-to-one relation() with "delete" cascade. [ticket:1183]
* a much easier way to ArgSingletonMike Bayer2008-10-121-14/+11
|
* - annual unitofwork cleanupMike Bayer2008-09-151-1/+1
| | | | | | | - moved conversion of cyclical sort to UOWTask structure to be non-recursive - reduced some verbosity - rationale for the "tree" sort clarified - would love to flatten all of uow topological sorting, sorting within mapper._save_obj() into a single sort someday
* - starargs_as_list was not actually issuing SAPendingDeprecationWarning, fixedMike Bayer2008-08-281-6/+6
| | | | - implemented code cleanup from [ticket:1152] but not including using the decorators module
* - fixed primary key update for many-to-many collectionsMike Bayer2008-08-161-1/+4
| | | | | where the collection had not been loaded yet [ticket:1127]
* - The "entity_name" feature of SQLAlchemy mappersMike Bayer2008-08-021-1/+1
| | | | | has been removed. For rationale, see http://groups.google.com/group/sqlalchemy/browse_thread/thread/9e23a0641a88b96d?hl=en
* - Removed 2.3 set emulations/enhancements.Jason Kirtland2008-07-151-1/+1
| | | | (sets.Set-based collections & DB-API returns still work.)
* And thus ends support for Python 2.3.Jason Kirtland2008-07-151-2/+2
|
* - merged r4841 from 0.4 branch (enable_typechecks lockdown)Mike Bayer2008-06-121-5/+6
|
* - PropertyLoader.foreign_keys becomes privateMike Bayer2008-05-241-1/+0
| | | | | - removed most __foo() defs from properties.py - complexity reduction in PropertyLoader.do_init()
* r4695 merged to trunk; trunk now becomes 0.5.Mike Bayer2008-05-091-39/+39
| | | | 0.4 development continues at /sqlalchemy/branches/rel_0_4
* - merged sync_simplify branchMike Bayer2008-04-041-28/+34
| | | | | | | | | | | | | | | | - The methodology behind "primaryjoin"/"secondaryjoin" has been refactored. Behavior should be slightly more intelligent, primarily in terms of error messages which have been pared down to be more readable. In a slight number of scenarios it can better resolve the correct foreign key than before. - moved collections unit test from relationships.py to collection.py - PropertyLoader now has "synchronize_pairs" and "equated_pairs" collections which allow easy access to the source/destination parent/child relation between columns (might change names) - factored out ClauseSynchronizer (finally) - added many more tests for priamryjoin/secondaryjoin error checks
* - merged with_polymorphic branch, which was merged with query_columns branchMike Bayer2008-03-291-1/+0
| | | | | | | | | | | | | | | | | - removes everything to do with select_table, which remains as a keyword argument synonymous with with_polymorphic=('*', select_table). - all "polymorphic" selectables find their way to Query by way of _set_select_from() now, so that all joins/aliasing/eager loads/etc. is handled consistently. Mapper has methods for producing polymorphic selectables so that Query and eagerloaders alike can get to them. - row aliasing simplified, so that they don't need to nest. they only need the source selectable and adapt to whatever incoming columns they get. - Query is more egalitarian about mappers/columns now. Still has a strong sense of "entity zero", but also introduces new unpublished/experimental _values() method which sets up a columns-only query. - Query.order_by() and Query.group_by() take *args now (also still take a list, will likely deprecate in 0.5). May want to do this for select() as well. - the existing "check for False discriminiator" "fix" was not working completely, added coverage - orphan detection was broken when the target object was a subclass of the mapper with the orphaned relation, fixed that too.
* some fixup to one-to-many delete cascadeMike Bayer2008-03-181-5/+6
|
* - fixed/added coverage for various cascade scenariosMike Bayer2008-03-181-14/+21
| | | | | - added coverage for some extra cases in dynamic relations - removed some unused methods from unitofwork
* - Fixed a couple pyflakes, cleaned up imports & whitespaceJason Kirtland2008-02-141-35/+34
|
* - next release will be 0.4.3Mike Bayer2008-01-301-2/+2
| | | | | | | | | | - fixed merge() collection-doubling bug when merging transient entities with backref'ed collections. [ticket:961] - 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.
* whups, args in wrong orderMike Bayer2008-01-231-2/+2
|
* more descriptive error message for m2m concurrency errorMike Bayer2008-01-231-2/+2
|
* - Restored 2.3 compat. in lib/sqlalchemyJason Kirtland2008-01-191-1/+1
| | | | | | | - Part one of test suite fixes to run on 2.3 Lots of failures still around sets; sets.Set differs from __builtin__.set particularly in the binops. We depend on set extensively now and may need to provide a corrected sets.Set subclass on 2.3.
* happy new yearMike Bayer2008-01-011-1/+1
|
* - cleanup; lambdas removed from properties; properties mirror same-named ↵Mike Bayer2007-12-181-5/+5
| | | | | | functions (more like eventual decorator syntax); remove some old methods, factor out some "raiseerr" ugliness to outer lying functions. - corresponding_column() integrates "require_embedded" flag with other set arithmetic
* - simplified _mapper_registry further. its now just a weakkeydict of ↵Mike Bayer2007-12-141-1/+1
| | | | | | | | | | 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.
* - mutable primary key support is added. primary key columns can beMike Bayer2007-12-091-41/+94
| | | | | | | | | changed freely, and the identity of the instance will change upon flush. In addition, update cascades of foreign key referents (primary key or not) along relations are supported, either in tandem with the database's ON UPDATE CASCADE (required for DB's like Postgres) or issued directly by the ORM in the form of UPDATE statements, by setting the flag "passive_cascades=False".
* - flush() refactor merged from uow_nontree branch r3871-r3885Mike Bayer2007-12-081-121/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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.
* - several ORM attributes have been removed or made private:Mike Bayer2007-12-011-5/+5
| | | | | | | | mapper.get_attr_by_column(), mapper.set_attr_by_column(), mapper.pks_by_table, mapper.cascade_callable(), MapperProperty.cascade_callable(), mapper.canload() - refinements to mapper PK/table column organization, session cascading, some naming convention work