Commit Graph

97 Commits

Author SHA1 Message Date
Mike Bayer 2829092cb8 - Improved the determination of the FROM clause
when placing SQL expressions in the query()
list of entities.  In particular scalar subqueries
should not "leak" their inner FROM objects out
into the enclosing query.
2008-08-06 20:58:48 +00:00
Mike Bayer 4cd1902796 - The RowTuple object returned by Query(*cols) now
features keynames which prefer mapped attribute
names over column keys, column keys over
column names, i.e.
Query(Class.foo, Class.bar) will have names
"foo" and "bar" even if those are not the names
of the underlying Column objects.  Direct
Column objects such as Query(table.c.col) will
return the "key" attribute of the Column.
2008-08-05 20:15:28 +00:00
Jason Kirtland b155b60280 - Spiffed up the deprecated decorators & @flipped 'em up top 2008-07-16 17:34:41 +00:00
Ants Aasma c571fd6f8a Ugh, learning to use git-svn, [4884] was not supposed to go upstream. Reverting. 2008-07-01 17:00:51 +00:00
Ants Aasma c33e7c7bfa query update and delete need to autoflush 2008-07-01 16:51:14 +00:00
Mike Bayer 8755dc3d66 - fixed up vertical.py
- Fixed query.join() when used in conjunction with a
columns-only clause and an SQL-expression
ON clause in the join.
2008-06-28 15:23:08 +00:00
Gaëtan de Menten d0c243711b session.Query().iterate_instances() has been renamed to just instances(). The old instances() method returning a list instead of an iterator no longer
exists. If you were relying on that behavior, you should use `list(your_query.instances())`.
2008-06-25 15:55:49 +00:00
Mike Bayer 22fcee0e07 - Repaired __str__() method on Query. [ticket:1066] 2008-06-24 19:27:32 +00:00
Mike Bayer 3cd10102e4 - Query.UpdateDeleteTest.test_delete_fallback fails on mysql due to subquery in DELETE; not sure how to do this exact operation in MySQL
- added query_cls keyword argument to sessionmaker(); allows user-defined Query subclasses to be generated by query().
- added @attributes.on_reconstitute decorator, MapperExtension.on_reconstitute, both receieve 'on_load' attribute event allowing
non-__init__ dependent instance initialization routines.
- push memusage to the top to avoid pointless heisenbugs
- renamed '_foostate'/'_fooclass_manager' to '_sa_instance_state'/'_sa_class_manager'
- removed legacy instance ORM state accessors
- query._get() will use _remove_newly_deleted instead of expunge() on ObjectDeleted, so that transaction rollback
restores the previous state
- removed MapperExtension.get(); replaced by a user-defined Query subclass
- removed needless **kwargs from query.get()
- removed Session.get(cls, id); this is redundant against Session.query(cls).get(id)
- removed Query.load() and Session.load(); the use case for this method has never been clear, and the same functionality is available in more explicit ways
2008-06-09 01:24:08 +00:00
Mike Bayer e525aee015 - removed query.min()/max()/sum()/avg(). these should be called using column arguments or values in conjunction with func.
- fixed [ticket:1008], count() works with single table inheritance
- changed the relationship of InstrumentedAttribute to class such that each subclass in an inheritance hierarchy gets a unique InstrumentedAttribute per column-oriented attribute, including for the same underlying ColumnProperty.  This allows expressions from subclasses to be annotated accurately so that Query can get a hold of the exact entities to be queried when using column-based expressions.  This repairs various polymorphic scenarios with both single and joined table inheritance.
- still to be determined is what does something like query(Person.name, Engineer.engineer_info) do; currently it's problematic.  Even trickier is query(Person.name, Engineer.engineer_info, Manager.manager_name)
2008-06-02 03:07:12 +00:00
Mike Bayer e3e1535720 merged r4829 of rel_0_4, [ticket:1058] 2008-06-01 14:15:41 +00:00
Mike Bayer 59c1887945 - improved the attribute and state accounting performed by query.update() and query.delete()
- added autoflush support to same
2008-05-29 14:45:40 +00:00
Jason Kirtland ff7574ffa3 - Lengthless String type 2008-05-29 02:42:58 +00:00
Ants Aasma 87718fa82b Add delete and update methods to query 2008-05-29 02:12:17 +00:00
Mike Bayer 4a742751d5 - removed info about _local_remote_pairs from PropertyLoader.__determine_fks
- added order_by(), group_by(), having() to the list of "no offset()/limit()", [ticket:851]
2008-05-24 17:37:58 +00:00
Mike Bayer d4f2a5d6c5 some order by's failing on the buildbot 2008-05-18 15:55:58 +00:00
Mike Bayer fa56f0acb4 - added test for threadlocal not supporting begin_nested()
- removed query.compile(); use explicit query.with_labels().statement instead
- moved statement annotation step upwards from query._compile_context() to outliers from_self()/statement.  speeds zoomark.step_6_editing by 16%
2008-05-18 15:49:14 +00:00
Mike Bayer 07496da9b5 - added some help for a heavily flush-order-dependent test
- quote flag propagates to _Label, [ticket:1045]
2008-05-16 22:10:04 +00:00
Mike Bayer 806c7024b3 a particular test which fails in 0.4 2008-05-16 21:27:15 +00:00
Jason Kirtland dd20ca5cb9 - Removed @unsupported 2008-05-14 22:09:23 +00:00
Jason Kirtland 81b1df8fe1 Query.one() raises either NoResultFound or MultipleResultsFound, [ticket:1034] 2008-05-14 20:44:16 +00:00
Mike Bayer ac934fc533 - renamed query.slice_() to query.slice()
- pulled out DeclarativeMeta.__init__ into its own function, added instrument_declarative()
which will do the "declarative" thing to any class independent of its lineage (for ctheune)
- added "cls" kwarg to declarative_base() allowing user-defined base class for declarative base [ticket:1042]
2008-05-13 20:35:41 +00:00
Mike Bayer 17684a1b81 - LIMIT/OFFSET of zero is detected within compiler and is counted
- Query.__getitem__ now returns list/scalar in all cases, not generative (#1035)
- added Query.slice_() which provides the simple "limit/offset from a positive range" operation,
we can rename this to range_()/section()/_something_private_because_users_shouldnt_do_this() as needed
2008-05-13 19:55:49 +00:00
Mike Bayer b0fd5ac899 scaled back the equivalents determined in _equivalent_columns to just current polymorphic_union
behavior, fixes [ticket:1041]
2008-05-12 22:44:04 +00:00
Mike Bayer e02114ce49 - clause adaption hits _raw_columns of a select() (though no ORM tests need this feature currently)
- broke up adapter chaining in eagerload, erroneous "wrapping" in row_decorator.  column_property() subqueries are now affected only by the ORMAdapter for that mapper.  fixes [ticket:1037], and may possibly impact some of [ticket:949]
2008-05-12 16:15:28 +00:00
Mike Bayer d3621ae961 - fixed a fairly critical bug in clause adaption/corresponding column in conjunction with annotations
- implicit order by is removed, modified many tests to explicitly set ordering, probably many more to go
once it hits the buildbot.
2008-05-09 23:58:30 +00:00
Jason Kirtland e41c0f4107 Test suite modernization in progress. Big changes:
- @unsupported now only accepts a single target and demands a reason
   for not running the test.
 - @exclude also demands an exclusion reason
 - Greatly expanded @testing.requires.<feature>, eliminating many
   decorators in the suite and signficantly easing integration of
   multi-driver support.
 - New ORM test base class, and a featureful base for mapped tests
 - Usage of 'global' for shared setup going away, * imports as well
2008-05-09 20:26:09 +00:00
Mike Bayer a2122a89f6 more order bys... 2008-05-09 20:04:29 +00:00
Mike Bayer 6dffbb2571 - warnings about Query invalid operations become InvalidRequestErrors
- __no_criterion() checks for more pre-existing conditions
- helpful note in 0.5 svn readme
2008-05-09 17:05:13 +00:00
Mike Bayer 4a6afd469f r4695 merged to trunk; trunk now becomes 0.5.
0.4 development continues at /sqlalchemy/branches/rel_0_4
2008-05-09 16:34:10 +00:00
Mike Bayer a5290b0d0f - backported 0.5's contains_eager() behavior such that rendering of eager clauses are disabled. workaround here is compatible with 0.5 but not compatible with the little-known "decorator" argument to contains_eager() (which was also removed in 0.5). Doesn't remove any existing 0.4 functionality. 2008-05-08 00:19:06 +00:00
Mike Bayer e435591259 - Fixed "concatenate tuple" bug which could occur with
Query.order_by() if clause adaption had taken place.
[ticket:1027]
2008-05-07 03:48:14 +00:00
Mike Bayer c407a608c3 added some reference tests for the any() situation 2008-05-01 15:17:07 +00:00
Mike Bayer 3560379ff7 fix order by for MySQL environment 2008-04-26 20:18:31 +00:00
Mike Bayer ab5adea360 - fixed Class.collection==None for m2m relationships
[ticket:4213]
2008-04-22 15:05:10 +00:00
Mike Bayer 5e2170f56a remove unneeded compile assertion test, doesn't work on MySQL 2008-04-07 21:53:13 +00:00
Mike Bayer e3b2305d67 - merged -r4458:4466 of query_columns branch
- this branch changes query.values() to immediately return an iterator, adds a new "aliased" construct which will be the primary method to get at aliased columns when using values()
- tentative ORM versions of _join and _outerjoin are not yet public, would like to integrate with Query better (work continues in the branch)
- lots of fixes to expressions regarding cloning and correlation.  Some apparent ORM bug-workarounds removed.
- to fix a recursion issue with anonymous identifiers, bind parameters generated against columns now just use the name of the column instead of the tablename_columnname label (plus the unique integer counter).  this way expensive recursive schemes aren't needed for the anon identifier logic.   This, as usual, impacted a ton of compiler unit tests which needed a search-n-replace for the new bind names.
2008-04-07 01:12:44 +00:00
Mike Bayer cfd7807838 some test fixup for oracle 2008-04-02 16:12:07 +00:00
Mike Bayer 8f2ff2a648 added an order by to fix potential mysql test failure 2008-04-01 18:11:13 +00:00
Mike Bayer 6aaa74e283 - added _from_self()
- changelog authoring
2008-03-30 18:05:33 +00:00
Mike Bayer c4955c05a3 - merged with_polymorphic branch, which was merged with query_columns branch
- removes everything to do with select_table, which remains as a keyword argument synonymous with
with_polymorphic=('*', select_table).
- all "polymorphic" selectables find their way to Query by way of _set_select_from() now, so that
all joins/aliasing/eager loads/etc. is handled consistently.  Mapper has methods for producing
polymorphic selectables so that Query and eagerloaders alike can get to them.
- row aliasing simplified, so that they don't need to nest.  they only need the source selectable
and adapt to whatever incoming columns they get.
- Query is more egalitarian about mappers/columns now.  Still has a strong sense of "entity zero",
but also introduces new unpublished/experimental _values() method which sets up a columns-only query.
- Query.order_by() and Query.group_by() take *args now (also still take a list, will likely deprecate
in 0.5).  May want to do this for select() as well.
- the existing "check for False discriminiator" "fix" was not working completely, added coverage
- orphan detection was broken when the target object was a subclass of the mapper with the orphaned
relation, fixed that too.
2008-03-29 00:00:49 +00:00
Mike Bayer 6bc2784a4d - made some fixes to the "from_joinpoint" argument to
query.join() so that if the previous join was aliased
and this one isn't, the join still happens successfully.
2008-03-21 17:21:41 +00:00
Mike Bayer ad4e425676 - fixed order_by calculation in Query to properly alias
mapper-config'ed order_by when using select_from()
2008-03-18 00:21:11 +00:00
Mike Bayer d8e258410e - adjusted generative.py test for revised error message
- mapper with non_primary asserts primary mapper already created
- added any()/instance compare test to query
2008-03-06 16:53:40 +00:00
Mike Bayer cef292c042 fixed negated self-referential m2m contains(), [ticket:987] 2008-03-04 19:26:29 +00:00
Mike Bayer 3175686514 - repaired behavior of == and != operators at the relation()
level when compared against NULL for one-to-one and other
relations [ticket:985]
2008-03-03 17:06:27 +00:00
Mike Bayer 075eb9076b - fixed bug whereby session.expire() attributes were not
loading on an polymorphically-mapped instance mapped
by a select_table mapper.

- added query.with_polymorphic() - specifies a list
of classes which descend from the base class, which will
be added to the FROM clause of the query.  Allows subclasses
to be used within filter() criterion as well as eagerly loads
the attributes of those subclasses.

- deprecated Query methods apply_sum(), apply_max(), apply_min(),
apply_avg().  Better methodologies are coming....
2008-03-01 01:46:23 +00:00
Mike Bayer f827e3c0b7 - fixed potential generative bug when the same Query was
used to generate multiple Query objects using join().
2008-02-20 17:09:25 +00:00
Mike Bayer 3e6e61dbe7 - modernized cascade.py tests
- your cries have been heard:  removing a pending item
from an attribute or collection with delete-orphan
expunges the item from the session; no FlushError is raised.
Note that if you session.save()'ed the pending item
explicitly, the attribute/collection removal still knocks
it out.
2008-02-17 18:13:14 +00:00
Mike Bayer a3f67fecb2 - any(), has(), contains(), attribute level == and != now
work properly with self-referential relations - the clause
inside the EXISTS is aliased on the "remote" side to
distinguish it from the parent table.
2008-02-17 01:15:43 +00:00