summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/dependency.py
Commit message (Collapse)AuthorAgeFilesLines
* happy new year 2023Mike Bayer2023-01-031-1/+1
| | | | Change-Id: I625af65b3fb1815b1af17dc2ef47dd697fdc3fb1
* inline mypy config; files ignoring type errors for the momentMike Bayer2022-04-281-0/+2
| | | | | | | | | | | | | | | | | | | to simplify pyproject.toml change the remaining files that aren't going to be typed on this first pass (unless of course someone wants to type some of these) to include # mypy: ignore-errors. for the moment, only a handful of ORM modules are to have more type checking implemented. It's important that ignore-errors is used and not "# type: ignore", as in the latter case, mypy doesn't even read the existing types in the file, which makes it impossible to type any files that refer to those modules at all. to simplify ongoing typing work use inline mypy config for remaining files that are "done" for now, indicating the level of type checking they currently have. Change-Id: I98669c1a305c2f0adba85d10b5425541f3fe9533
* pep-484 for sqlalchemy.event; use future annotationsMike Bayer2022-02-151-0/+2
| | | | | | | | | | __future__.annotations mode allows us to use non-string annotations for argument and return types in most cases, but more importantly it removes a large amount of runtime overhead that would be spent in evaluating the annotations. Change-Id: I2f5b6126fe0019713fc50001be3627b664019ede References: #6810
* happy new year 2022Mike Bayer2022-01-061-1/+1
| | | | Change-Id: I49abf2607e0eb0623650efdf0091b1fb3db737ea
* Remove object in class definitionFederico Caselli2021-11-221-1/+1
| | | | | References: #4600 Change-Id: I2a62ddfe00bc562720f0eae700a497495d7a987a
* Modernize tests - dml_whereclauseGord Thompson2021-07-261-1/+1
| | | | | | | | | Fixed issue where the unit of work would internally use a 2.0-deprecated SQL expression form, emitting a deprecation warning when SQLALCHEMY_WARN_20 were enabled. Fixes: #6812 Change-Id: I0a031e728527a1c3382848b6ddc793939362b128
* Replace all http:// links to https://Federico Caselli2021-07-041-1/+1
| | | | | | Also replace http://pypi.python.org/pypi with https://pypi.org/project Change-Id: I84b5005c39969a82140706472989f2a30b0c7685
* disable all raiseload within the unit of work process.Mike Bayer2021-02-281-0/+5
| | | | | | | | | | | The unit of work process now turns off all "lazy='raise'" behavior altogether when a flush is proceeding. While there are areas where the UOW is sometimes loading things that aren't ultimately needed, the lazy="raise" strategy is not helpful here as the user often does not have much control or visibility into the flush process. Fixes: #5984 Change-Id: I23f2e332a5faa5c7c29823c9be9434d129676a5a
* happy new yearMike Bayer2021-01-041-1/+1
| | | | Change-Id: Ic5bb19ca8be3cb47c95a0d3315d84cb484bac47c
* Send deterministic ordering into unit of work topologicalMike Bayer2020-12-111-0/+1
| | | | | | | | | | | | | | | | Improved the unit of work topological sorting system such that the toplogical sort is now deterministic based on the sorting of the input set, which itself is now sorted at the level of mappers, so that the same inputs of affected mappers should produce the same output every time, among mappers / tables that don't have any dependency on each other. This further reduces the chance of deadlocks as can be observed in a flush that UPDATEs among multiple, unrelated tables such that row locks are generated. topological.sort() has been made "deterministic" in all cases by using a separate list + set. Fixes: #5735 Change-Id: I073103df414dba549e46605b394f8ccae6e80d0e
* Establish future behavior for Session cascade backrefs, bindMike Bayer2020-08-011-1/+1
| | | | | | | | | | | | | | | | | | | | The behavior of the :paramref:`_orm.relationship.cascade_backrefs` flag will be reversed in 2.0 and set to ``False`` unconditionally, such that backrefs don't cascade save-update operations from a forwards-assignment to a backwards assignment. A 2.0 deprecation warning is emitted when the parameter is left at its default of ``True`` at the point at which such a cascade operation actually takes place. The new behavior can be established as always by setting the flag to ``False`` on a specific :func:`_orm.relationship`, or more generally can be set up across the board by setting the the :paramref:`_orm.Session.future` flag to True. Additionally in the interests of expediency, this commit will also move Session away from making use of bound metadata if the future=True flag is set. An application that sets future=True should ideally have to change as little else as possible for full 2.0 behavior. Fixes: #5150 Change-Id: I490d1d61f09c62ffc2de983208aeed25dfe48aec
* happy new yearMike Bayer2020-01-011-1/+1
| | | | Change-Id: I08440dc25e40ea1ccea1778f6ee9e28a00808235
* Fixes for uselist=True with m2o relationshipsMike Bayer2019-07-181-1/+7
| | | | | | | | | | | | | | | Fixed bug where a many-to-one relationship that specified ``uselist=True`` would fail to update correctly during a primary key change where a related column needs to change. Fixed bug where the detection for many-to-one or one-to-one use with a "dynamic" relationship, which is an invalid configuration, would fail to raise if the relationship were configured with ``uselist=True``. The current fix is that it warns, instead of raises, as this would otherwise be backwards incompatible, however in a future release it will be a raise. Fixes: #4772 Change-Id: Ibd5d2f7329ff245c88118e2533fc8ef42a09fef3
* Run PK/FK sync for multi-level inheritance w/ no intermediary updateMike Bayer2019-06-121-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | Also fix DetectKeySwitch for intermediary class relationship Fixed a series of related bugs regarding joined table inheritance more than two levels deep, in conjunction with modification to primary key values, where those primary key columns are also linked together in a foreign key relationship as is typical for joined table inheritance. The intermediary table in a three-level inheritance hierachy will now get its UPDATE if only the primary key value has changed and passive_updates=False (e.g. foreign key constraints not being enforced), whereas before it would be skipped; similarly, with passive_updates=True (e.g. ON UPDATE CASCADE in effect), the third-level table will not receive an UPDATE statement as was the case earlier which would fail since CASCADE already modified it. In a related issue, a relationship linked to a three-level inheritance hierarchy on the primary key of an intermediary table of a joined-inheritance hierarchy will also correctly have its foreign key column updated when the parent object's primary key is modified, even if that parent object is a subclass of the linked parent class, whereas before these classes would not be counted. Fixes: #4723 Change-Id: Idc408ead67702068e64d583a15149dd4beeefc24
* happy new yearMike Bayer2019-01-111-1/+1
| | | | Change-Id: I6a71f4924d046cf306961c58dffccf21e9c03911
* Post black reformattingMike Bayer2019-01-061-9/+17
| | | | | | | | | | | | | 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-496/+590
| | | | | | | | | | | | | | 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
* Implement __delete__Mike Bayer2018-11-021-0/+3
| | | | | | | | | | A long-standing oversight in the ORM, the ``__delete__`` method for a many- to-one relationship was non-functional, e.g. for an operation such as ``del a.b``. This is now implemented and is equivalent to setting the attribute to ``None``. Fixes: #4354 Change-Id: I60131a84c007b0bf6f20c5cc5f21a3b96e954046
* Don't null FK for collection-removed item with passive_deletes='all'Mike Bayer2018-07-111-4/+11
| | | | | | | | | | | Fixed issue regarding passive_deletes="all", where the foreign key attribute of an object is maintained with its value even after the object is removed from its parent collection. Previously, the unit of work would set this to NULL even though passive_deletes indicated it should not be modified. Change-Id: I5ba98bc388cbdd6323d255b764e02506c2e66896 Fixes: #3844
* Add dependency for parent_pre post updates to parent deletesMike Bayer2018-02-121-0/+1
| | | | | | | | | | | Fixed issue in post_update feature where an UPDATE is emitted when the parent object has been deleted but the dependent object is not. This issue has existed for a long time however since 1.2 now asserts rows matched for post_update, this was raising an error. Change-Id: I31b1d22408e358962577435f0c4cb9a456ba0872 Fixes: #4187
* happy new yearMike Bayer2018-01-121-1/+1
| | | | Change-Id: I3ef36bfd0cb0ba62b3123c8cf92370a43156cf8f
* Refinements for unitofwork internalsMike Bayer2017-06-141-24/+13
| | | | | | | | | | | * remove "mapper" argument from SaveUpdateState, DeleteState * use __slots__ for all uow action classes * rename ".delete" to ".isdelete" * rename issue_post_update to register_post_update since this doesn't actually issue the UPDATE * rename IssuePostUpdate to PostUpdateAll Change-Id: Ia6263b80d6a86eab1e8ed38df1421b1d0f249797
* update for 2017 copyrightMike Bayer2017-01-041-1/+1
| | | | Change-Id: I4e8c2aa8fe817bb2af8707410fa0201f938781de
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - Fixed issue where post_update on a many-to-one relationship wouldMike Bayer2015-12-021-3/+5
| | | | | | fail to emit an UPDATE in the case where the attribute were set to None and not previously loaded. fixes #3599
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - restore non_updating_cascade to test_manytomany_nonpassive, but alsoMike Bayer2014-07-251-0/+1
| | | | add sane_multi_rowcount requirement, as pg8000 doesn't do "multi" row count.
* - apply pep8 formatting to sqlalchemy/sql, sqlalchemy/util, sqlalchemy/dialects,Brian Jarrett2014-07-201-284/+286
| | | | 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
* - Related to :ticket:`3060`, an adjustment has been made to the unitMike Bayer2014-05-301-3/+7
| | | | | | | | | | of work such that loading for related many-to-one objects is slightly more aggressive, in the case of a graph of self-referential objects that are to be deleted; the load of related objects is to help determine the correct order for deletion if passive_deletes is not set. - revert the changes to test_delete_unloaded_m2o, these deletes do in fact need to occur in the order of the two child objects first.
* - Adjustment to attribute mechanics concerning when a value isMike Bayer2014-05-291-5/+0
| | | | | | | | | | | | | | 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-4/+9
| | | | | | | | | | | 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
|
* Fixed bug where many-to-many relationship with uselist=FalseMike Bayer2013-04-211-3/+7
| | | | | | would fail to delete the association row and raise an error if the scalar attribute were set to None. Also in 0.7.11. [ticket:2710]
* happy new year (see #2645)Diana Clarke2013-01-011-1/+1
|
* just a pep8 pass of lib/sqlalchemy/orm/Diana Clarke2012-11-191-26/+23
|
* - [feature] Adding/removing None from a mapped collectionMike Bayer2012-08-131-8/+10
| | | | | | | | | | | 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]
* move mapper-level UOW functionality straight into unitofwork also. there'sMike Bayer2012-07-141-200/+200
| | | | | | no need for this to be per-mapper. can't move dependency init off of property though as this init needs to happen up front, added a test to prove it.
* - move all of orm to use absolute importsMike Bayer2012-06-231-5/+6
| | | | | | | | - 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
* happy new yearMike Bayer2012-01-041-1/+1
|
* - "delete-orphan" cascade is now allowed onMike Bayer2011-06-041-1/+1
| | | | | | | | | | 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
* - and fix the message that was the actual subject of [ticket:2063]Mike Bayer2011-03-271-3/+9
|
* - Reworded the exception raised when a flushMike Bayer2011-03-271-8/+15
| | | | | is attempted of a subclass that is not polymorphic against the supertype. [ticket:2063]
* corrected a bunch of spelling typosDiana Clarke2011-02-281-1/+1
|
* - A tweak to the unit of work causes it to orderMike Bayer2011-03-061-1/+3
| | | | | | | | | | | | | the flush along relationship() dependencies even if the given objects don't have any inter-attribute references in memory, which was the behavior in 0.5 and earlier, so a flush of Parent/Child with only foreign key/primary key set will succeed. This while still maintaining 0.6 and above's not generating a ton of useless internal dependency structures within the flush that don't correspond to state actually within the current flush. [ticket:2082]
* - remove some remaining sys.modules shenanigansrel_0_7b1Mike Bayer2011-02-121-2/+1
| | | | | | | | | - 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.
* - replace all usage of True and False for passive with PASSIVE_NO_INITIALIZE,Mike Bayer2011-02-111-23/+39
| | | | | | PASSIVE_OFF, now expresed as non-boolean symbols - make "passive" available positionally on all get_history() methods, call it like that
* - Additional tuning to "many-to-one" relationshipMike Bayer2011-02-111-1/+6
| | | | | | | | | | loads during a flush(). A change in version 0.6.6 ([ticket:2002]) required that more "unnecessary" m2o loads during a flush could occur. Extra loading modes have been added so that the SQL emitted in this specific use case is trimmed back, while still retrieving the information the flush needs in order to not miss anything. [ticket:2049]
* - Fixed bug whereby "passive_deletes='all'" wasn't passingMike Bayer2011-01-041-7/+10
| | | | | the correct symbols to lazy loaders during flush, thereby causing an unwarranted load. [ticket:2013]
* - whitespace removal bonanzaMike Bayer2011-01-021-90/+90
|