summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/dynamic.py
Commit message (Collapse)AuthorAgeFilesLines
...
* - the wrapped memoized_property here was not working, as the attribute nameMike Bayer2013-11-261-2/+7
| | | | didn't match. use straight memoized_props here for now, add a perf test to check it
* - merge ticket_1418 branch, [ticket:1418]Mike Bayer2013-10-061-1/+1
| | | | | | | | | | | | | - The system of loader options has been entirely rearchitected to build upon a much more comprehensive base, the :class:`.Load` object. This base allows any common loader option like :func:`.joinedload`, :func:`.defer`, etc. to be used in a "chained" style for the purpose of specifying options down a path, such as ``joinedload("foo").subqueryload("bar")``. The new system supersedes the usage of dot-separated path names, multiple attributes within options, and the usage of ``_all()`` options. - Added a new load option :func:`.orm.load_only`. This allows a series of column names to be specified as loading "only" those attributes, deferring the rest.
* - apply an import refactoring to the ORM as wellMike Bayer2013-08-141-1/+2
| | | | | | | | | - 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-4/+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-2/+5
| | | | | | | | | | | | | | | | | | | :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]
* happy new year (see #2645)Diana Clarke2013-01-011-1/+1
|
* - add tests to ensure SELECT of dynamic collection not emittedMike Bayer2012-12-221-0/+3
| | | | | | 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
* - revert the full iteration of the collection for a passive history event; ↵Mike Bayer2012-12-221-5/+11
| | | | | | | that's the wrong behavior, and for the original #2637 issue we will have to fix the association proxy, which is #2642
* - significantly rework the approach to collection events and history within ↵Mike Bayer2012-12-211-61/+83
| | | | | | | | | | DynamicAttributeImpl - Fixes to the "dynamic" loader on :func:`.relationship`, includes that backrefs will work properly even when autoflush is disabled, history events are more accurate in scenarios where multiple add/remove of the same object occurs, as can often be the case in conjunction with the association proxy. [ticket:2637]
* - cleanup on these testsMike Bayer2012-12-211-0/+6
| | | | - add "extend()" to AppenderQuery
* just a pep8 pass of lib/sqlalchemy/orm/Diana Clarke2012-11-191-7/+11
|
* - [bug] An error is emitted when uselist=FalseMike Bayer2012-08-051-2/+6
| | | | | is combined with a "dynamic" loader. This is a warning in 0.7.9.
* - [feature] A warning is emitted when a referenceMike Bayer2012-08-041-0/+1
| | | | | | | | | 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]
* -whitespace bonanza, contdMike Bayer2012-07-281-13/+13
|
* - move all of orm to use absolute importsMike Bayer2012-06-231-12/+9
| | | | | | | | - 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
* merge patch for [ticket:2208]. This still needs documentation.Mike Bayer2012-04-231-1/+1
|\
| * - the inspect interface is done, needs docs.Mike Bayer2012-04-041-1/+1
| | | | | | | | | | - 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-4/+6
|/
* happy new yearMike Bayer2012-01-041-1/+1
|
* - attribute system gets a pop() method.Mike Bayer2011-10-301-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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]
* - remove test.sql._base, test.engine._base, test.orm._base, move those ↵Mike Bayer2011-03-271-1/+1
| | | | | | | classes to a new test.lib.fixtures module - move testing.TestBase to test.lib.fixtures - massive search and replace
* - replace all usage of True and False for passive with PASSIVE_NO_INITIALIZE,Mike Bayer2011-02-111-16/+19
| | | | | | PASSIVE_OFF, now expresed as non-boolean symbols - make "passive" available positionally on all get_history() methods, call it like that
* - whitespace removal bonanzaMike Bayer2011-01-021-7/+7
|
* - clean up copyright, update for 2011, stamp every file withMike Bayer2011-01-021-2/+2
| | | | | a consistent tag - AUTHORS file
* - removes the "on_" prefix.Mike Bayer2010-12-301-2/+2
|
* - slight simplify to state.modified_event()Mike Bayer2010-12-231-4/+2
|
* - modest inlinings into the MapperProperty.setup/row_processor chainMike Bayer2010-12-201-3/+0
|
* - further optimize what get_all_pending() returns to reduce the work of ↵Mike Bayer2010-12-191-3/+5
| | | | receivers
* - inlinings and callcount reductionsMike Bayer2010-12-121-1/+1
| | | | - add test coverage for the rare case of noload->lazyload + pickle
* - shave about a millisecond off of moderately complex save casades.Mike Bayer2010-12-061-2/+8
|
* - merge hybrid attributes branch, [ticket:1903]Mike Bayer2010-11-201-1/+1
|\
| * merge tipMike Bayer2010-11-141-1/+1
| |\
| * \ merge tipMike Bayer2010-09-141-1/+1
| |\ \
| * | | - step one, remove "resolve_synonyms" and start using class attributeMike Bayer2010-08-061-1/+1
| | | | | | | | | | | | | | | | access to get at mapped properties by name
* | | | - merge tipMike Bayer2010-11-061-1/+1
|\ \ \ \ | | |_|/ | |/| |
| * | | - Added a new "lazyload" option "immediateload".Mike Bayer2010-10-151-1/+1
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | Issues the usual "lazy" load operation automatically as the object is populated. The use case here is when loading objects to be placed in an offline cache, or otherwise used after the session isn't available, and straight 'select' loading, not 'joined' or 'subquery', is desired. [ticket:1914]
* | | - merge tip, 0.6.4 + 0.6.5Mike Bayer2010-09-141-1/+1
|\ \ \ | |/ /
| * | - Fixed recursion bug which could occur when movingMike Bayer2010-09-131-1/+1
| |/ | | | | | | | | | | | | an object from one reference to another, with backrefs involved, where the initiating parent was a subclass (with its own mapper) of the previous parent.
* | - get active_history to work, move attribute events into module-level classesMike Bayer2010-09-031-6/+7
|/
* - Dynamic attributes don't support collectionMike Bayer2010-08-051-13/+26
| | | | | | | | population - added an assertion for when set_committed_value() is called, as well as when joinedload() or subqueryload() options are applied to a dynamic attribute, instead of failure / silent failure. [ticket:1864]
* fix importMike Bayer2010-06-171-1/+1
|
* - session.merge() will not expire attributes on the returnedMike Bayer2010-05-081-2/+2
| | | | instance if that instance is "pending". [ticket:1789]
* - The official name for the relation() function is nowMike Bayer2010-03-171-1/+1
| | | | | | relationship(), to eliminate confusion over the relational algebra term. relation() however will remain available in equal capacity for the foreseeable future. [ticket:1740]
* Gave the "state" internals a good solidMike Bayer2010-02-141-1/+5
| | | | | cleanup with less complexity, datamembers, method calls, blank dictionary creates.
* - Now uses sqlalchemy.orm.exc.DetachedInstanceError when anMike Bayer2010-02-071-2/+3
| | | | | | attribute load or refresh action fails due to object being detached from any Session. UnboundExecutionError is specific to engines bound to sessions and statements.
* - Using a "dynamic" loader with a "secondary" table now producesMike Bayer2009-10-251-9/+24
| | | | | | | | | | | | a query where the "secondary" table is *not* aliased. This allows the secondary Table object to be used in the "order_by" attribute of the relation(), and also allows it to be used in filter criterion against the dynamic relation. [ticket:1531] - a "dynamic" loader sets up its query criterion at construction time so that the actual query is returned from non-cloning accessors like "statement".
* deprecations per [ticket:1498]:Mike Bayer2009-10-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - deprecated PassiveDefault - use DefaultClause. - the BINARY and MSBinary types now generate "BINARY" in all cases. Omitting the "length" parameter will generate "BINARY" with no length. Use BLOB to generate an unlengthed binary column. - the "quoting='quoted'" argument to MSEnum/ENUM is deprecated. It's best to rely upon the automatic quoting. - "shortname" attribute on bindparam() is removed. - fold_equivalents flag on join is deprecated (will remain until [ticket:1131] is implemented) - "scalar" flag on select() is removed, use select.as_scalar(). - 'transactional' flag on sessionmaker() and others is removed. Use 'autocommit=True' to indicate 'transactional=False'. - 'polymorphic_fetch' argument on mapper() is removed. Loading can be controlled using the 'with_polymorphic' option. - 'select_table' argument on mapper() is removed. Use 'with_polymorphic=("*", <some selectable>)' for this functionality. - 'proxy' argument on synonym() is removed. This flag did nothing throughout 0.5, as the "proxy generation" behavior is now automatic. - Passing a single list of elements to eagerload(), eagerload_all(), contains_eager(), lazyload(), defer(), and undefer() instead of multiple positional -args is deprecated. - Passing a single list of elements to query.order_by(), query.group_by(), query.join(), or query.outerjoin() instead of multiple positional *args is deprecated. - query.iterate_instances() is removed. Use query.instances(). - Query.query_from_parent() is removed. Use the sqlalchemy.orm.with_parent() function to produce a "parent" clause, or alternatively query.with_parent(). - query._from_self() is removed, use query.from_self() instead. - the "comparator" argument to composite() is removed. Use "comparator_factory". - RelationProperty._get_join() is removed. - the 'echo_uow' flag on Session is removed. Use logging on the "sqlalchemy.orm.unitofwork" name. - session.clear() is removed. use session.expunge_all(). - session.save(), session.update(), session.save_or_update() are removed. Use session.add() and session.add_all(). - the "objects" flag on session.flush() remains deprecated. - the "dont_load=True" flag on session.merge() is deprecated in favor of "load=False". - passing an InstanceState (internal SQLAlchemy state object) to attributes.init_collection() or attributes.get_history() is deprecated. These functions are public API and normally expect a regular mapped object instance. - the 'engine' parameter to declarative_base() is removed. Use the 'bind' keyword argument.
* - Squeezed a few more unnecessary "lazy loads" out ofMike Bayer2009-07-261-1/+1
| | | | | | | | | | | relation(). When a collection is mutated, many-to-one backrefs on the other side will not fire off to load the "old" value, unless "single_parent=True" is set. A direct assignment of a many-to-one still loads the "old" value in order to update backref collections on that value, which may be present in the session already, thus maintaining the 0.5 behavioral contract. [ticket:1483]
* - Significant performance enhancements regarding Sessions/flush()Mike Bayer2009-05-171-23/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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().
* Modified query_cls on DynamicAttribteImpl to accept a full mixin version of ↵Michael Trier2009-04-251-20/+22
| | | | the AppenderQuery.