summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/sync.py
Commit message (Collapse)AuthorAgeFilesLines
* Ensure all nested exception throws have a causeMike Bayer2020-03-021-28/+35
| | | | | | | | | | | | | | | Applied an explicit "cause" to most if not all internally raised exceptions that are raised from within an internal exception catch, to avoid misleading stacktraces that suggest an error within the handling of an exception. While it would be preferable to suppress the internally caught exception in the way that the ``__suppress_context__`` attribute would, there does not as yet seem to be a way to do this without suppressing an enclosing user constructed context, so for now it exposes the internally caught exception as the cause so that full information about the context of the error is maintained. Fixes: #4849 Change-Id: I55a86b29023675d9e5e49bc7edc5a2dc0bcd4751
* happy new yearMike Bayer2020-01-011-1/+1
| | | | Change-Id: I08440dc25e40ea1ccea1778f6ee9e28a00808235
* happy new yearMike Bayer2019-01-111-1/+1
| | | | Change-Id: I6a71f4924d046cf306961c58dffccf21e9c03911
* Post black reformattingMike Bayer2019-01-061-1/+3
| | | | | | | | | | | | | Applied on top of a pure run of black -l 79 in I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9, this set of changes resolves all remaining flake8 conditions for those codes we have enabled in setup.cfg. Included are resolutions for all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I4f72d3ba1380dd601610ff80b8fb06a2aff8b0fe
* Run black -l 79 against all source filesMike Bayer2019-01-061-23/+41
| | | | | | | | | | | | | | This is a straight reformat run using black as is, with no edits applied at all. The black run will format code consistently, however in some cases that are prevalent in SQLAlchemy code it produces too-long lines. The too-long lines will be resolved in the following commit that will resolve all remaining flake8 issues including shadowed builtins, long lines, import order, unused imports, duplicate imports, and docstring issues. Change-Id: I7eda77fed3d8e73df84b3651fd6cfcfe858d4dc9
* happy new yearMike Bayer2018-01-121-1/+1
| | | | Change-Id: I3ef36bfd0cb0ba62b3123c8cf92370a43156cf8f
* update for 2017 copyrightMike Bayer2017-01-041-1/+1
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - Fixed more regressions caused by NEVER_SET; comparisonsMike Bayer2015-04-201-2/+2
| | | | | | | | | to transient objects with attributes unset would leak NEVER_SET, and negated_contains_or_equals would do so for any transient object as the comparison used only the committed value. Repaired the NEVER_SET cases, fixes #3371, and also made negated_contains_or_equals() use state_attr_by_column() just like a non-negated comparison, fixes #3374
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - fix inheritance persistenceMike Bayer2014-12-071-0/+17
| | | | - start writing docs
* - apply pep8 formatting to sqlalchemy/sql, sqlalchemy/util, sqlalchemy/dialects,Brian Jarrett2014-07-201-19/+20
| | | | sqlalchemy/orm, sqlalchemy/event, sqlalchemy/testing
* - break up the <authors> copyright comment as part of a passMike Bayer2014-07-091-1/+2
| | | | to get all flake8 passing
* - Adjustment to attribute mechanics concerning when a value isMike Bayer2014-05-291-1/+1
| | | | | | | | | | | | | | implicitly initialized to None via first access; this action, which has always resulted in a population of the attribute, now emits an attribute event just like any other attribute set operation and generates the same kind of history as one. Additionally, many mapper internal operations will no longer implicitly generate these "None" values when various never-set attributes are checked. These are subtle behavioral fixes to attribute mechanics which provide a better solution to the problem of :ticket:`3060`, which also involves recognition of attributes explicitly set to ``None`` vs. attributes that were never set. fixes #3061
* - Fixed a few edge cases which arise in the so-called "row switch"Mike Bayer2014-05-281-1/+4
| | | | | | | | | | | scenario, where an INSERT/DELETE can be turned into an UPDATE. In this situation, a many-to-one relationship set to None, or in some cases a scalar attribute set to None, may not be detected as a net change in value, and therefore the UPDATE would not reset what was on the previous row. This is due to some as-yet unresovled side effects of the way attribute history works in terms of implicitly assuming None isn't really a "change" for a previously un-set attribute. See also :ticket:`3061`. fixes #3060
* - happy new yearMike Bayer2014-01-051-1/+1
|
* Detection of a primary key change within the processMike Bayer2013-02-251-1/+2
| | | | | | | of cascading a natural primary key update will succeed even if the key is composite and only some of the attributes have changed. [ticket:2665]
* happy new year (see #2645)Diana Clarke2013-01-011-1/+1
|
* just a pep8 pass of lib/sqlalchemy/orm/Diana Clarke2012-11-191-7/+16
|
* -whitespace bonanza, contdMike Bayer2012-07-281-6/+6
|
* - move all of orm to use absolute importsMike Bayer2012-06-231-2/+2
| | | | | | | | - 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-14/+14
| | | | | | | | | | | | | | * 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)
* break out _save_obj(), _delete_obj(), _post_update() into a new moduleMike Bayer2012-01-301-0/+1
| | | | | | | persistence.py - Mapper loses awareness of how to emit INSERT/UPDATE/DELETE, persistence.py is only used by unitofwork.py. Then break each method out into a top level with almost no logic, calling into _organize_states_for_XYZ(), _collect_XYZ_commands(), _emit_XYZ_statements().
* happy new yearMike Bayer2012-01-041-1/+1
|
* - Fixed the error message emitted for "can'tMike Bayer2011-05-071-1/+1
| | | | | | | | execute syncrule for destination column 'q'; mapper 'X' does not map this column" to reference the correct mapper. [ticket:2163]. Also in 0.6.8. - test/orm/test_sync.py covers orm/sync.py 100%
* corrected a bunch of spelling typosDiana Clarke2011-02-281-1/+1
|
* - replace all usage of True and False for passive with PASSIVE_NO_INITIALIZE,Mike Bayer2011-02-111-3/+5
| | | | | | 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-3/+3
|
* - clean up copyright, update for 2011, stamp every file withMike Bayer2011-01-021-2/+2
| | | | | a consistent tag - AUTHORS file
* - with composites gone all the get_col_value crap is gone tooMike Bayer2010-12-201-2/+9
|
* - callcountsMike Bayer2010-12-101-2/+3
|
* Apply more memoization to Mapper attributes & subject to group expiry.Jason Kirtland2010-09-031-1/+1
|
* - Moving an o2m object from one collection toMike Bayer2010-07-221-2/+2
| | | | | | | | | | | | | | | | | another, or vice versa changing the referenced object by an m2o, where the foreign key is also a member of the primary key, will now be more carefully checked during flush if the change in value of the foreign key on the "many" side is the result of a change in the primary key of the "one" side, or if the "one" is just a different object. In one case, a cascade-capable DB would have cascaded the value already and we need to look at the "new" PK value to do an UPDATE, in the other we need to continue looking at the "old". We now look at the "old", assuming passive_updates=True, unless we know it was a PK switch that triggered the change. [ticket:1856]
* - starting to groom the branch for its inclusionMike Bayer2010-04-101-2/+1
| | | | | | | | | | | | | | - one-to-many relationships now maintain a list of positive parent-child associations within the flush, preventing previous parents marked as deleted from cascading a delete or NULL foreign key set on those child objects, despite the end-user not removing the child from the old association. [ticket:1764] - re-established Preprocess as unique on their arguments, as they were definitely duped in inheritance scenarios - added a "memo" feature to UOWTransaction which represents the usual pattern of using the .attributes collection - added the test case from [ticket:1081] into perf/
* - dict_ becomes explicit on _get_state_attr_by_column, ↵Mike Bayer2010-04-071-5/+5
| | | | | | | | | _set_state_attr_by_column, others, to reduce on expensive state.dict calls. - internal getattr(), setattr(), getcommitted() methods on ColumnProperty, CompositeProperty, RelationshipProperty have been underscored, signature has changed.
* - cleanup some long lines. (test hg commit hook)Mike Bayer2010-03-071-7/+22
|
* - Primary key values can now be changed on a joined-table inheritanceMike Bayer2010-02-021-1/+11
| | | | | | | | | | | | 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]
* happy new yearMike Bayer2010-01-071-1/+1
|
* - Removed all* O(N) scanning behavior from the flush() process,Mike Bayer2009-05-171-14/+6
| | | | | | | | | | | 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.
* happy new yearMike Bayer2009-01-121-1/+1
|
* - added some abstraction to the attributes.History objectMike Bayer2008-10-281-4/+4
| | | | | - Repaired support for "passive-deletes" on a many-to-one relation() with "delete" cascade. [ticket:1183]
* r4695 merged to trunk; trunk now becomes 0.5.Mike Bayer2008-05-091-19/+14
| | | | 0.4 development continues at /sqlalchemy/branches/rel_0_4
* - merged sync_simplify branchMike Bayer2008-04-041-165/+62
| | | | | | | | | | | | | | | | - 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
* - Fixed a couple pyflakes, cleaned up imports & whitespaceJason Kirtland2008-02-141-1/+1
|
* - fixed bug with session.dirty when using "mutable scalars"Mike Bayer2008-01-091-6/+24
| | | | | | | | (such as PickleTypes) - added a more descriptive error message when flushing on a relation() that has non-locally-mapped columns in its primary or secondary join condition
* happy new yearMike Bayer2008-01-011-1/+1
|
* only report true for source change if added + deleted, dont pick up insertsMike Bayer2007-12-091-1/+1
|
* - mutable primary key support is added. primary key columns can beMike Bayer2007-12-091-3/+31
| | | | | | | | | 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-13/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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-3/+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