summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/util.py
Commit message (Collapse)AuthorAgeFilesLines
* - Fixed 1.0 regression where the "parent entity" of a synonym-Mike Bayer2015-06-271-1/+1
| | | | | | | | | | | | | mapped attribute on top of an :func:`.aliased` object would resolve to the original mapper, not the :func:`.aliased` version of it, thereby causing problems for a :class:`.Query` that relies on this attribute (e.g. it's the only representative attribute given in the constructor) to figure out the correct FROM clause for the query. fixes #3466 - apply consitency to ._parententity vs. __clause_element__()._annotations['parententity'] in terms of aliased class, test it all.
* - Fixed 1.0 regression where the enhanced behavior of single-inheritanceMike Bayer2015-06-191-3/+4
| | | | | | | | joins of :ticket:`3222` takes place inappropriately for a JOIN along explicit join criteria with a single-inheritance subclass that does not make use of any discriminator, resulting in an additional "AND NULL" clause. fixes #3462
* - Liberalized an assertion that was added as part of :ticket:`3347`Mike Bayer2015-05-021-1/+5
| | | | | | | | to protect against unknown conditions when splicing inner joins together within joined eager loads with ``innerjoin=True``; if some of the joins use a "secondary" table, the assertion needs to unwrap further joins in order to pass. fixes #3412
* - Fixed a critical regression caused by :ticket:`3061` where theMike Bayer2015-04-171-1/+1
| | | | | | | | | | | NEVER_SET symbol could easily leak into a lazyload query, subsequent to the flush of a pending object. This would occur typically for a many-to-one relationship that does not use a simple "get" strategy. The good news is that the fix improves efficiency vs. 0.9, because we can now skip the SELECT statement entirely when we detect NEVER_SET symbols present in the parameters; prior to :ticket:`3061`, we couldn't discern if the None here were set or not. fixes #3368
* - further fixes for #3347; track the mappers we're joiningMike Bayer2015-03-311-1/+29
| | | | | between fully and match on those, rather than trying to compare selectables; fixes #3347
* Accept unicode in CascadeOptionspr/160Julien Castets2015-03-161-1/+1
|
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - add MemoizedSlots, a generalized solution to using __getattr__Mike Bayer2015-01-051-4/+6
| | | | | for memoization on a class that uses slots. - apply many more __slots__. mem use for nova now at 46% savings
* - The :meth:`.PropComparator.of_type` modifier has beenMike Bayer2014-11-241-3/+19
| | | | | | | | | | | | | | | improved in conjunction with loader directives such as :func:`.joinedload` and :func:`.contains_eager` such that if two :meth:`.PropComparator.of_type` modifiers of the same base type/path are encountered, they will be joined together into a single "polymorphic" entity, rather than replacing the entity of type A with the one of type B. E.g. a joinedload of ``A.b.of_type(BSub1)->BSub1.c`` combined with joinedload of ``A.b.of_type(BSub2)->BSub2.c`` will create a single joinedload of ``A.b.of_type((BSub1, BSub2)) -> BSub1.c, BSub2.c``, without the need for the ``with_polymorphic`` to be explicit in the query. fixes #3256
* Merge remote-tracking branch 'origin/pr/137' into pr137Mike Bayer2014-10-211-7/+12
|\
| * change functionspr/137jona2014-09-161-7/+12
| |
* | - The ON clause rendered when using :meth:`.Query.join`,Mike Bayer2014-10-091-0/+10
|/ | | | | | | | | | :meth:`.Query.outerjoin`, or the standalone :func:`.orm.join` / :func:`.orm.outerjoin` functions to a single-inheritance subclass will now include the "single table criteria" in the ON clause even if the ON clause is otherwise hand-rolled; it is now added to the criteria using AND, the same way as if joining to a single-table target using relationship or similar. fixes #3222
* - remove some old cruftMike Bayer2014-09-071-3/+1
| | | | | | - prop.compare() isn't needed; replace with prop._with_parent() for relationships - update docs in orm/interfaces
* - rework ColumnAdapter and ORMAdapter to only provide the featuresticket_3148Mike Bayer2014-09-071-10/+8
| | | | | | | | | | | we're now using; rework them fully so that their behavioral contract is consistent regarding adapter.traverse() vs. adapter.columns[], add a full suite of tests including advanced wrapping scenarios previously only covered by test/orm/test_froms.py and test/orm/inheritance/test_relationships.py - identify several cases where label._order_by_label_clause would be corrupted, e.g. due to adaption or annotation separately - add full tests for #3148
* - enhance ClauseAdapter / ColumnAdapter to have new behaviors with labels.Mike Bayer2014-09-071-4/+7
| | | | | | | | | | | | | | | | | | | | | The "anonymize label" logic is now generalized to ClauseAdapter, and takes place when the anonymize_labels flag is sent, taking effect for all .columns lookups as well as within traverse() calls against the label directly. - traverse() will also memoize what it gets in columns, so that calling upon traverse() / .columns against the same Label will produce the same anonymized label. This is so that AliasedClass produces the same anonymized label when it is accessed per-column (e.g. SomeAlias.some_column) as well as when it is applied to a Query, and within column loader strategies (e.g. query(SomeAlias)); the former uses traverse() while the latter uses .columns - AliasedClass now calls onto ColumnAdapter - Query also makes sure to use that same ColumnAdapter from the AliasedClass in all cases - update the logic from 0.9 in #1068 to make use of the same _label_resolve_dict we use for #2992, simplifying how that works and adding support for new scenarios that were pretty broken (see #3148, #3188)
* wip for #3148Mike Bayer2014-09-061-4/+5
|
* - rename _InspectionAttr to InspectionAttrMike Bayer2014-08-131-2/+2
|
* - apply pep8 formatting to sqlalchemy/sql, sqlalchemy/util, sqlalchemy/dialects,Brian Jarrett2014-07-201-87/+97
| | | | 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-2/+1
| | | | | | | | | | 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-1/+2
| | | | | | | | | | | | | | 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
* Fix many typos throughout the codebasepr/85Alex Gaynor2014-04-261-1/+1
| | | | Found using: https://github.com/intgr/topy
* - happy new yearMike Bayer2014-01-051-1/+1
|
* - documentation cleanup in ORM including [ticket:2816]Mike Bayer2013-12-071-12/+40
|
* - Added new argument ``include_backrefs=True`` to theMike Bayer2013-12-021-6/+25
| | | | | | | :func:`.validates` function; when set to False, a validation event will not be triggered if the event was initated as a backref to an attribute operation from the other side. [ticket:1535] - break out validation tests into an updated module test_validators
* - Some refinements to the :class:`.AliasedClass` construct with regardsMike Bayer2013-11-231-14/+6
| | | | | | | | | | | | | | | 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]
* Fixed a potential issue in an ordered sequence implementation usedMike Bayer2013-08-181-0/+1
| | | | | | | by the ORM to iterate mapper hierarchies; under the Jython interpreter this implementation wasn't ordered, even though cPython and Pypy maintained ordering. Also in 0.8.3. [ticket:2794]
* - spot checking of imports, obsolete functionsMike Bayer2013-08-171-2/+1
|
* - apply an import refactoring to the ORM as wellMike Bayer2013-08-141-422/+7
| | | | | | | | | - 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
* remove double methodsMike Bayer2013-06-171-19/+0
|
* - rework PropComparator.adapted() to be PropComparator.adapt_to_entity(),Mike Bayer2013-06-171-81/+100
| | | | | | | 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]
* Fixed the interaction between composite attributes andMike Bayer2013-06-101-1/+0
| | | | | | the :func:`.aliased` function. Previously, composite attributes wouldn't work correctly in comparison operations when aliasing was applied. Also in 0.8.2. [ticket:2755]
* - tests for the alias() APIMike Bayer2013-06-081-0/+26
| | | | - docs docs docs
* - Fixed an obscure bug where the wrong results would beMike Bayer2013-06-071-2/+7
| | | | | | | | | | | fetched when joining/joinedloading across a many-to-many relationship to a single-table-inheriting subclass with a specific discriminator value, due to "secondary" rows that would come back. The "secondary" and right-side tables are now inner joined inside of parenthesis for all ORM joins on many-to-many relationships so that the left->right join can accurately filtered. [ticket:2369]
* dial back the default "flatness" a bit, it will be there for joinedload and ↵Mike Bayer2013-06-061-9/+11
| | | | | | | query.join(), but if you're dealing with aliased() or with_polymorphic() you need to say "flat=True". Just the one flag though, "flat" implies "aliased".
* - eager loadsMike Bayer2013-06-041-1/+1
| | | | - two suite of SQL assertions converted
* here's the flat join thing. it just works. Changing the existing compiled ↵Mike Bayer2013-06-041-2/+3
| | | | | | SQL assertions might even be most of the tests we need (though dedicated sql tests would be needed anyway)
* - blow away context._attributesMike Bayer2013-06-021-11/+11
| | | | | - to account for query._attributes/context.attributes, just pass the attributes dict directly to the PathRegistry methods
* repair py3kisms in key ORM modulesMike Bayer2013-05-261-5/+5
|
* merge defaultMike Bayer2013-05-131-1/+8
|\
| * Fixed a regression from 0.7 caused by this ticket, whichMike Bayer2013-05-131-1/+8
| | | | | | | | | | | | | | | | made the check for recursion overflow in self-referential eager joining too loose, missing a particular circumstance where a subclass had lazy="joined" or "subquery" configured and the load was a "with_polymorphic" against the base. [ticket:2481]
* | most of ORM passing...Mike Bayer2013-05-041-0/+1
| |
* | - the raw 2to3 runMike Bayer2013-04-271-12/+12
|/ | | | - went through examples/ and cleaned out excess list() calls
* we can always adapt to right also. suppose if rightMike Bayer2013-04-251-5/+1
| | | | were an alias of a table, should add tests for that.
* cleanupMike Bayer2013-04-251-51/+15
|
* everything passes with this!!!!!!! holy crap !!!!! and its the simplest of allMike Bayer2013-04-251-57/+69
|
* - attempt to replace the whole idea of "join_to_left" with a moreMike Bayer2013-04-241-10/+22
| | | | | fundamental and general purpose heuristic. this initial approach has about 60 tests failing but seems to have gone pretty far
* - Fixed bug in unit of work whereby a joined-inheritanceMike Bayer2013-04-011-0/+37
| | | | | | | | | | | subclass could insert the row for the "sub" table before the parent table, if the two tables had no ForeignKey constraints set up between them. Also in 0.7.11. [ticket:2689] - fix a glitch in the assertsql.CompiledSQL fixture regarding when a multiparam compiledSQL is used within an AllOf - add a new utility function randomize_unitofwork() which does the function of --reversetop
* - Added new helper function :func:`.was_deleted`, returns TrueMike Bayer2013-02-201-0/+21
| | | | | | | | | if the given object was the subject of a :meth:`.Session.delete` operation. - An object that's deleted from a session will be de-associated with that session fully after the transaction is committed, that is the :func:`.object_session` function will return None. [ticket:2658]
* happy new year (see #2645)Diana Clarke2013-01-011-1/+1
|