Commit Graph

40 Commits

Author SHA1 Message Date
Mike Bayer 2bc8c92279 - Identified an inconsistency when handling :meth:.Query.join to the
same target more than once; it implicitly dedupes only in the case of
a relationship join, and due to 🎫`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 🎫`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
2015-04-15 17:30:23 -04:00
Mike Bayer 7b9134be71 - test + changelog 2015-02-08 19:58:34 -05:00
Mike Bayer 028f7b8a86 - set default dialect here 2014-11-26 13:51:39 -05:00
Mike Bayer 99e5115124 - changelog, improve docstring/test for #3217. fixes #3217 2014-11-26 13:50:43 -05:00
Mike Bayer 55ad1d9159 Merge branch 'issue_bb_3217' of https://bitbucket.org/jvanasco/sqlalchemy-alt into pr32 2014-11-26 13:45:25 -05:00
Mike Bayer 55cad302ce - A warning is emitted in the case of multiple relationships that
ultimately will populate a foreign key column in conflict with
another, where the relationships are attempting to copy values
from different source columns.  This occurs in the case where
composite foreign keys with overlapping columns are mapped to
relationships that each refer to a different referenced column.
A new documentation section illustrates the example as well as how
to overcome the issue by specifying "foreign" columns specifically
on a per-relationship basis.
fixes #3230
2014-10-19 00:01:50 -04:00
jonathan vanasco 16d9d366bd * adding 'isouter=False' to sqlalchemy.orm.query.Query (https://bitbucket.org/zzzeek/sqlalchemy/issue/3217/make-join-more-standard-or-improve-error)
$ python setup.py develop
$ pip install nose
$ pip install mock
$ ./sqla_nose.py test.orm.test_joins
.....................................................................................................
----------------------------------------------------------------------
Ran 101 tests in 1.222s

OK

$ ./sqla_nose.py test.orm
......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................S......................................................................................................................................................................................................................................................................................................................S.......................................................................................................................................................................................................................................................................................................................................................S.......S..S.SSS.SS...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................S................................S..S........................S...........................................................................................SSS.S.........SSSSSSSS......SSSSSSSSS........SS...SS...............S.............................S..............................................................SS..SS..............................................................................................................S.
----------------------------------------------------------------------
Ran 3103 tests in 82.607s

OK (SKIP=46)
2014-10-03 13:15:52 -04:00
Mike Bayer 89a8e0d187 fix assertion 2014-03-19 11:47:58 -04:00
Mike Bayer 9ec01ab35a - Improved an error message which would occur if a query() were made
against a non-selectable, such as a :func:`.literal_column`, and then
an attempt was made to use :meth:`.Query.join` such that the "left"
side would be determined as ``None`` and then fail.  This condition
is now detected explicitly.
2014-03-17 16:25:51 -04:00
Mike Bayer 743ceb045e - Support is improved for supplying a :func:.join construct as the
target of :paramref:`.relationship.secondary` for the purposes
of creating very complex :func:`.relationship` join conditions.
The change includes adjustments to query joining, joined eager loading
to not render a SELECT subquery, changes to lazy loading such that
the "secondary" target is properly included in the SELECT, and
changes to declarative to better support specification of a
join() object with classes as targets.
2014-01-22 20:16:47 -05:00
Mike Bayer ca8fca6391 - Fixed regression where we apparently still create an implicit
alias when saying query(B).join(B.cs), where "C" is a joined inh
class; however, this implicit alias was created only considering
the immediate left side, and not a longer chain of joins along different
joined-inh subclasses of the same base.   As long as we're still
implicitly aliasing in this case, the behavior is dialed back a bit
so that it will alias the right side in a wider variety of cases.
[ticket:2903]
2014-01-02 18:26:32 -05:00
Mike Bayer fc348366f7 - fix a regression caused by #2587, where query.join() would apply an
adapter to an aliased-mapped, non-polymorphic selectable that prevented us from referring
directly to that selectable.
2013-06-27 16:43:01 -04:00
Mike Bayer 11578ba709 - improve overlapping selectables, apply to both query and relationship
- clean up inspect() calls within query._join()
- make sure join.alias(flat) propagates
- fix almost all assertion tests
2013-06-04 18:23:06 -04:00
Mike Bayer 04317bd5a8 The "auto-aliasing" behavior of the :class:.Query.select_from
method has been turned off.  The specific behavior is now
availble via a new method :class:`.Query.select_entity_from`.
[ticket:2736]
2013-05-30 20:09:44 -04:00
Mike Bayer 4b614b9b35 - the raw 2to3 run
- went through examples/ and cleaned out excess list() calls
2013-04-27 19:53:57 -04:00
Mike Bayer 6f05aa06bf everything passes with this!!!!!!! holy crap !!!!! and its the simplest of all 2013-04-25 13:54:40 -04:00
Mike Bayer 6372327097 - attempt to replace the whole idea of "join_to_left" with a more
fundamental and general purpose heuristic.   this initial approach
has about 60 tests failing but seems to have gone pretty far
2013-04-24 18:58:09 -04:00
Mike Bayer c3c9a3f701 break into multiple tests 2013-04-24 18:10:16 -04:00
Mike Bayer b19f3db870 - unit test failing on python3.3 + psycopg2, add an order by 2013-04-11 19:38:49 -04:00
Mike Bayer b66dad46f3 - refactor of pathing mechanics, to address #2614, #2617
- 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.
2012-12-01 20:12:23 -05:00
Mike Bayer be40b51cb0 getting everything to pass again 2012-09-27 16:33:54 -04:00
Mike Bayer 20cdc64588 trying different approaches to test layout. in this one, the testing modules
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.
2012-09-27 02:37:33 -04:00
Mike Bayer 22ba1c43b7 -whitespace bonanza, contd 2012-07-28 17:05:50 -04: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 df02cc0854 - Improved query.join() such that the "left" side
can more flexibly be a non-ORM selectable,
such as a subquery.   A selectable placed
in select_from() will now be used as the left
side, favored over implicit usage
of a mapped entity.
If the join still fails based on lack of
foreign keys, the error message includes
this detail.  Thanks to brianrhude
on IRC for the test case.  [ticket:2298]
2011-10-12 15:15:28 -04:00
Mike Bayer 9fae11e38c - Fixed a variety of synonym()-related regressions
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.
2011-09-15 20:18:26 -04:00
Mike Bayer 40ffa5a804 - Another previously unknown feature from 0.6, synonyms
of relationship() can again be passed to join().
2011-09-15 17:58:01 -04:00
Mike Bayer b9a4eacfa3 - Fixed bug in query.join() which would occur
in a complex multiple-overlapping path scenario,
    where the same table could be joined to
    twice.  Thanks *much* to Dave Vitek
    for the excellent fix here.  [ticket:2247]
2011-08-06 14:23:07 -04:00
Mike Bayer 027725fc49 default dialect, oopsie 2011-07-24 18:27:31 -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 7b24e458c7 - move all the comments that got shoved below the fixture grabs back up 2011-03-27 17:19:00 -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 a3083eabf4 - move all the setup_classes(cls) and setup_mappers(cls) to use a
local cls.Basic, cls.Comparable base class so that there is no ambiguity
or hash identity behaviors getting in the way of class registration.
2011-03-27 15:04:06 -04:00
Mike Bayer e3dbb87d94 - move _fixtures to work via the normal methods of _base.MappedTest, convert
all referncing tests to not use globals
- tests that deal with pickle specifically load the fixture classes
from test.lib.pickleable, which gets some more classes added
- removed weird sa05 pickling tests that don't matter
2011-03-26 20:44:47 -04:00
Mike Bayer 14a2fae239 - remove @testing.resolve_artifact_names, replace with direct attribute
access to the cls/self.tables/classes registries
- express orm/_base.py ORMTest in terms of engine/_base.py TablesTest,
factor out common steps into TablesTest, remove AltEngineTest as a
separate class.   will further consolidate these base classes
2011-03-26 19:03:11 -04:00
Mike Bayer dbaa3627b6 blow away some globals in the search for what makes resolve_artifact_names fail (possibly when there's already globals in the way...) 2011-03-16 01:26:27 -04:00
Diana Clarke 13242f766e corrected a bunch of spelling typos 2011-02-28 13:17:46 -05:00
Denise Govindarajan febb7b1ed6 Corrected order by in test joins. 2011-03-14 11:44:38 -04:00
Mike Bayer 350aed3fdb - whitespace removal bonanza 2011-01-02 14:23:42 -05:00
Mike Bayer 75a96be41b break up test_query into three modules 2010-12-11 18:21:52 -05:00