summaryrefslogtreecommitdiff
path: root/test/orm/query.py
Commit message (Collapse)AuthorAgeFilesLines
* - unit tests have been migrated from unittest to nose.Mike Bayer2009-06-101-3012/+0
| | | | | See README.unittests for information on how to run the tests. [ticket:970]
* - Fixed Query being able to join() from individual columns ofMike Bayer2009-06-051-0/+10
| | | | | | | | | | a joined-table subclass entity, i.e. query(SubClass.foo, SubcClass.bar).join(<anything>). In most cases, an error "Could not find a FROM clause to join from" would be raised. In a few others, the result would be returned in terms of the base class rather than the subclass - so applications which relied on this erroneous result need to be adjusted. [ticket:1431]
* - removed test.testing.ORMTest, test.fixtures, and allMike Bayer2009-06-021-202/+159
| | | | dependencies on those.
* - Significant performance enhancements regarding Sessions/flush()Mike Bayer2009-05-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in conjunction with large mapper graphs, large numbers of objects: - The Session's "weak referencing" behavior is now *full* - no strong references whatsoever are made to a mapped object or related items/collections in its __dict__. Backrefs and other cycles in objects no longer affect the Session's ability to lose all references to unmodified objects. Objects with pending changes still are maintained strongly until flush. [ticket:1398] The implementation also improves performance by moving the "resurrection" process of garbage collected items to only be relevant for mappings that map "mutable" attributes (i.e. PickleType, composite attrs). This removes overhead from the gc process and simplifies internal behavior. If a "mutable" attribute change is the sole change on an object which is then dereferenced, the mapper will not have access to other attribute state when the UPDATE is issued. This may present itself differently to some MapperExtensions. The change also affects the internal attribute API, but not the AttributeExtension interface nor any of the publically documented attribute functions. - The unit of work no longer genererates a graph of "dependency" processors for the full graph of mappers during flush(), instead creating such processors only for those mappers which represent objects with pending changes. This saves a tremendous number of method calls in the context of a large interconnected graph of mappers. - Cached a wasteful "table sort" operation that previously occured multiple times per flush, also removing significant method call count from flush(). - Other redundant behaviors have been simplified in mapper._save_obj().
* this falls back to "expire" in any case since concat_op is not supported by ↵Mike Bayer2009-05-021-1/+1
| | | | the evaluator
* Query.update() and Query.delete() should turn off eagerloads. Fixes #1378.Ants Aasma2009-04-201-0/+51
|
* - An alias() of a select() will convert to a "scalar subquery"Mike Bayer2009-03-211-2/+11
| | | | | | when used in an unambiguously scalar context, i.e. it's used in a comparison operation. This applies to the ORM when using query.subquery() as well.
* - Query.group_by() properly takes into account aliasing appliedMike Bayer2009-03-081-0/+14
| | | | | to the FROM clause, such as with select_from(), using with_polymorphic(), or using from_self().
* unit test fixesMike Bayer2009-01-281-7/+9
|
* - Query now implements __clause_element__() which producesMike Bayer2009-01-271-3/+43
| | | | | | | | | | its selectable, which means a Query instance can be accepted in many SQL expressions, including col.in_(query), union(query1, query2), select([foo]).select_from(query), etc. - the __selectable__() interface has been replaced entirely by __clause_element__().
* - refined and clarified query.__join() for readabilityrel_0_5_2Mike Bayer2009-01-241-0/+36
| | | | | | | | | | - _ORMJoin() gets a new flag join_to_left to specify if we really want to alias from the existing left side or not. eager loading wants this flag off in almost all cases, query.join() usually wants it on. - query.join()/outerjoin() will now properly join an aliased() construct to the existing left side, even if query.from_self() or query.select_from(someselectable) has been called. [ticket:1293]
* - The "clear()", "save()", "update()", "save_or_update()"Mike Bayer2009-01-171-38/+38
| | | | | | Session methods have been deprecated, replaced by "expunge_all()" and "add()". "expunge_all()" has also been added to ScopedSession.
* - Query.from_self() as well as query.subquery() both disableMike Bayer2009-01-151-2/+66
| | | | | | | | | | | | | the rendering of eager joins inside the subquery produced. The "disable all eager joins" feature is available publically via a new query.enable_eagerloads() generative. [ticket:1276] - Added a rudimental series of set operations to Query that receive Query objects as arguments, including union(), union_all(), intersect(), except_(), insertsect_all(), except_all(). See the API documentation for Query.union() for examples. - Fixed bug that prevented Query.join() and eagerloads from attaching to a query that selected from a union or aliased union.
* - query.join() raises an error when the target of the joinMike Bayer2009-01-061-0/+32
| | | | | | doesn't match the property-based attribute - while it's unlikely anyone is doing this, the SQLAlchemy author was guilty of this particular loosey-goosey behavior.
* added order_by test coverage as per [ticket:1218]Mike Bayer2009-01-031-0/+20
|
* - Fixed some deep "column correspondence" issues which couldMike Bayer2009-01-031-1/+14
| | | | | | | | impact a Query made against a selectable containing multiple versions of the same table, as well as unions and similar which contained the same table columns in different column positions at different levels. [ticket:1268]
* - Can pass mapped attributes and column objects as keysMike Bayer2008-12-281-1/+9
| | | | | | | | | to query.update({}). [ticket:1262] - Mapped attributes passed to the values() of an expression level insert() or update() will use the keys of the mapped columns, not that of the mapped attribute.
* - Query() can be passed a "composite" attributeMike Bayer2008-12-181-24/+6
| | | | | | | | | | | | | | | | | | | | | | | as a column expression and it will be expanded. Somewhat related to [ticket:1253]. - Query() is a little more robust when passed various column expressions such as strings, clauselists, text() constructs (which may mean it just raises an error more nicely). - select() can accept a ClauseList as a column in the same way as a Table or other selectable and the interior expressions will be used as column elements. [ticket:1253] - removed erroneous FooTest from test/orm/query -This line, and those below, will be ignored-- M test/orm/query.py M test/orm/mapper.py M test/sql/select.py M lib/sqlalchemy/orm/query.py M lib/sqlalchemy/sql/expression.py M CHANGES
* Modified fails_on testing decorator to take a reason for the failure.Michael Trier2008-12-121-4/+4
| | | | | This should assist with helping to document the reasons for testing failures. Currently unspecified failures are defaulted to 'FIXME: unknown'.
* Broke out a specific values test and indicated that it fails on mssql due to ↵Michael Trier2008-12-121-4/+12
| | | | duplicate columns in the order by clause.
* Corrected problem with bindparams not working properly with Query.delete and ↵Michael Trier2008-12-111-1/+22
| | | | Query.update. Thanks zzzeek. Fixes #1242.
* - first() works as expected with Query.from_statement().Mike Bayer2008-12-101-16/+4
|
* - Comparison of many-to-one relation to NULL isMike Bayer2008-11-211-1/+11
| | | | properly converted to IS NOT NULL based on not_().
* - Query.select_from(), from_statement() ensureMike Bayer2008-11-161-0/+27
| | | | | | | | that the given argument is a FromClause, or Text/Select/Union, respectively. - Query.add_column() can accept FromClause objects in the same manner as session.query() can.
* Pulled out values test that uses boolean evaluation in the SELECT in order ↵Michael Trier2008-11-141-4/+10
| | | | to appropriately flag it as not supported on mssql. I sure hope I didn't jack things up for other dialects. Cleaned up a comment and removed some commented pdb statements.
* Fixed up a lot of missing order_by statements in the tests when using ↵Michael Trier2008-11-141-9/+9
| | | | offset. A lot of dialects don't really require order_by although you'll get unpredictable results. mssql does require order_by with an offset, so this fixes problems with that dialect.
* The str(query) output is also correct on the mssql dialect.Michael Trier2008-11-141-1/+1
|
* - Restored NotImplementedError on Cls.relation.in_()Mike Bayer2008-11-101-0/+3
| | | | [ticket:1140] [ticket:1221]
* - Query.count() has been enhanced to do the "rightMike Bayer2008-11-091-4/+45
| | | | | | | | | | | | | | thing" in a wider variety of cases. It can now count multiple-entity queries, as well as column-based queries. Note that this means if you say query(A, B).count() without any joining criterion, it's going to count the cartesian product of A*B. Any query which is against column-based entities will automatically issue "SELECT count(1) FROM (SELECT...)" so that the real rowcount is returned, meaning a query such as query(func.count(A.name)).count() will return a value of one, since that query would return one row.
* - Query.count() and Query.get() return a more informativeMike Bayer2008-11-081-0/+8
| | | | | error message when executed against multiple entities. [ticket:1220]
* - Fixed bug in Query involving order_by() in conjunction withMike Bayer2008-11-061-2/+2
| | | | | | | | | | | | | | | | multiple aliases of the same class (will add tests in [ticket:1218]) - Added a new extension sqlalchemy.ext.serializer. Provides Serializer/Deserializer "classes" which mirror Pickle/Unpickle, as well as dumps() and loads(). This serializer implements an "external object" pickler which keeps key context-sensitive objects, including engines, sessions, metadata, Tables/Columns, and mappers, outside of the pickle stream, and can later restore the pickle using any engine/metadata/session provider. This is used not for pickling regular object instances, which are pickleable without any special logic, but for pickling expression objects and full Query objects, such that all mapper/engine/session dependencies can be restored at unpickle time.
* Added a label for pg.Jason Kirtland2008-11-031-1/+1
|
* - Fixed bug when using multiple query.join() with an aliased-boundMike Bayer2008-11-031-2/+12
| | | | descriptor which would lose the left alias.
* - Improved the behavior of aliased() objects such that they moreMike Bayer2008-11-031-44/+52
| | | | | | | | | | | accurately adapt the expressions generated, which helps particularly with self-referential comparisons. [ticket:1171] - Fixed bug involving primaryjoin/secondaryjoin conditions constructed from class-bound attributes (as often occurs when using declarative), which later would be inappropriately aliased by Query, particularly with the various EXISTS based comparators.
* Added tests for Query.scalar(), .value() [ticket:1163]Jason Kirtland2008-11-031-1/+21
|
* revert r5220 inadvertently committed to trunkMike Bayer2008-11-021-50/+37
|
* progress so farMike Bayer2008-11-021-37/+50
|
* Corrected some ordering issues with tests.Michael Trier2008-11-021-6/+5
|
* - When using Query.join() with an explicit clause for theMike Bayer2008-10-251-0/+18
| | | | | | | ON clause, the clause will be aliased in terms of the left side of the join, allowing scenarios like query(Source). from_self().join((Dest, Source.id==Dest.source_id)) to work properly.
* - "not equals" comparisons of simple many-to-one relationMike Bayer2008-10-181-1/+11
| | | | | | | | | | | | | | | to an instance will not drop into an EXISTS clause and will compare foreign key columns instead. - removed not-really-working use cases of comparing a collection to an iterable. Use contains() to test for collection membership. - Further simplified SELECT compilation and its relationship to result row processing. - Direct execution of a union() construct will properly set up result-row processing. [ticket:1194]
* - fix outerjoin, add order_by for DB varianceMike Bayer2008-10-041-4/+3
|
* - using contains_eager() against an alias combined with an overall query ↵Mike Bayer2008-10-041-7/+51
| | | | | | | | | | | | alias repaired - the contains_eager adapter wraps the query adapter, not vice versa. Test coverage added. - contains_eager() will now add columns into the "primary" column collection within Query._compile_context(), instead of the "secondary" collection. This allows those columns to get wrapped within the subquery generated by limit/offset in conjunction with an ORM-generated eager join. Eager strategy also picks up on context.adapter in this case to deliver the columns during result load. contains_eager() is now compatible with the subquery generated by a regular eager load with limit/offset. [ticket:1180]
* - Fixed up slices on Query (i.e. query[x:y]) to work properlyMike Bayer2008-09-281-1/+41
| | | | | for zero length slices, slices with None on either end. [ticket:1177]
* more failing casesMike Bayer2008-09-181-2/+59
|
* - "non-batch" mode in mapper(), a feature which allowsMike Bayer2008-09-181-4/+78
| | | | | | | mapper extension methods to be called as each instance is updated/inserted, now honors the insert order of the objects given. - added some tests, some commented out, involving [ticket:1171]
* - Added scalar() and value() methods to Query, each return aMike Bayer2008-09-111-0/+1
| | | | | | | single scalar value. scalar() takes no arguments and is roughly equivalent to first()[0], value() takes a single column expression and is roughly equivalent to values(expr).next()[0].
* - The exists() construct won't "export" its contained listMike Bayer2008-09-081-1/+1
| | | | | | | | | of elements as FROM clauses, allowing them to be used more effectively in the columns clause of a SELECT. - and_() and or_() now generate a ColumnElement, allowing boolean expressions as result columns, i.e. select([and_(1, 0)]). [ticket:798]
* - query.order_by().get() silently drops the "ORDER BY" fromMike Bayer2008-09-061-0/+6
| | | | the query issued by GET but does not raise an exception.
* Make Query.update and Query.delete return the amount of rows matchedAnts Aasma2008-09-021-0/+17
|
* - expire/fetch strategies are now default for Query.update/Query.delete.Ants Aasma2008-08-251-5/+5
| | | | - added API docs for Query.update/Query.delete