summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/strategies.py
Commit message (Collapse)AuthorAgeFilesLines
* dial back the default "flatness" a bit, it will be there for joinedload and ↵Mike Bayer2013-06-061-2/+10
| | | | | | | query.join(), but if you're dealing with aliased() or with_polymorphic() you need to say "flat=True". Just the one flag though, "flat" implies "aliased".
* - blow away context._attributesMike Bayer2013-06-021-25/+29
| | | | | - to account for query._attributes/context.attributes, just pass the attributes dict directly to the PathRegistry methods
* The "auto-aliasing" behavior of the :class:`.Query.select_from`Mike Bayer2013-05-301-1/+1
| | | | | | method has been turned off. The specific behavior is now availble via a new method :class:`.Query.select_entity_from`. [ticket:2736]
* a pass where we try to squash down as many list()/keys() combinationsMike Bayer2013-05-261-1/+1
| | | | as possible
* - the raw 2to3 runMike Bayer2013-04-271-4/+4
| | | | - went through examples/ and cleaned out excess list() calls
* cleanupMike Bayer2013-04-251-7/+0
|
* - additional test + correction for [ticket:2699]Mike Bayer2013-04-181-4/+5
|
* Fixed bug when a query of the form:Mike Bayer2013-04-091-2/+5
| | | | | | | | | | | ``query(SubClass).options(subqueryload(Baseclass.attrname))``, where ``SubClass`` is a joined inh of ``BaseClass``, would fail to apply the ``JOIN`` inside the subquery on the attribute load, producing a cartesian product. The populated results still tended to be correct as additional rows are just ignored, so this issue may be present as a performance degradation in applications that are otherwise working correctly. [ticket:2699]
* happy new year (see #2645)Diana Clarke2013-01-011-1/+1
|
* - refactor of pathing mechanics, to address #2614, #2617Mike Bayer2012-12-011-40/+43
| | | | | | | | | | | | | | | | | | | - paths now store Mapper + MapperProperty now instead of string key, so that the parent mapper for the property is known, supports same-named properties on multiple subclasses - the Mapper within the path is now always relevant to the property to the right of it. PathRegistry does the translation now, instead of having all the outside users of PathRegistry worry about it, to produce a path that is much more consistent. Paths are now consistent with mappings in all cases. Special logic to get at "with_polymorphic" structures and such added also. - AliasedClass now has two modes, "use_mapper_path" and regular; "use_mapper_path" is for all those situations where we put an AliasedClass in for a plain class internally, and want it to "path" with the plain mapper. - The AliasedInsp is now the first class "entity" for an AliasedClass, and is passed around internally and used as attr._parententity and such. it is the AliasedClass analogue for Mapper.
* Added a new exception to detect the case where twoMike Bayer2012-11-241-2/+17
| | | | | | | | | | | subclasses are being loaded using with_polymorphic(), each subclass contains a relationship attribute of the same name, and eager loading is being applied to one or both. This is an ongoing bug which can't be immediately fixed, so since the results are usually wrong in any case it raises an exception for now. 0.7 has the same issue, so an exception raise here probably means the code was returning the wrong data in 0.7. [ticket:2614]
* just a pep8 pass of lib/sqlalchemy/orm/Diana Clarke2012-11-191-7/+7
|
* just a pep8 pass of lib/sqlalchemy/orm/Diana Clarke2012-11-191-29/+51
|
* - remove old hardcoded rule about chained being limited to certain load typesMike Bayer2012-10-081-1/+1
|
* - fix annotation transfer when producing m2m backref, [ticket:2578]Mike Bayer2012-09-281-1/+1
|
* - [bug] Lazy loads emitted within flush eventsMike Bayer2012-08-191-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | such as before_flush(), before_update(), etc. will now function as they would within non-event code, regarding consideration of the PK/FK values used in the lazy-emitted query. Previously, special flags would be established that would cause lazy loads to load related items based on the "previous" value of the parent PK/FK values specifically when called upon within a flush; the signal to load in this way is now localized to where the unit of work actually needs to load that way. Note that the UOW does sometimes load these collections before the before_update() event is called, so the usage of "passive_updates" or not can affect whether or not a collection will represent the "old" or "new" data, when accessed within a flush event, based on when the lazy load was emitted. The change is backwards incompatible in the exceedingly small chance that user event code depended on the old behavior. [ticket:2350]
* - with InstanceState more public, underscore all its methodsMike Bayer2012-07-181-6/+6
| | | | | that change object state as these aren't intended for public use.
* - totally remove _entity_info and _extended_entity_info, replacing all usageMike Bayer2012-07-161-137/+137
| | | | with inspect()
* - move all of orm to use absolute importsMike Bayer2012-06-231-33/+34
| | | | | | | | - break out key mechanics of loading objects into new "orm.loading" module, removing implementation details from both mapper.py and query.py. is analogous to persistence.py - some other cleanup and old cruft removal
* - [removed] Deprecated identifiers removed:Mike Bayer2012-06-211-3/+0
| | | | | | | | | | | | | | * allow_null_pks mapper() argument (use allow_partial_pks) * _get_col_to_prop() mapper method (use get_property_by_column()) * dont_load argument to Session.merge() (use load=True) * sqlalchemy.orm.shard module (use sqlalchemy.ext.horizontal_shard)
* - [feature] The of_type() construct on attributesMike Bayer2012-06-201-156/+198
| | | | | | | | | | | | | | | | | | | | | | | | now accepts aliased() class constructs as well as with_polymorphic constructs, and works with query.join(), any(), has(), and also eager loaders subqueryload(), joinedload(), contains_eager() [ticket:2438] [ticket:1106] - a rewrite of the query path system to use an object based approach for more succinct usage. the system has been designed carefully to not add an excessive method overhead. - [feature] select() features a correlate_except() method, auto correlates all selectables except those passed. Is needed here for the updated any()/has() functionality. - remove some old cruft from LoaderStrategy, init(),debug_callable() - use a namedtuple for _extended_entity_info. This method should become standard within the orm internals - some tweaks to the memory profile tests, number of runs can be customized to work around pysqlite's very annoying behavior - try to simplify PropertyOption._get_paths(), rename to _process_paths(), returns a single list now. overall works more completely as was needed for of_type() functionality
* - [bug] Fixed bug whereby populate_existingMike Bayer2012-06-161-0/+2
| | | | | | option would not propagate to subquery eager loaders. [ticket:2497]. Also in 0.7.8.
* fix logic here broken by the change for enable_relationship_loadingMike Bayer2012-05-191-4/+8
|
* - [feature] Added utility featureMike Bayer2012-05-171-2/+4
| | | | | | | Session.enable_relationship_loading(), supersedes relationship.load_on_pending. Both features should be avoided, however. [ticket:2372]
* - [bug] Fixed bug whereby subqueryload() fromMike Bayer2012-05-171-1/+7
| | | | | | | a polymorphic mapping to a target would incur a new invocation of the query for each distinct class encountered in the polymorphic result. [ticket:2480]. Also in 0.7.8.
* - [removed] The legacy "mutable" system of theMike Bayer2012-04-231-8/+0
| | | | | | | | | | | | | | 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]
* - re-merge + CHANGESMike Bayer2012-04-231-1/+1
|\
| * make auto-correlation the same for Query & select()Diana Clarke2012-04-021-1/+1
| |
* | - merge attribute flag overhaul for [ticket:2358]Mike Bayer2012-04-231-16/+8
| |
* | - merged #1401 branch from bitbucketMike Bayer2012-04-221-61/+7
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - resolved some serious speed hits I missed, we need to ensure only deannotated columns are used in the local/remote collections and soforth so that hash lookups against mapped columns don't dig into __eq__() - fix some other parity mismatches regarding stuff from [ticket:2453], including finding another case where _deep_annotate() was doing the wrong thing, new tests. - [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]
| * | - move create_lazy_clause() to relationshipsMike Bayer2012-04-011-46/+3
| | | | | | | | | | | | - add foreign, remote annotations to declarative
| * | - move properties to use the new create_joinsMike Bayer2012-02-101-19/+4
| | | | | | | | | | | | - fix up subquery eager loading
| * | - got m2m, local_remote_pairs, etc. workingMike Bayer2012-02-091-0/+4
| |/ | | | | | | | | | | | | | | - using new traversal that returns the product of both sides of a binary, starting to work with (a+b) == (c+d) types of joins. primaryjoins on functions working - annotations working, including reversing local/remote when doing backref
* | - [feature] Added new flag to @validatesMike Bayer2012-04-111-3/+3
|/ | | | | | | | include_removes. When True, collection remove and attribute del events will also be sent to the validation function, which accepts an additional argument "is_remove" when this flag is used.
* - [feature] Added new capability to relationshipMike Bayer2012-01-221-0/+7
| | | | | | | | | | | loader options to allow "default" loader strategies. Pass '*' to any of joinedload(), lazyload(), subqueryload(), or noload() and that becomes the loader strategy used for all relationships, except for those explicitly stated in the Query. Thanks to up-and-coming contributor Kent Bower for an exhaustive and well written test suite ! [ticket:2351]
* fix a callcount issue hereMike Bayer2012-01-221-3/+1
|
* couple more vars not needed outsideMike Bayer2012-01-221-4/+2
|
* - apply the pyflakes stick to strategies.py. In particular, tryMike Bayer2012-01-221-194/+285
| | | | | | | | | | | | to get almost every method to be less than 50 lines. For the relationship loaders this meant finding some decent boundaries to split things up. I find this style a bit unnatural as in some cases we are just doing three things with a handful of variables, why shuffle them between three methods that are entirely dependent on each other, but not sure what other option there is for a long list of steps like subquery loading. Also renamed all the "loader callables" to something descriptive, might help when they come up in stack traces.
* happy new yearMike Bayer2012-01-041-1/+1
|
* - attribute system gets a pop() method.Mike Bayer2011-10-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - remove() on a scalar object will raise if the object removed is not what was present. - InstanceState can be pickled if obj() is None; this to support the other changes in this commit - only use trackparent flag on attributes if single_parent or ONETOMANY; otherwise we can skip this overhead - attribute hasparent()/sethasparent() check that trackparent is set, else their usage is invalid - [bug] Fixed backref behavior when "popping" the value off of a many-to-one in response to a removal from a stale one-to-many - the operation is skipped, since the many-to-one has since been updated. [ticket:2315] - [bug] After some years of not doing this, added more granularity to the "is X a parent of Y" functionality, which is used when determining if the FK on "Y" needs to be "nulled out" as well as if "Y" should be deleted with delete-orphan cascade. The test now takes into account the Python identity of the parent as well its identity key, to see if the last known parent of Y is definitely X. If a decision can't be made, a StaleDataError is raised. The conditions where this error is raised are fairly rare, requiring that the previous parent was garbage collected, and previously could very well inappropriately update/delete a record that's since moved onto a new parent, though there may be some cases where "silent success" occurred previously that will now raise in the face of ambiguity. Expiring "Y" resets the "parent" tracker, meaning X.remove(Y) could then end up deleting Y even if X is stale, but this is the same behavior as before; it's advised to expire X also in that case. [ticket:2264]
* - Fixed bug whereby mapper.order_by attribute wouldMike Bayer2011-09-281-0/+4
| | | | | | be ignored in the "inner" query within a subquery eager load. [ticket:2287]. Also in 0.6.9.
* - Load of a deferred() attribute on an objectMike Bayer2011-07-311-2/+4
| | | | | | | | | where row can't be located raises ObjectDeletedError instead of failing later on; improved the message in ObjectDeletedError to include other conditions besides a simple "delete". [ticket:2191] - break up test_get_refreshes() in test_expire
* - Added public attribute ".validators" toMike Bayer2011-07-301-2/+2
| | | | | | | Mapper, an immutable dictionary view of all attributes that have been decorated with the @validates decorator. [ticket:2240] courtesy Stefano Fontanelli
* - Fixed regression from 0.6 where a get historyMike Bayer2011-07-201-0/+2
| | | | | | | | operation on some relationship() based attributes would fail when a lazyload would emit; this could trigger within a flush() under certain conditions. [ticket:2224] Thanks to the user who submitted the great test for this.
* - Feature enhancement: joined and subqueryMike Bayer2011-07-171-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | loading will now traverse already-present related objects and collections in search of unpopulated attributes throughout the scope of the eager load being defined, so that the eager loading that is specified via mappings or query options unconditionally takes place for the full depth, populating whatever is not already populated. Previously, this traversal would stop if a related object or collection were already present leading to inconsistent behavior (though would save on loads/cycles for an already-loaded graph). For a subqueryload, this means that the additional SELECT statements emitted by subqueryload will invoke unconditionally, no matter how much of the existing graph is already present (hence the controversy). The previous behavior of "stopping" is still in effect when a query is the result of an attribute-initiated lazyload, as otherwise an "N+1" style of collection iteration can become needlessly expensive when the same related object is encountered repeatedly. There's also an as-yet-not-public generative Query method _with_invoke_all_eagers() which selects old/new behavior [ticket:2213]
* - The join condition produced by with_parentMike Bayer2011-07-061-21/+30
| | | | | | | | as well as when using a "dynamic" relationship against a parent will generate unique bindparams, rather than incorrectly repeating the same bindparam. [ticket:2207]. Also in 0.6.9.
* - rename EagerLoader to JoinedLoaderMike Bayer2011-06-231-4/+7
|
* - "delete-orphan" cascade is now allowed onMike Bayer2011-06-041-1/+0
| | | | | | | | | | self-referential relationships - this since SQLA 0.7 no longer enforces "parent with no child" at the ORM level; this check is left up to foreign key nullability. Related to [ticket:1912] - a lot of cleanup and refactoring on relationship() init, clarification
* - remove the old term 'selectcontext'Mike Bayer2011-05-311-14/+23
| | | | - don't swing the GOF hammer so hard
* remove erroneously committed pdbMike Bayer2011-04-201-2/+0
|