summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/attributes.py
Commit message (Collapse)AuthorAgeFilesLines
* A performance fix related to the usage of the :func:`.defer` optionMike Bayer2013-07-131-1/+1
| | | | | | | | | | | | | when loading mapped entities. The function overhead of applying a per-object deferred callable to an instance at load time was significantly higher than that of just loading the data from the row (note that ``defer()`` is meant to reduce DB/network overhead, not necessarily function call count); the function call overhead is now less than that of loading data from the column in all cases. There is also a reduction in the number of "lazy callable" objects created per load from N (total deferred values in the result) to 1 (total number of deferred cols). [ticket:2778]
* Fixed bug whereby attribute history functions would failMike Bayer2013-07-041-2/+2
| | | | | | | when an object we moved from "persistent" to "pending" using the :func:`.make_transient` function, for operations involving collection-based backrefs. [ticket:2773]
* A meaningful :attr:`.QueryableAttribute.info` attribute isMike Bayer2013-03-091-0/+43
| | | | | | | | added, which proxies down to the ``.info`` attribute on either the :class:`.schema.Column` object if directly present, or the :class:`.MapperProperty` otherwise. The full behavior is documented and ensured by tests to remain stable. [ticket:2675]
* yikes, print statement !Mike Bayer2013-03-031-3/+2
|
* - Improved checking for an existing backref name conflict duringMike Bayer2013-03-031-6/+18
| | | | | | | | | | | | | | | | | | | | mapper configuration; will now test for name conflicts on superclasses and subclasses, in addition to the current mapper, as these conflicts break things just as much. This is new for 0.8, but see below for a warning that will also be triggered in 0.7.11. - Improved the error message emitted when a "backref loop" is detected, that is when an attribute event triggers a bidirectional assignment between two other attributes with no end. This condition can occur not just when an object of the wrong type is assigned, but also when an attribute is mis-configured to backref into an existing backref pair. Also in 0.7.11. - A warning is emitted when a MapperProperty is assigned to a mapper that replaces an existing property, if the properties in question aren't plain column-based properties. Replacement of relationship properties is rarely (ever?) what is intended and usually refers to a mapper mis-configuration. Also in 0.7.11. [ticket:2674]
* typoMike Bayer2013-02-261-1/+1
|
* happy new year (see #2645)Diana Clarke2013-01-011-1/+1
|
* Extended the :doc:`/core/inspection` system so that all Python descriptorsMike Bayer2012-12-291-2/+24
| | | | | | | | associated with the ORM or its extensions can be retrieved. This fulfills the common request of being able to inspect all :class:`.QueryableAttribute` descriptors in addition to extension types such as :class:`.hybrid_property` and :class:`.AssociationProxy`. See :attr:`.Mapper.all_orm_descriptors`.
* - add tests to ensure SELECT of dynamic collection not emittedMike Bayer2012-12-221-1/+0
| | | | | | on regular append/remove history - fix the real cause of the original #2637 issue, backrefs call upon the "pop()" method now which wasn't implemented for Dynamic
* just a pep8 pass of lib/sqlalchemy/orm/Diana Clarke2012-11-191-14/+30
|
* - add class_ to AliasedInspMike Bayer2012-10-261-2/+19
| | | | | | - redefine inspect(Class.attrname).parent to be always an inspectable target; either Mapper or AliasedInsp - add most major features to 08 migration, document, link
* - some naming changes on PropComparator, Comparator:Mike Bayer2012-10-251-5/+14
| | | | | | | | | | | | | 1. all Comparators now have "parent" which is always the parent mapper or AliasedClass instance 2. only RelationshipProperty.Comparator has "mapper" now, which is the target mapper 3. The names "parententity" and "parentmapper" are underscored also improved the message with the "neither comparator nor instruentedattribute...." to include the classname + attribute name
* - fix regression from 0.7 where calling get_history with passiveMike Bayer2012-10-221-0/+4
| | | | | | | on a never-set collection would fail; made this act just like scalars for now and added tests. I would think that HISTORY_BLANK would be more appropriate here but it's too late in the game to mess with that.
* - [feature] Conflicts between columns onMike Bayer2012-08-271-1/+3
| | | | | | | single-inheritance declarative subclasses, with or without using a mixin, can be resolved using a new @declared_attr usage described in the documentation. [ticket:2472]
* - [bug] Lazy loads emitted within flush eventsMike Bayer2012-08-191-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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]
* - [feature] Adding/removing None from a mapped collectionMike Bayer2012-08-131-1/+3
| | | | | | | | | | | now generates attribute events. Previously, a None append would be ignored in some cases. Related to [ticket:2229]. - [feature] The presence of None in a mapped collection now raises an error during flush. Previously, None values in collections would be silently ignored. [ticket:2229]
* - [bug] Fixed bug whereby user error in related-objectMike Bayer2012-08-121-18/+38
| | | | | | | | assignment could cause recursion overflow if the assignment triggered a backref of the same name as a bi-directional attribute on the incorrect class to the same target. An informative error is raised now.
* - [feature] A warning is emitted when a referenceMike Bayer2012-08-041-0/+7
| | | | | | | | | to an instrumented collection is no longer associated with the parent class due to expiration/attribute refresh/collection replacement, but an append or remove operation is received on the now-detached collection. [ticket:2476]
* - [feature] ORM entities can be passedMike Bayer2012-07-231-5/+8
| | | | | | | to select() as well as the select_from(), correlate(), and correlate_except() methods, where they will be unwrapped into selectables. [ticket:2245]
* a lot of docsMike Bayer2012-07-181-20/+28
|
* - with InstanceState more public, underscore all its methodsMike Bayer2012-07-181-2/+2
| | | | | that change object state as these aren't intended for public use.
* - document the inspection systemMike Bayer2012-07-181-94/+108
|
* - [moved] The InstrumentationManager interfaceMike Bayer2012-06-241-0/+2
| | | | | | | | | | | | | and the entire related system of alternate class implementation is now moved out to sqlalchemy.ext.instrumentation. This is a seldom used system that adds significant complexity and overhead to the mechanics of class instrumentation. The new architecture allows it to remain unused until InstrumentationManager is actually imported, at which point it is bootstrapped into the core.
* - move all of orm to use absolute importsMike Bayer2012-06-231-9/+7
| | | | | | | | - 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
* - [feature] The of_type() construct on attributesMike Bayer2012-06-201-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | 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
* - [feature] Added utility featureMike Bayer2012-05-171-1/+0
| | | | | | | Session.enable_relationship_loading(), supersedes relationship.load_on_pending. Both features should be avoided, however. [ticket:2372]
* - [bug] Fixed issue in unit of workMike Bayer2012-05-041-1/+1
| | | | | | | | whereby setting a non-None self-referential many-to-one relationship to None would fail to persist the change if the former value was not already loaded. [ticket:2477].
* - [bug] The "passive" flag on Session.is_modified()Mike Bayer2012-04-241-0/+5
| | | | | | | | 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]
* - [removed] The legacy "mutable" system of theMike Bayer2012-04-231-58/+1
| | | | | | | | | | | | | | 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]
* - some adjustments to keep hybrid properties workingMike Bayer2012-04-231-3/+4
| | | | - callcount here seems to have gone up by five, reason not certain
* merge patch for [ticket:2208]. This still needs documentation.Mike Bayer2012-04-231-18/+23
|\
| * - the inspect interface is done, needs docs.Mike Bayer2012-04-041-18/+23
| | | | | | | | | | - start dressing up InstanceState for it's coming out, start moving internal things to be underscored within the lib
* | - merge attribute flag overhaul for [ticket:2358]Mike Bayer2012-04-231-46/+63
|/
* typos in lib/sqlalchemy/ormDiana Clarke2012-03-171-3/+3
|
* happy new yearMike Bayer2012-01-041-1/+1
|
* - attribute system gets a pop() method.Mike Bayer2011-10-301-25/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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]
* - Added missing comma to PASSIVE_RETURN_NEVER_SETMike Bayer2011-10-201-1/+1
| | | | symbol [ticket:2304]
* - Fixed a variety of synonym()-related regressionsMike Bayer2011-09-151-0/+4
| | | | | | | | | | | | from 0.6: - making a synonym against a synonym now works. - synonyms made against a relationship() can be passed to query.join(), options sent to query.options(), passed by name to query.with_parent(). - revised the approach taken earlier to just propagate "property" out from the proxied attr the same way queryable attribute does.
* - Fixed bug whereby if __eq__() wasMike Bayer2011-09-091-1/+1
| | | | | | redefined, a relationship many-to-one lazyload would hit the __eq__() and fail. [ticket:2260] Does not apply to 0.6.9.
* - Fixed regression from 0.6 where Session.add()Mike Bayer2011-07-241-4/+13
| | | | | | | | | | | against an object which contained None in a collection would raise an internal exception. Reverted this to 0.6's behavior which is to accept the None but obviously nothing is persisted. Ideally, collections with None present or on append() should at least emit a warning, which is being considered for 0.8. [ticket:2205]
* - Fixed regression from 0.6 where a get historyMike Bayer2011-07-201-5/+5
| | | | | | | | 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.
* hey, we don't need this.Mike Bayer2011-05-301-11/+0
|
* the "property" argument here is not usedMike Bayer2011-05-301-1/+1
|
* - Added checks inside the UOW to detect the unusualMike Bayer2011-04-101-40/+61
| | | | | | | | | | | | | | | | | | | condition of being asked to UPDATE or DELETE on a primary key value that contains NULL in it. [ticket:2127] - Some refinements to attribute history. More changes are pending possibly in 0.8, but for now history has been modified such that scalar history doesn't have a "side effect" of populating None for a non-present value. This allows a slightly better ability to distinguish between a None set and no actual change, affects [ticket:2127] as well. - rewriting the history tests in test_attributes to be individual per operation/assertion. its a huge job so this is partial for the moment.
* - Some fixes to the state handling regardingMike Bayer2011-04-071-1/+0
| | | | | | | | | backrefs, typically when autoflush=False, where the back-referenced collection wouldn't properly handle add/removes with no net change. Thanks to Richard Murri for the test case + patch. [ticket:2123] (also in 0.6.7).
* - some doc reorgMike Bayer2011-03-171-2/+2
| | | | | | | | | | - change engine.Connection to _connection_cls so sphinx doesn't get upset - globally add "." to all :class:`Foo` - start naming sections that are mostly docstrings "API Documentation - blah blah" - move some ad-hoc docstrings into "API" sections, there is some inconsistency here and it may be that we just have to leave it that way - add "internals" rsts to core, orm, I'm not super thrilled how these look but they are targeted by some of the public api docs, users typically become aware of these anyway
* corrected a bunch of spelling typosDiana Clarke2011-02-281-1/+1
|
* - use easy to recognize names for backref events [ticket:2066]Mike Bayer2011-02-171-6/+14
|
* - remove some remaining sys.modules shenanigansrel_0_7b1Mike Bayer2011-02-121-2/+2
| | | | | | | | | - The "sqlalchemy.exceptions" alias in sys.modules has been removed. Base SQLA exceptions are available via "from sqlalchemy import exc". The "exceptions" alias for "exc" remains in "sqlalchemy" for now, it's just not patched into sys.modules.
* - fix long lines in test_attributesMike Bayer2011-02-111-18/+41
| | | | | | - add deprecation warning to get_history() when passed True or False, convert - rearrange symbol() so we can get sphinx autodata to work