summaryrefslogtreecommitdiff
path: root/test/orm/test_query.py
Commit message (Collapse)AuthorAgeFilesLines
* - Added new method to the :func:`.insert` constructMike Bayer2013-07-051-1/+70
| | | | | | | | | | :meth:`.Insert.from_select`. Given a list of columns and a selectable, renders ``INSERT INTO (table) (columns) SELECT ..``. While this feature is highlighted as part of 0.9 it is also backported to 0.8.3. [ticket:722] - The :func:`.update`, :func:`.insert`, and :func:`.delete` constructs will now interpret ORM entities as FROM clauses to be operated upon, in the same way that select() already does. Also in 0.8.3.
* - rework of correlation, continuing on #2668, #2746Mike Bayer2013-06-261-26/+68
| | | | | | | | | | | | | | | | | | | | | | | | - add support for correlations to propagate all the way in; because correlations require context now, need to make sure a select enclosure of any level takes effect any number of levels deep. - fix what we said correlate_except() was supposed to do when we first released #2668 - "the FROM clause is left intact if the correlated SELECT is not used in the context of an enclosing SELECT..." - it was not considering the "existing_froms" collection at all, and prohibited additional FROMs from being placed in an any() or has(). - add test for multilevel any() - lots of docs, including glossary entries as we really need to define "WHERE clause", "columns clause" etc. so that we can explain correlation better - based on the insight that a SELECT can correlate anything that ultimately came from an enclosing SELECT that links to this one via WHERE/columns/HAVING/ORDER BY, have the compiler keep track of the FROM lists that correspond in this way, link it to the asfrom flag, so that we send to _get_display_froms() the exact list of candidate FROMs to correlate. no longer need any asfrom logic in the Select() itself - preserve 0.8.1's behavior for correlation when no correlate options are given, not to mention 0.7 and prior's behavior of not propagating implicit correlation more than one level.. this is to reduce surprises/hard-to-debug situations when a user isn't trying to correlate anything.
* remove all remaining start/end py2k/py3k blocksMike Bayer2013-06-071-20/+12
|
* - the raw 2to3 runMike Bayer2013-04-271-41/+42
| | | | - went through examples/ and cleaned out excess list() calls
* adding convenience method exists() to Query (see # 2673)Diana Clarke2013-03-291-0/+15
|
* - clean up entity correlation tests in test_queryMike Bayer2013-03-091-12/+17
|
* Changed behavior of Select.correlate() to ignore correlations to froms that ↵Luke Cyca2013-03-071-9/+15
| | | | don't exist in the superquery.
* Fixed bug whereby :meth:`.Query.yield_per` would set the executionMike Bayer2013-02-081-0/+11
| | | | | | options incorrectly, thereby breaking subsequent usage of the :meth:`.Query.execution_options` method. Courtesy Ryan Kelly. [ticket:2661]
* - adding in requirementsMike Bayer2013-02-061-8/+15
| | | | - get test_naturalpks to be more generalized
* - refactor of pathing mechanics, to address #2614, #2617Mike Bayer2012-12-011-17/+28
| | | | | | | | | | | | | | | | | | | - paths now store Mapper + MapperProperty now instead of string key, so that the parent mapper for the property is known, supports same-named properties on multiple subclasses - the Mapper within the path is now always relevant to the property to the right of it. PathRegistry does the translation now, instead of having all the outside users of PathRegistry worry about it, to produce a path that is much more consistent. Paths are now consistent with mappings in all cases. Special logic to get at "with_polymorphic" structures and such added also. - AliasedClass now has two modes, "use_mapper_path" and regular; "use_mapper_path" is for all those situations where we put an AliasedClass in for a plain class internally, and want it to "path" with the plain mapper. - The AliasedInsp is now the first class "entity" for an AliasedClass, and is passed around internally and used as attr._parententity and such. it is the AliasedClass analogue for Mapper.
* Fixed bug in type_coerce() whereby typing informationMike Bayer2012-11-121-2/+3
| | | | | | | | could be lost if the statement were used as a subquery inside of another statement, as well as other similar situations. Among other things, would cause typing information to be lost when the Oracle/mssql dialects would apply limit/offset wrappings. [ticket:2603]
* - [feature] The Query can now load entity/scalar-mixedMike Bayer2012-10-151-3/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | "tuple" rows that contain types which aren't hashable, by setting the flag "hashable=False" on the corresponding TypeEngine object in use. Custom types that return unhashable types (typically lists) can set this flag to False. [ticket:2592] - [bug] Applying a column expression to a select statement using a label with or without other modifying constructs will no longer "target" that expression to the underlying Column; this affects ORM operations that rely upon Column targeting in order to retrieve results. That is, a query like query(User.id, User.id.label('foo')) will now track the value of each "User.id" expression separately instead of munging them together. It is not expected that any users will be impacted by this; however, a usage that uses select() in conjunction with query.from_statement() and attempts to load fully composed ORM entities may not function as expected if the select() named Column objects with arbitrary .label() names, as these will no longer target to the Column objects mapped by that entity. [ticket:2591]
* - allow a __clause_element__() to be passed to query.filter() alsoMike Bayer2012-10-151-0/+9
|
* - [feature] "scalar" selects now have a WHERE methodMike Bayer2012-10-151-0/+20
| | | | | | | | | | | | | | | | | | | | to help with generative building. Also slight adjustment regarding how SS "correlates" columns; the new methodology no longer applies meaning to the underlying Table column being selected. This improves some fairly esoteric situations, and the logic that was there didn't seem to have any purpose. - [feature] Some support for auto-rendering of a relationship join condition based on the mapped attribute, with usage of core SQL constructs. E.g. select([SomeClass]).where(SomeClass.somerelationship) would render SELECT from "someclass" and use the primaryjoin of "somerelationship" as the WHERE clause. This changes the previous meaning of "SomeClass.somerelationship" when used in a core SQL context; previously, it would "resolve" to the parent selectable, which wasn't generally useful. Related to [ticket:2245].
* trying different approaches to test layout. in this one, the testing modulesMike Bayer2012-09-271-7/+6
| | | | | | | become an externally usable package but still remains within the main sqlalchemy parent package. in this system, we use kind of an ugly hack to get the noseplugin imported outside of the "sqlalchemy" package, while still making it available within sqlalchemy for usage by third party libraries.
* - got firebird runningMike Bayer2012-09-231-11/+1
| | | | | | | | | | | | - add some failure cases - [bug] Firebird now uses strict "ansi bind rules" so that bound parameters don't render in the columns clause of a statement - they render literally instead. - [bug] Support for passing datetime as date when using the DateTime type with Firebird; other dialects support this.
* - [bug] Fixed a regression since 0.6 regardingMike Bayer2012-08-311-9/+49
| | | | | | | | | | | | | | | | result-row targeting. It should be possible to use a select() statement with string based columns in it, that is select(['id', 'name']).select_from('mytable'), and have this statement be targetable by Column objects with those names; this is the mechanism by which query(MyClass).from_statement(some_statement) works. At some point the specific case of using select(['id']), which is equivalent to select([literal_column('id')]), stopped working here, so this has been re-instated and of course tested. [ticket:2558]
* - [feature] The "required" flag is set toMike Bayer2012-08-271-2/+4
| | | | | | | | | | True by default, if not passed explicitly, on bindparam() if the "value" or "callable" parameters are not passed. This will cause statement execution to check for the parameter being present in the final collection of bound parameters, rather than implicitly assigning None. [ticket:2556]
* - adjustments for py3.3 unit tests, [ticket:2542]Mike Bayer2012-08-111-17/+0
|
* - [feature] Added reduce_columns() methodMike Bayer2012-07-281-0/+17
| | | | | | | | | | | | | | | to select() construct, replaces columns inline using the util.reduce_columns utility function to remove equivalent columns. reduce_columns() also adds "with_only_synonyms" to limit the reduction just to those columns which have the same name. The deprecated fold_equivalents() feature is removed [ticket:1729]. - [feature] Added with_labels and reduce_columns keyword arguments to Query.subquery(), to provide two alternate strategies for producing queries with uniquely- named columns. [ticket:1729].
* - some more interpret_as_fromsMike Bayer2012-07-231-0/+18
|
* - [feature] ORM entities can be passedMike Bayer2012-07-231-0/+74
| | | | | | | to select() as well as the select_from(), correlate(), and correlate_except() methods, where they will be unwrapped into selectables. [ticket:2245]
* - with InstanceState more public, underscore all its methodsMike Bayer2012-07-181-61/+61
| | | | | that change object state as these aren't intended for public use.
* - [feature] The of_type() construct on attributesMike Bayer2012-06-201-43/+47
| | | | | | | | | | | | | | | | | | | | | | | | now accepts aliased() class constructs as well as with_polymorphic constructs, and works with query.join(), any(), has(), and also eager loaders subqueryload(), joinedload(), contains_eager() [ticket:2438] [ticket:1106] - a rewrite of the query path system to use an object based approach for more succinct usage. the system has been designed carefully to not add an excessive method overhead. - [feature] select() features a correlate_except() method, auto correlates all selectables except those passed. Is needed here for the updated any()/has() functionality. - remove some old cruft from LoaderStrategy, init(),debug_callable() - use a namedtuple for _extended_entity_info. This method should become standard within the orm internals - some tweaks to the memory profile tests, number of runs can be customized to work around pysqlite's very annoying behavior - try to simplify PropertyOption._get_paths(), rename to _process_paths(), returns a single list now. overall works more completely as was needed for of_type() functionality
* - [bug] Fixed bug in relationship comparisonsMike Bayer2012-04-251-0/+10
| | | | | | | whereby calling unimplemented methods like SomeClass.somerelationship.like() would produce a recursion overflow, instead of NotImplementedError.
* - [bug] column.label(None) now produces anMike Bayer2012-04-241-3/+3
| | | | | | anonymous label, instead of returning the column object itself, consistent with the behavior of label(column, None). [ticket:2168]
* - [bug] removed legacy behavior wherebyMike Bayer2012-04-241-2/+1
| | | | | | | | | | a column comparison to a scalar SELECT via == would coerce to an IN with the SQL server dialect. This is implicit behavior which fails in other scenarios so is removed. Code which relies on this needs to be modified to use column.in_(select) explicitly. [ticket:2277]
* merge patch for [ticket:2208]. This still needs documentation.Mike Bayer2012-04-231-39/+1
|\
| * begin implementing inspection system for #2208Mike Bayer2012-04-031-39/+1
| |
* | - merged #1401 branch from bitbucketMike Bayer2012-04-221-0/+8
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - resolved some serious speed hits I missed, we need to ensure only deannotated columns are used in the local/remote collections and soforth so that hash lookups against mapped columns don't dig into __eq__() - fix some other parity mismatches regarding stuff from [ticket:2453], including finding another case where _deep_annotate() was doing the wrong thing, new tests. - [feature] Major rewrite of relationship() internals now allow join conditions which include columns pointing to themselves within composite foreign keys. A new API for very specialized primaryjoin conditions is added, allowing conditions based on SQL functions, CAST, etc. to be handled by placing the annotation functions remote() and foreign() inline within the expression when necessary. Previous recipes using the semi-private _local_remote_pairs approach can be upgraded to this new approach. [ticket:1401]
| * - hooks in the new object to RelationshipProperty, restores the "local" ↵Mike Bayer2012-02-081-1/+1
| | | | | | | | | | | | annotation. also added in sync pairs, etc. many-to-many is currently broken.
| * initial annotations approach to join conditions. all tests pass, plus ↵Mike Bayer2012-02-061-0/+8
| | | | | | | | | | | | additional tests in #1401 pass. would now like to reorganize RelationshipProperty more around the annotations concept.
* | - 0.7.7Mike Bayer2012-03-201-0/+37
| | | | | | | | | | | | | | | | - [feature] Added prefix_with() method to Query, calls upon select().prefix_with() to allow placement of MySQL SELECT directives in statements. Courtesy Diana Clarke [ticket:2443]
* | - [feature] Added the ability to query forMike Bayer2012-02-121-0/+26
|/ | | | | | Table-bound column names when using query(sometable).filter_by(colname=value). [ticket:2400]
* - [bug] Raise an exception if xyzload_all() isMike Bayer2012-01-281-15/+34
| | | | | used inappropriately with two non-connected relationships. [ticket:2370]
* - [feature] query.filter() accepts multipleMike Bayer2012-01-071-0/+25
| | | | | criteria which will join via AND, i.e. query.filter(x==y, z>q, ...)
* - [bug] Fixed the error formatting raised whenMike Bayer2011-12-031-0/+7
| | | | | a tuple is inadvertently passed to session.query() [ticket:2297].
* - Cls.column.collate("some collation") nowMike Bayer2011-10-231-1/+10
| | | | works. [ticket:1776] Also in 0.6.9
* - The behavior of =/!= when comparing a scalar selectMike Bayer2011-09-231-1/+1
| | | | | | | | | | | to a value will no longer produce IN/NOT IN as of 0.8; this behavior is a little too heavy handed (use in_() if you want to emit IN) and now emits a deprecation warning. To get the 0.8 behavior immediately and remove the warning, a compiler recipe is given at http://www.sqlalchemy.org/docs/07/dialects/mssql.html#scalar-select-comparisons to override the behavior of visit_binary(). [ticket:2277]
* plus synonyms accessed as stringMike Bayer2011-09-191-1/+19
|
* - added "adapt_on_names" boolean flag to orm.aliased()Mike Bayer2011-09-191-0/+10
| | | | | | | | construct. Allows an aliased() construct to link the ORM entity to a selectable that contains aggregates or other derived forms of a particular attribute, provided the name is the same as that of the entity mapped column.
* orderingMike Bayer2011-09-151-1/+1
|
* - Fixed a variety of synonym()-related regressionsMike Bayer2011-09-151-4/+40
| | | | | | | | | | | | from 0.6: - making a synonym against a synonym now works. - synonyms made against a relationship() can be passed to query.join(), options sent to query.options(), passed by name to query.with_parent(). - revised the approach taken earlier to just propagate "property" out from the proxied attr the same way queryable attribute does.
* - Another previously unknown feature from 0.6, synonymsMike Bayer2011-09-151-2/+0
| | | | of relationship() can again be passed to join().
* - The join condition produced by with_parentMike Bayer2011-07-061-3/+64
| | | | | | | | as well as when using a "dynamic" relationship against a parent will generate unique bindparams, rather than incorrectly repeating the same bindparam. [ticket:2207]. Also in 0.6.9.
* - Repaired the "no statement condition"Mike Bayer2011-06-211-13/+19
| | | | | | | assertion in Query which would attempt to raise if a generative method were called after from_statement() were called. [ticket:2199]. Also in 0.6.9.
* - Fixed bug whereby comparison of columnMike Bayer2011-06-121-35/+43
| | | | | | | | | expression to a Query() would not call as_scalar() on the underlying SELECT statement to produce a scalar subquery, in the way that occurs if you called it on Query().subquery(). [ticket:2190] - some cleanup to test.orm.test_query
* - use default dialect hereMike Bayer2011-05-141-5/+3
|
* - query.count() emits "count(*)" instead ofMike Bayer2011-05-101-1/+19
| | | | | "count(1)". [ticket:2162] - another test that should be excluded from "low-connections"
* - rework of Query._adapt_clause to support [ticket:2155],Mike Bayer2011-04-301-0/+31
| | | | | | | | | | | | | be clearer in its intent. - Fine tuning of Query clause adaptation when from_self(), union(), or other "select from myself" operation, such that plain SQL expression elements added to filter(), order_by() etc. which are present in the nested "from myself" query *will* be adapted in the same way an ORM expression element will, since these elements are otherwise not easily accessible. [ticket:2155]