Commit Graph

36 Commits

Author SHA1 Message Date
Mike Bayer 503bddc879 - [bug] column.label(None) now produces an
anonymous label, instead of returning the
column object itself, consistent with the behavior
of label(column, None).  [ticket:2168]
2012-04-24 13:04:38 -04:00
Mike Bayer 9b73e997b2 - [bug] The names of the columns on the
.c. attribute of a select().apply_labels()
is now based on <tablename>_<colkey> instead
of <tablename>_<colname>, for those columns
that have a distinctly named .key.
[ticket:2397]
2012-04-24 11:24:23 -04:00
Mike Bayer 713a4e19fa - merged #1401 branch from bitbucket
- 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]
2012-04-22 19:43:31 -04:00
Mike Bayer 1378bf0d25 - reopened #2453, needed to put in the original patch as well to cover the case
of column_property() objs building off each other
2012-04-03 09:59:22 -04:00
Mike Bayer 45046367f3 - [bug] Fixed bug in expression annotation
mechanics which could lead to incorrect
rendering of SELECT statements with aliases
and joins, particularly when using
column_property().  [ticket:2453]
2012-03-31 13:35:05 -04:00
Mike Bayer 57868f587e - [bug] Fixed bug whereby a primaryjoin
condition with a "literal" in it would
raise an error on compile with certain
kinds of deeply nested expressions
which also needed to render the same
bound parameter name more than once.
[ticket:2425]
2012-03-12 13:35:27 -07:00
Mike Bayer d934ea23e2 - figured out again why deannotate must clone()
- got everything working.  just need to update
error strings
2012-02-11 20:33:56 -05:00
Mike Bayer bc45fa350a - got m2m, local_remote_pairs, etc. working
- using new traversal that returns the product of both sides
of a binary, starting to work with (a+b) == (c+d) types of joins.
primaryjoins on functions working
- annotations working, including reversing local/remote when
doing backref
2012-02-09 21:16:53 -05:00
Mike Bayer 73f734bf80 initial annotations approach to join conditions. all tests pass, plus additional tests in #1401 pass.
would now like to reorganize RelationshipProperty more around the annotations concept.
2012-02-06 12:20:15 -05:00
Mike Bayer 2dbeeff50b - [bug] Added support for using the .key
of a Column as a string identifier in a
result set row.   The .key is currently
listed as an "alternate" name for a column,
and is superseded by the name of a column
which has that key value as its regular name.
For the next major release
of SQLAlchemy we may reverse this precedence
so that .key takes precedence, but this
is not decided on yet.  [ticket:2392]
2012-02-05 16:58:32 -05:00
Mike Bayer 699146086d - [bug] Fixed bug whereby column_property() created
against ORM-level column could be treated as
a distinct entity when producing certain
kinds of joined-inh joins.  [ticket:2316]

- [bug] related to [ticket:2316], made some
adjustments to the change from [ticket:2261]
regarding the "from" list on a select(). The
_froms collection is no longer memoized, as this
simplifies various use cases and removes the
need for a "warning" if a column is attached
to a table after it was already used in an
expression - the select() construct will now
always produce the correct expression.
There's probably no real-world
performance hit here; select() objects are
almost always made ad-hoc, and systems that
wish to optimize the re-use of a select()
would be using the "compiled_cache" feature.
A hit which would occur when calling select.bind
has been reduced, but the vast majority
of users shouldn't be using "bound metadata"
anyway :).
2011-12-03 19:50:01 -05:00
Mike Bayer c0c42af4e0 - [bug] further tweak to the fix from [ticket:2261],
so that generative methods work a bit better
off of cloned (this is almost a non-use case though).
In particular this allows with_only_columns()
to behave more consistently.   Added additional
documentation to with_only_columns() to clarify
expected behavior, which changed as a result
of [ticket:2261].  [ticket:2319]
- document the crap out of with_only_columns, include caveats about
the change, etc.
2011-11-19 23:28:01 -05:00
Mike Bayer 9d775a4cd4 - Fixed bug whereby with_only_columns() method of
Select would fail if a selectable were passed.
    [ticket:2270].  Also in 0.6.9.
2011-09-21 17:08:08 -04:00
Mike Bayer 1cf80dc5b2 - Changed the update() method on association proxy
dictionary to use a duck typing approach, i.e.
    checks for "keys", to discern between update({})
    and update((a, b)).   Previously, passing a
    dictionary that had tuples as keys would be misinterpreted
    as a sequence. [ticket:2275]
2011-09-14 11:31:33 -04:00
Mike Bayer 8c0e82238c - Fixed bug regarding calculation of "from" list
for a select() element.  The "from" calc is now
delayed, so that if the construct uses a Column
object that is not yet attached to a Table,
but is later associated with a Table, it generates
SQL using the table as a FROM.   This change
impacted fairly deeply the mechanics of how
the FROM list as well as the "correlates" collection
is calculated, as some "clause adaption" schemes
(these are used very heavily in the ORM)
were relying upon the fact that the "froms"
collection would typically be cached before the
adaption completed.   The rework allows it
such that the "froms" collection can be cleared
and re-generated at any time.  [ticket:2261]
- RelationshipProperty.Comparator._criterion_exists()
adds an "_orm_adapt" annotation to the correlates target,
to work with the change in [ticket:2261].   It's not clear
if the change to correlation+adaption mechanics will affect end user
code yet.
- FromClause now uses group_expirable_memoized_property for
late-generated values like primary key, _columns, etc.
The Select class adds some tokens to this object and has the
nice effect that FromClause doesn't need to know about
Select's names anymore.   An additional change might be to
have Select use a different group_expirable_memoized_property
so that it's collection of attribute names are specific to
Select though this isn't really necessary right now.
2011-09-05 19:12:12 -04:00
Mike Bayer 5c7cc27425 - rework Annotated to no longer use __cmp__(), supply an __eq__() that
works with ColumnElement as well as works with non-__eq__() suppliers,
works with sets, on Py3K as well.
2011-07-24 20:41:42 -04:00
Mike Bayer 8a483dbf38 - rewrite cloned_traverse() and replacement_traverse() to use a straight
recursive descent with clone() + _copy_internals().  This is essentially
what it was doing anyway with lots of unnecessary steps.
Fix Alias() to honor the given clone() function which may have been the
reason the traversal hadn't been fixed sooner.   Alias._copy_internals()
will specifically skip an alias of a Table
as a more specific form of what it was doing before.  This may need to
be further improved such that ClauseAdapter or replacement_traverse()
send it some specific hints what not to dig into; **kw has been added
to all _copy_internals() to support this.   replacement/clone traversal
is at least clear now.
- apply new no_replacement_traverse annotation to join created by
_create_joins(), fixes [ticket:2195]
- can replace orm.query "_halt_adapt" with "no_replacement_traverse"
2011-07-24 17:51:01 -04:00
Mike Bayer 668991a7ed - Fixed subtle bug that caused SQL to blow
up if: column_property() against subquery +
joinedload + LIMIT + order by the column
property() occurred.  [ticket:2188].
Also in 0.6.9
2011-06-27 19:25:35 -04:00
Mike Bayer 63dbed1fd7 - Fixed a subtle bug involving column
correspondence in a selectable with the
    same column repeated.   Affects [ticket:2188].
2011-06-27 18:54:02 -04:00
Mike Bayer 50a96ca260 use default dialect here 2011-05-29 13:50:41 -04:00
Mike Bayer 736481e58f - Streamlined the process by which a Select
determines what's in it's '.c' collection.
Behaves identically, except that a
raw ClauseList() passed to select([])
(which is not a documented case anyway) will
now be expanded into its individual column
elements instead of being ignored.
2011-05-28 13:28:38 -04:00
Mike Bayer 00380cf3c3 - Fixed bug whereby nesting a label of a select()
with another label in it would produce incorrect
exported columns.   Among other things this would
break an ORM column_property() mapping against
another column_property().  [ticket:2167].
Also in 0.6.8
- _Label() is always against a column or selectable.  remove
uncovered case of label against something else.
- start taking notes to clean up some of this labeling stuff,
which will be [ticket:2168]
2011-05-18 12:07:40 -04:00
Mike Bayer 4bc2402cc0 - Changed the handling in determination of join
conditions such that foreign key errors are
only considered between the two given tables.
That is, t1.join(t2) will report FK errors
that involve 't1' or 't2', but anything
involving 't3' will be skipped.   This affects
join(), as well as ORM relationship and
inherit condition logic.  Will keep the more conservative
approach to [ticket:2153] in 0.6.
2011-05-07 12:52:25 -04:00
Mike Bayer 68a350d462 - remove test.sql._base, test.engine._base, test.orm._base, move those classes to a new test.lib.fixtures module
- move testing.TestBase to test.lib.fixtures
- massive search and replace
2011-03-27 16:27:27 -04:00
Mike Bayer 350aed3fdb - whitespace removal bonanza 2011-01-02 14:23:42 -05:00
Mike Bayer e1402efb19 - move sqlalchemy.test to test.lib 2010-11-15 19:37:50 -05:00
Mike Bayer cbb0a03a56 - the _Label construct, i.e. the one that is produced
whenever you say somecol.label(), now counts itself
in its "proxy_set" unioned with that of it's
contained column's proxy set, instead of
directly returning that of the contained column.
This allows column correspondence
operations which depend on the identity of the
_Labels themselves to return the correct result
- fixes ORM bug [ticket:1852].
2010-08-07 20:58:23 -04:00
Mike Bayer 5cce6bf2a8 - experimenting with pytidy with mods as a textmate plugin along
the path to 78 chars.   eh
2010-07-10 14:50:13 -04:00
Mike Bayer 33f6dcc80b - Modified the internals of "column annotation" such that
a custom Column subclass can safely override
_constructor to return Column, for the purposes of
making "configurational" column classes that aren't
involved in proxying, etc.
2010-06-14 19:39:26 -04:00
Mike Bayer c6fbff56a3 - join() will now simulate a NATURAL JOIN by default. Meaning,
if the left side is a join, it will attempt to join the right
side to the rightmost side of the left first, and not raise
any exceptions about ambiguous join conditions if successful
even if there are further join targets across the rest of
the left.  [ticket:1714]
2010-03-19 15:30:48 -04:00
Mike Bayer 86df449c2b - fixed internal error which would occur if calling has()
or similar complex expression on a single-table inheritance
relation(). [ticket:1731]
2010-03-11 12:07:08 -05:00
Mike Bayer d24133e5c5 - Fixed a column arithmetic bug that affected column
correspondence for cloned selectables which contain
free-standing column expressions.   This bug is
generally only noticeable when exercising newer
ORM behavior only availble in 0.6 via [ticket:1568],
but is more correct at the SQL expression level
as well. [ticket:1617]
2010-01-03 20:57:37 +00:00
Philip Jenvey 5a9c1b8824 merge from branches/clauseelement-nonzero
adds a __nonzero__ to _BinaryExpression to avoid faulty comparisons during hash
collisions (which only occur on Jython)
fixes #1547
2009-09-24 02:11:56 +00:00
Mike Bayer 8fc5005dfe merge 0.6 series to trunk. 2009-08-06 21:11:27 +00:00
Mike Bayer b303eb9342 merged [ticket:1486] fix from 0.6 2009-07-28 17:47:54 +00:00
Mike Bayer 45cec095b4 - unit tests have been migrated from unittest to nose.
See README.unittests for information on how to run
the tests.  [ticket:970]
2009-06-10 21:18:24 +00:00