Commit Graph

49 Commits

Author SHA1 Message Date
Mike Bayer 2d8d1dcf60 - repair the _enable_single_crit method, it was named the same
as the attribute and probably just replaced itself, so that is
now _set_enable_single_crit
- as a side effect of the main issue fixed here, correct the case in
adjust_for_single_inheritance where the same mapper appears more
than once in mapper_adapter_map; run through a set() for uniqueness.
- Fixed bug in subquery eager loading in conjunction with
:func:`.with_polymorphic`, the targeting of entities and columns
in the subquery load has been made more accurate with respect
to this type of entity and others. Fixes #3106
2014-06-30 20:25:04 -04:00
Mike Bayer 95b10c4e8e - Fixed bug in subquery eager loading where a long chain of
eager loads across a polymorphic-subclass boundary in conjunction
with polymorphic loading would fail to locate the subclass-link in the
chain, erroring out with a missing property name on an
:class:`.AliasedClass`. fixes #3055
2014-05-25 13:45:32 -04:00
Mike Bayer 5d2bfc4df4 - Fixed a few errant `u''` strings that would prevent tests from passing
in Py3.2.  Patch courtesy Arfrever Frehtes Taifersar Arahesis. fixes #2980
2014-03-22 18:48:59 -04:00
Mike Bayer de2cfa2d1e autoincrement here 2013-12-17 16:28:43 -05:00
Mike Bayer 84f1d34179 - An adjustment to the :func:.subqueryload strategy which ensures that
the query runs after the loading process has begun; this is so that
the subqueryload takes precedence over other loaders that may be
hitting the same attribute due to other eager/noload situations
at the wrong time. [ticket:2887]
2013-12-16 19:17:41 -05:00
Mike Bayer 59ca4633ac - remove informix dialect, moved out to https://bitbucket.org/zzzeek/sqlalchemy_informixdb
- remove informix, maxdb, access symbols from tests etc.
2013-11-17 13:45:23 -05:00
Mike Bayer ca851e5815 use a set here also 2013-10-18 19:03:21 -04:00
Mike Bayer ab38a67995 - fix non-deterministic ordering point 2013-10-14 10:35:54 -04:00
Mike Bayer f00544a589 - Added new option to :func:.relationship `distinct_target_key`.
This enables the subquery eager loader strategy to apply a DISTINCT
to the innermost SELECT subquery, to assist in the case where
duplicate rows are generated by the innermost query which corresponds
to this relationship (there's not yet a general solution to the issue
of dupe rows within subquery eager loading, however, when joins outside
of the innermost subquery produce dupes).  When the flag
is set to ``True``, the DISTINCT is rendered unconditionally, and when
it is set to ``None``, DISTINCT is rendered if the innermost relationship
targets columns that do not comprise a full primary key.
The option defaults to False in 0.8 (e.g. off by default in all cases),
None in 0.9 (e.g. automatic by default).   Thanks to Alexander Koval
for help with this. [ticket:2836]
2013-10-13 16:42:32 -04:00
Mike Bayer 2b0b802b49 working through tests.... 2013-06-02 20:23:03 -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 e5d0592180 - additional test + correction for [ticket:2699] 2013-04-18 10:34:59 -04:00
Mike Bayer 37a9c5f52d order by... 2013-04-09 14:48:59 -04:00
Mike Bayer df4e59ff55 Fixed bug when a query of the form:
``query(SubClass).options(subqueryload(Baseclass.attrname))``,
where ``SubClass`` is a joined inh of ``BaseClass``,
would fail to apply the ``JOIN`` inside the subquery
on the attribute load, producing a cartesian product.
The populated results still tended to be correct as additional
rows are just ignored, so this issue may be present as a
performance degradation in applications that are
otherwise working correctly. [ticket:2699]
2013-04-09 11:52:21 -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 e2697d547e Added a new exception to detect the case where two
subclasses are being loaded using with_polymorphic(),
each subclass contains a relationship attribute of the same
name, and eager loading is being applied to one or both.
This is an ongoing bug which can't be immediately fixed,
so since the results are usually wrong in any case it raises an
exception for now.   0.7 has the same issue, so an exception
raise here probably means the code was returning the wrong
data in 0.7.  [ticket:2614]
2012-11-24 16:14:58 -05: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 ec7ea3d264 mo tests mo problems 2012-08-06 12:19:22 -04:00
Mike Bayer 63e2a0f8eb - [bug] Improvements to joined/subquery eager
loading dealing with chains of subclass entities
    sharing a common base, with no specific "join depth"
    provided.  Will chain out to
    each subclass mapper individually before detecting
    a "cycle", rather than considering the base class
    to be the source of the "cycle".  [ticket:2481]
2012-08-06 11:36:57 -04:00
Mike Bayer 22ba1c43b7 -whitespace bonanza, contd 2012-07-28 17:05:50 -04:00
Mike Bayer 3dd536ac06 - [feature] The of_type() construct on attributes
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
2012-06-20 19:28:29 -04:00
Mike Bayer 3db5ddfdac - [bug] Fixed bug whereby populate_existing
option would not propagate to subquery
eager loaders.  [ticket:2497].  Also
in 0.7.8.
2012-06-16 17:40:15 -04:00
Mike Bayer d05319ec7e - [bug] Fixed bug whereby subqueryload() from
a polymorphic mapping to a target would incur
a new invocation of the query for each
distinct class encountered in the polymorphic
result.  [ticket:2480].  Also in 0.7.8.
2012-05-17 14:18:05 -04:00
Mike Bayer 98a7915415 - Fixed bug whereby mapper.order_by attribute would
be ignored in the "inner" query within a
subquery eager load.  [ticket:2287].
Also in 0.6.9.
2011-09-28 09:10:23 -04:00
Mike Bayer 15cd4235b6 - Feature enhancement: joined and subquery
loading will now traverse already-present related
    objects and collections in search of unpopulated
    attributes throughout the scope of the eager load
    being defined, so that the eager loading that is
    specified via mappings or query options
    unconditionally takes place for the full depth,
    populating whatever is not already populated.
    Previously, this traversal would stop if a related
    object or collection were already present leading
    to inconsistent behavior (though would save on
    loads/cycles for an already-loaded graph). For a
    subqueryload, this means that the additional
    SELECT statements emitted by subqueryload will
    invoke unconditionally, no matter how much of the
    existing graph is already present (hence the
    controversy). The previous behavior of "stopping"
    is still in effect when a query is the result of
    an attribute-initiated lazyload, as otherwise an
    "N+1" style of collection iteration can become
    needlessly expensive when the same related object
    is encountered repeatedly. There's also an
    as-yet-not-public generative Query method
    _with_invoke_all_eagers()
    which selects old/new behavior [ticket:2213]
2011-07-17 15:14:03 -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 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 b1b8e7defd - alex gaynor's latest batch of pypy test fixes 2011-03-16 13:04:07 -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 5400ea2c1e - additional fix for [ticket:1964]
- [ticket:1965] is invalid
2010-11-13 12:05:13 -05:00
Mike Bayer 5b96e3fff7 whoopsie 2010-11-11 19:27:35 -05:00
Mike Bayer bcf577c1d5 - Fixed bug regarding "subqueryload" strategy whereby
strategy would fail if the entity was an aliased()
construct.  [ticket:1964]
2010-11-11 19:15:26 -05:00
Mike Bayer 53d861792b - Dynamic attributes don't support collection
population - added an assertion for when
set_committed_value() is called, as well as
when joinedload() or subqueryload() options
are applied to a dynamic attribute, instead
of failure / silent failure.  [ticket:1864]
2010-08-05 12:28:01 -04:00
Mike Bayer 7a554d5267 - Query.statement, Query.subquery(), etc. now transfer
the values of bind parameters, i.e. those specified
by query.params(), into the resulting SQL expression.
Previously the values would not be transferred
and bind parameters would come out as None.

- Subquery-eager-loading now works with Query objects
which include params(), as well as get() Queries.
2010-06-14 20:07:44 -04:00
Mike Bayer a977894c84 - fix some final pathing stuff, we weren't getting all the loads in the
inheritance examples, now its improved !
- final doc pass
2010-03-24 23:51:49 -04:00
Mike Bayer c6bceb7775 - converted all lazy=True|False|None to 'select'|'joined'|'noload'
- converted all eager to joined in examples
- fixed beaker/advanced.py to reference RelationshipCache
2010-03-24 19:19:03 -04:00
Mike Bayer 1675811029 - To accomodate the fact that there are now two kinds of eager
loading available, the new names for eagerload() and
eagerload_all() are joinedload() and joinedload_all().  The
old names will remain as synonyms for the foreseeable future.

- The "lazy" flag on the relationship() function now accepts
a string argument for all kinds of loading: "select", "joined",
"subquery", "noload" and "dynamic", where the default is now
"select".  The old values of True/
False/None still retain their usual meanings and will remain
as synonyms for the foreseeable future.

- Added documentation to tutorial,mapper doc, api docs
for subqueryload, subqueryload_all, and other options.
2010-03-24 19:11:01 -04:00
Mike Bayer 9c68542116 everything everything passes on this one. still want to get rid of that hack tho. 2010-03-24 13:19:34 -04:00
Mike Bayer 4d396e5ff0 this version actually works for all existing tests plus simple self-referential.
I don't like how difficult it was to get Query() to do it, however.
2010-03-23 18:33:31 -04:00
Mike Bayer 3308cf8f48 - order by secondary works
- self referential is killing it, however
2010-03-23 14:02:22 -04:00
Mike Bayer 2d6ac273ae adding tests, all the features present in joined eager loading 2010-03-23 12:11:20 -04:00
Mike Bayer f130b2f04d that was easy 2010-03-23 11:14:02 -04:00
Mike Bayer 77752f4a3f all tests are passing. some more TODOs and more testing needed 2010-03-22 21:23:31 -04:00
Mike Bayer 0197a70343 - Fixed bug which affected all eagerload() and similar options
such that "remote" eager loads, i.e. eagerloads off of a lazy
load such as query(A).options(eagerload(A.b, B.c))
wouldn't eagerload anything, but using eagerload("b.c") would
work fine.
- subquery eagerloading very close
2010-03-22 20:15:50 -04:00
Mike Bayer efcc9d7822 and here's where it gets *fun* ! so much for being easy 2010-03-22 16:54:58 -04:00
Mike Bayer e62b7d4087 - ordering tests
- bring all lines in strategies.py to 78 chars
2010-03-22 14:03:09 -04:00
Mike Bayer a57f7c072b initial subq implementation 2010-03-21 18:45:54 -04:00