summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/query.py
Commit message (Collapse)AuthorAgeFilesLines
* Rename Query._mapper_zero() to Query._entity_zero()Mike Bayer2016-04-191-17/+15
| | | | | | | | | | | | To be more descriptive of the use of _mapper_zero(), rename it to _entity_zero(), but also supply a new _mapper_zero() function that more strictly returns a mapper. The existing _entity_zero() function is renamed to _query_entity_zero. _only_mapper_zero() is removed as it isn't used. Divide up the existing calling functions to refer to the appropriate new method. Change-Id: I8780c3235e87b4936c6daf64d9d299b22b6e1260 Fixes: #3608
* - Added support for rendering "FULL OUTER JOIN" to both Core and ORM.Mike Bayer2016-03-281-13/+21
| | | | Pull request courtesy Stefan Urbanek. fixes #1957
* Adds documentation to Query.slice().pr/247jfinkels2016-03-131-3/+28
|
* - An improvement to the workings of :meth:`.Query.correlate` suchMike Bayer2016-02-251-5/+8
| | | | | | | that when a "polymorphic" entity is used which represents a straight join of several tables, the statement will ensure that all the tables within the join are part of what's correlating. fixes #3662
* - CTE functionality has been expanded to support all DML, allowingMike Bayer2016-02-111-3/+1
| | | | | | | INSERT, UPDATE, and DELETE statements to both specify their own WITH clause, as well as for these statements themselves to be CTE expressions when they include a RETURNING clause. fixes #2551
* - A refinement to the logic which adds columns to the resulting SQL whenMike Bayer2016-02-091-15/+11
| | | | | | | | | | | | | :meth:`.Query.distinct` is combined with :meth:`.Query.order_by` such that columns which are already present will not be added a second time, even if they are labeled with a different name. Regardless of this change, the extra columns added to the SQL have never been returned in the final result, so this change only impacts the string form of the statement as well as its behavior when used in a Core execution context. Additionally, columns are no longer added when the DISTINCT ON format is used, provided the query is not wrapped inside a subquery due to joined eager loading. fixes #3641
* - happy new yearMike Bayer2016-01-291-1/+1
|
* - The ``str()`` call for :class:`.Query` will now take into accountMike Bayer2016-01-191-7/+20
| | | | | | | | | | | | the :class:`.Engine` to which the :class:`.Session` is bound, when generating the string form of the SQL, so that the actual SQL that would be emitted to the database is shown, if possible. Previously, only the engine associated with the :class:`.MetaData` to which the mappings are associated would be used, if present. If no bind can be located either on the :class:`.Session` or on the :class:`.MetaData` to which the mappings are associated, then the "default" dialect is used to render the SQL, as was the case previously. fixes #3081
* - Fixed bug where use of the :meth:`.Query.select_from` method wouldMike Bayer2015-12-121-1/+5
| | | | | | cause a subsequent call to the :meth:`.Query.with_parent` method to fail. fixes #3606 - add mark-as-fail test for #3607
* - write a real inline documentation section for from_self(),Mike Bayer2015-12-071-2/+163
| | | | | building on the example of query.join(). Ideally all the methods in Query would have this kind of thing. fixes #3544
* - Added support for parameter-ordered SET clauses in an UPDATEMike Bayer2015-11-281-2/+8
| | | | | | | | | | statement. This feature is available by passing the :paramref:`~.sqlalchemy.sql.expression.update.preserve_parameter_order` flag either to the core :class:`.Update` construct or alternatively adding it to the :paramref:`.Query.update.update_args` dictionary at the ORM-level, also passing the parameters themselves as a list of 2-tuples. Thanks to Gorka Eguileor for implementation and tests. adapted from pullreq github:200
* - Fixed bug where the "single table inheritance" criteria would beMike Bayer2015-11-111-1/+1
| | | | | | | added onto the end of a query in some inappropriate situations, such as when querying from an exists() of a single-inheritance subclass. fixes #3582
* - try to make this language more succinct and fix linksMike Bayer2015-10-201-24/+8
| | | | (cherry picked from commit 3ffe8569fbaa72c2d844604b600c4661097339eb)
* Merge remote-tracking branch 'origin/pr/203'Mike Bayer2015-10-091-8/+7
|\
| * Remplement Query.one() in terms of .one_or_none()pr/203Eric Siegerman2015-09-281-8/+7
| | | | | | Thanks to Mike Bayer for suggesting a simpler refactoring.
* | Merge remote-tracking branch 'origin/pr/205'Mike Bayer2015-10-091-0/+12
|\ \
| * | Doc fixpr/205Eric Siegerman2015-09-281-0/+12
| |/
* | - remove ambiguous use of the phrase "joined together by AND" as thisMike Bayer2015-10-011-5/+6
|/ | | | | | | may be construed as the Python "and" keyword - add notes to ORM tutorial for beginners that Python "and" keyword is not to be used fixes #3545
* - replicate Query.one_or_none to BakedQueryMike Bayer2015-09-241-2/+10
| | | | - changelog / version note finishing
* Add Query.one_or_none()pr/201Eric Siegerman2015-09-241-0/+32
|
* - add a note about DISTINCT in query w/ ORDER BY, references #3518Mike Bayer2015-08-311-0/+13
|
* - merge of ticket_3499 indexed access branchMike Bayer2015-08-171-10/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - The "hashable" flag on special datatypes such as :class:`.postgresql.ARRAY`, :class:`.postgresql.JSON` and :class:`.postgresql.HSTORE` is now set to False, which allows these types to be fetchable in ORM queries that include entities within the row. fixes #3499 - The Postgresql :class:`.postgresql.ARRAY` type now supports multidimensional indexed access, e.g. expressions such as ``somecol[5][6]`` without any need for explicit casts or type coercions, provided that the :paramref:`.postgresql.ARRAY.dimensions` parameter is set to the desired number of dimensions. fixes #3487 - The return type for the :class:`.postgresql.JSON` and :class:`.postgresql.JSONB` when using indexed access has been fixed to work like Postgresql itself, and returns an expression that itself is of type :class:`.postgresql.JSON` or :class:`.postgresql.JSONB`. Previously, the accessor would return :class:`.NullType` which disallowed subsequent JSON-like operators to be used. part of fixes #3503 - The :class:`.postgresql.JSON`, :class:`.postgresql.JSONB` and :class:`.postgresql.HSTORE` datatypes now allow full control over the return type from an indexed textual access operation, either ``column[someindex].astext`` for a JSON type or ``column[someindex]`` for an HSTORE type, via the :paramref:`.postgresql.JSON.astext_type` and :paramref:`.postgresql.HSTORE.text_type` parameters. also part of fixes #3503 - The :attr:`.postgresql.JSON.Comparator.astext` modifier no longer calls upon :meth:`.ColumnElement.cast` implicitly, as PG's JSON/JSONB types allow cross-casting between each other as well. Code that makes use of :meth:`.ColumnElement.cast` on JSON indexed access, e.g. ``col[someindex].cast(Integer)``, will need to be changed to call :attr:`.postgresql.JSON.Comparator.astext` explicitly. This is part of the refactor in references #3503 for consistency in operator use.
* - add a note clarifying query.with_labels(), fixes #3506Mike Bayer2015-08-031-0/+10
|
* Added max_row_buffer attribute to the context execution options and usepr/182Morgan McClure2015-06-131-1/+2
| | | | it to prevent excess memory usage with yield_per
* - Fixed an unexpected-use regression whereby custom :class:`.Comparator`Mike Bayer2015-06-111-2/+6
| | | | | | | | | | objects that made use of the ``__clause_element__()`` method and returned an object that was an ORM-mapped :class:`.InstrumentedAttribute` and not explicitly a :class:`.ColumnElement` would fail to be correctly handled when passed as an expression to :meth:`.Session.query`. The logic in 0.9 happened to succeed on this, so this use case is now supported. fixes #3448
* - Repaired / added to tests yet more expressions that were reportedMike Bayer2015-05-011-4/+13
| | | | | | | | | as failing with the new 'entity' key value added to :attr:`.Query.column_descriptions`, the logic to discover the "from" clause is again reworked to accommodate columns from aliased classes, as well as to report the correct value for the "aliased" flag in these cases. fixes #3409
* - Fixed regression from as yet unreleased 0.9.10 where the new additionMike Bayer2015-04-301-1/+1
| | | | | | | of ``entity`` to the :attr:`.Query.column_descriptions` accessor would fail if the target entity was produced from a core selectable such as a :class:`.Table` or :class:`.CTE` object. fixes #3403 references #3320
* - Fixed issue in new :meth:`.QueryEvents.before_compile` event whereMike Bayer2015-04-261-1/+1
| | | | | | | changes made to the :class:`.Query` object's collection of entities to load within the event would render in the SQL, but would not be reflected during the loading process. fixes #3387
* - Identified an inconsistency when handling :meth:`.Query.join` to theMike Bayer2015-04-151-1/+7
| | | | | | | | | | | same target more than once; it implicitly dedupes only in the case of a relationship join, and due to :ticket:`3233`, in 1.0 a join to the same table twice behaves differently than 0.9 in that it no longer erroneously aliases. To help document this change, the verbiage regarding :ticket:`3233` in the migration notes has been generalized, and a warning has been added when :meth:`.Query.join` is called against the same target relationship more than once. fixes #3367
* - changelog + docstring for pullreq github:164Mike Bayer2015-04-031-0/+7
|
* Merge remote-tracking branch 'origin/pr/164' into pr164Mike Bayer2015-04-031-2/+3
|\
| * Allow kwargs to be passed through update()pr/164Amir Sadoughi2015-03-201-2/+3
| | | | | | | | | | This is useful to be able to pass in mysql_limit=1 from using the ORM.
* | - :class:`.Query` doesn't support joins, subselects, or specialMike Bayer2015-04-011-16/+0
|/ | | | | | | | | | | | | | | FROM clauses when using the :meth:`.Query.update` or :meth:`.Query.delete` methods; instead of silently ignoring these fields if methods like :meth:`.Query.join` or :meth:`.Query.select_from` has been called, an error is raised. In 0.9.10 this only emits a warning. fixes #3349 - don't needlessly call _compile_context() and build up a whole statement that we never need. Construct QueryContext as it's part of the event contract, but don't actually call upon mapper attributes; use more direct systems of determining the update or delete table. - don't realy need _no_select_modifiers anymore
* - fix a get call here, we should figure this out since we dont wantMike Bayer2015-03-121-1/+1
| | | | to be using getattr
* - Added a new extension suite :mod:`sqlalchemy.ext.baked`. ThisMike Bayer2015-03-111-30/+57
| | | | | | | | simple but unusual system allows for a dramatic savings in Python overhead for the construction and processing of orm :class:`.Query` objects, from query construction up through rendering of a string SQL statement. fixes #3054
* - Added a new entry ``"entity"`` to the dictionaries returned byMike Bayer2015-03-111-2/+8
| | | | | | | | | :attr:`.Query.column_descriptions`. This refers to the primary ORM mapped class or aliased class that is referred to by the expression. Compared to the existing entry for ``"type"``, it will always be a mapped entity, even if extracted from a column expression, or None if the given expression is a pure core expression. references #3320
* - Added a new event suite :class:`.QueryEvents`. TheMike Bayer2015-03-101-4/+9
| | | | | | | | | | | :meth:`.QueryEvents.before_compile` event allows the creation of functions which may place additional modifications to :class:`.Query` objects before the construction of the SELECT statement. It is hoped that this event be made much more useful via the advent of a new inspection system that will allow for detailed modifications to be made against :class:`.Query` objects in an automated fashion. fixes #3317
* - copyright 2015Mike Bayer2015-03-101-1/+1
|
* - pick around gaining modest dings in callcounts here and thereMike Bayer2015-03-091-15/+17
|
* - random performance whacking vs. 0.9, in particular we have to watchMike Bayer2015-03-081-0/+6
| | | | for the slots-based __getattr__ thing getting hit
* - squash-merge the final row_proc integration branch. this isMike Bayer2015-03-011-46/+20
| | | | | | | | | | | | | | | a much more modest outcome than what we started with. The work of create_row_processor() for ColumnProperty objects is essentially done at query setup time combined with some lookups in _instance_processor(). - to allow this change for deferred columns, deferred columns no longer search for themselves in the result. If they've been set up as deferred without any explicit directive to undefer them, then this is what was asked for. if we don't do this, then we're stuck with this performance penalty for all deferred columns which in the vast majority of typical use cases (e.g. loading large, legacy tables or tables with many/large very seldom used values) won't be present in the result and won't be accessed at all.
* - remove meaningless assignmentMike Bayer2015-02-081-1/+0
|
* - test + changelogMike Bayer2015-02-081-2/+2
|
* Merge remote-tracking branch 'origin/pr/147' into pr147Mike Bayer2015-02-081-1/+1
|\ | | | | | | | | Conflicts: lib/sqlalchemy/orm/query.py
| * It's the 'kwargs' which are iterable, not 'keys'pr/147Malthe Borch2014-10-301-2/+1
| |
* | - restore r611883ffb35ca6664649f6328ae8 with additional fixes and an ↵Mike Bayer2015-01-191-13/+30
| | | | | | | | | | | | additional test that is much more specific to #1326
* | - reverse the last commit temporarily as it breaks all the polymorphic casesMike Bayer2015-01-191-34/+20
| |
* | - The primary :class:`.Mapper` of a :class:`.Query` is now passed to theMike Bayer2015-01-191-20/+34
| | | | | | | | | | | | | | | | | | | | | | :meth:`.Session.get_bind` method when calling upon :meth:`.Query.count`, :meth:`.Query.update`, :meth:`.Query.delete`, as well as queries against mapped columns, :obj:`.column_property` objects, and SQL functions and expressions derived from mapped columns. This allows sessions that rely upon either customized :meth:`.Session.get_bind` schemes or "bound" metadata to work in all relevant cases. fixes #3227 fixes #3242 fixes #1326
* | - tighten the inspection in _ColumnEntity to reduce unnecessaryMike Bayer2015-01-031-14/+14
| | | | | | | | isinstance() calls, express intent more clearly
* | - fix links for loading, add a redirect pageMike Bayer2014-12-271-2/+2
| | | | | | | | | | | | bump foo