summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/attributes.py
Commit message (Collapse)AuthorAgeFilesLines
* Fix many typos throughout the codebasepr/85Alex Gaynor2014-04-261-1/+1
| | | | Found using: https://github.com/intgr/topy
* - Fixed bug in mutable extension as well asMike Bayer2014-03-191-1/+1
| | | | | | :func:`.attributes.flag_modified` where the change event would not be propagated if the attribute had been reassigned to itself. fixes #2997
* - Added a new directive used within the scope of an attribute "set" operationMike Bayer2014-01-311-2/+2
| | | | | | | | to disable autoflush, in the case that the attribute needs to lazy-load the "old" value, as in when replacing one-to-one values or some kinds of many-to-one. A flush at this point otherwise occurs at the point that the attribute is None and can cause NULL violations. [ticket:2921]
* - happy new yearMike Bayer2014-01-051-1/+1
|
* - the wrapped memoized_property here was not working, as the attribute nameMike Bayer2013-11-261-10/+18
| | | | didn't match. use straight memoized_props here for now, add a perf test to check it
* - Some refinements to the :class:`.AliasedClass` construct with regardsMike Bayer2013-11-231-1/+7
| | | | | | | | | | | | | | | to descriptors, like hybrids, synonyms, composites, user-defined descriptors, etc. The attribute adaptation which goes on has been made more robust, such that if a descriptor returns another instrumented attribute, rather than a compound SQL expression element, the operation will still proceed. Addtionally, the "adapted" operator will retain its class; previously, a change in class from ``InstrumentedAttribute`` to ``QueryableAttribute`` (a superclass) would interact with Python's operator system such that an expression like ``aliased(MyClass.x) > MyClass.x`` would reverse itself to read ``myclass.x < myclass_1.x``. The adapted attribute will also refer to the new :class:`.AliasedClass` as its parent which was not always the case before. [ticket:2872]
* - The ``viewonly`` flag on :func:`.relationship` will now preventMike Bayer2013-11-191-0/+6
| | | | | | | | | | attribute history from being written on behalf of the target attribute. This has the effect of the object not being written to the Session.dirty list if it is mutated. Previously, the object would be present in Session.dirty, but no change would take place on behalf of the modified attribute during flush. The attribute still emits events such as backref events and user-defined events and will still receive mutations from backrefs. [ticket:2833]
* - :func:`.attributes.get_history()` when used with a scalar column-mappedMike Bayer2013-10-251-5/+12
| | | | | | | | | attribute will now honor the "passive" flag passed to it; as this defaults to ``PASSIVE_OFF``, the function will by default query the database if the value is not present. This is a behavioral change vs. 0.8. [ticket:2787] - Added new method :meth:`.AttributeState.load_history`, works like :attr:`.AttributeState.history` but also fires loader callables.
* - A new construct :class:`.Bundle` is added, which allows for specificationMike Bayer2013-10-031-1/+7
| | | | | | | | | | | | | | | | of groups of column expressions to a :class:`.Query` construct. The group of columns are returned as a single tuple by default. The behavior of :class:`.Bundle` can be overridden however to provide any sort of result processing to the returned row. One example included is :attr:`.Composite.Comparator.bundle`, which applies a bundled form of a "composite" mapped attribute. [ticket:2824] - The :func:`.composite` construct now maintains the return object when used in a column-oriented :class:`.Query`, rather than expanding out into individual columns. This makes use of the new :class:`.Bundle` feature internally. This behavior is backwards incompatible; to select from a composite column which will expand out, use ``MyClass.some_composite.clauses``.
* - apply an import refactoring to the ORM as wellMike Bayer2013-08-141-107/+13
| | | | | | | | | - rework the event system so that event modules load after their targets, dependencies are reversed - create an improved strategy lookup system for the ORM - rework the ORM to have very few import cycles - move out "importlater" to just util.dependency - other tricks to cross-populate modules in as clear a way as possible
* - A large refactoring of the ``sqlalchemy.sql`` package has reorganizedMike Bayer2013-08-121-2/+1
| | | | | | | | | | | | | | | | | | | | | | the import structure of many core modules. ``sqlalchemy.schema`` and ``sqlalchemy.types`` remain in the top-level package, but are now just lists of names that pull from within ``sqlalchemy.sql``. Their implementations are now broken out among ``sqlalchemy.sql.type_api``, ``sqlalchemy.sql.sqltypes``, ``sqlalchemy.sql.schema`` and ``sqlalchemy.sql.ddl``, the last of which was moved from ``sqlalchemy.engine``. ``sqlalchemy.sql.expression`` is also a namespace now which pulls implementations mostly from ``sqlalchemy.sql.elements``, ``sqlalchemy.sql.selectable``, and ``sqlalchemy.sql.dml``. Most of the "factory" functions used to create SQL expression objects have been moved to classmethods or constructors, which are exposed in ``sqlalchemy.sql.expression`` using a programmatic system. Care has been taken such that all the original import namespaces remain intact and there should be no impact on any existing applications. The rationale here was to break out these very large modules into smaller ones, provide more manageable lists of function names, to greatly reduce "import cycles" and clarify the up-front importing of names, and to remove the need for redundant functions and documentation throughout the expression package.
* - The mechanism by which attribute events pass along anMike Bayer2013-07-261-44/+91
| | | | | | | | | | | | | | | | | | | :class:`.AttributeImpl` as an "initiator" token has been changed; the object is now an event-specific object called :class:`.attributes.Event`. Additionally, the attribute system no longer halts events based on a matching "initiator" token; this logic has been moved to be specific to ORM backref event handlers, which are the typical source of the re-propagation of an attribute event onto subsequent append/set/remove operations. End user code which emulates the behavior of backrefs must now ensure that recursive event propagation schemes are halted, if the scheme does not use the backref handlers. Using this new system, backref handlers can now peform a "two-hop" operation when an object is appended to a collection, associated with a new many-to-one, de-associated with the previous many-to-one, and then removed from a previous collection. Before this change, the last step of removal from the previous collection would not occur. [ticket:2789]
* 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]
* - rework PropComparator.adapted() to be PropComparator.adapt_to_entity(),Mike Bayer2013-06-171-10/+7
| | | | | | | passes in AliasedInsp and allows more flexibility. - rework the AliasedClass/AliasedInsp relationship so that AliasedInsp has all state and functionality. AliasedClass is just a facade. [ticket:2756]
* a pass where we try to squash down as many list()/keys() combinationsMike Bayer2013-05-261-1/+1
| | | | as possible
* most of ORM passing...Mike Bayer2013-05-041-2/+3
|
* - the raw 2to3 runMike Bayer2013-04-271-1/+1
| | | | - went through examples/ and cleaned out excess list() calls
* 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
|