Commit Graph

37 Commits

Author SHA1 Message Date
Mike Bayer 7c6a45c480 - The :func:~.expression.column and :func:~.expression.table
constructs are now importable from the "from sqlalchemy" namespace,
just like every other Core construct.
- The implicit conversion of strings to :func:`.text` constructs
when passed to most builder methods of :func:`.select` as
well as :class:`.Query` now emits a warning with just the
plain string sent.   The textual conversion still proceeds normally,
however.  The only method that accepts a string without a warning
are the "label reference" methods like order_by(), group_by();
these functions will now at compile time attempt to resolve a single
string argument to a column or label expression present in the
selectable; if none is located, the expression still renders, but
you get the warning again. The rationale here is that the implicit
conversion from string to text is more unexpected than not these days,
and it is better that the user send more direction to the Core / ORM
when passing a raw string as to what direction should be taken.
Core/ORM tutorials have been updated to go more in depth as to how text
is handled.
fixes #2992
2014-09-01 20:19:54 -04:00
Tony Locke 0365a53c5d PEP8 tidy of test/orm/test_froms.py 2014-07-20 11:59:33 +01:00
Tony Locke b4f9a6949b Opened test_self_referential for pg8000
The test orm/test_froms.py test_self_referential works with pg8000 now,
so I've opened it up.
2014-07-20 11:59:33 +01:00
Mike Bayer ec40a84d96 - Fixed a regression from 0.9.0 due to 🎫2736 where the
:meth:`.Query.select_from` method no longer set up the "from
entity" of the :class:`.Query` object correctly, so that
subsequent :meth:`.Query.filter_by` or :meth:`.Query.join`
calls would fail to check the appropriate "from" entity when
searching for attributes by string name.
fixes #3083
2014-07-14 18:49:06 -04:00
Alex Gaynor 1caa7fafbd Fix many typos throughout the codebase
Found using: https://github.com/intgr/topy
2014-04-26 13:13:13 -07:00
Mike Bayer ae4629e6a0 - Some refinements to the :class:.AliasedClass construct with regards
to descriptors, like hybrids, synonyms, composites, user-defined
descriptors, etc.  The attribute
adaptation which goes on has been made more robust, such that if a descriptor
returns another instrumented attribute, rather than a compound SQL
expression element, the operation will still proceed.
Addtionally, the "adapted" operator will retain its class; previously,
a change in class from ``InstrumentedAttribute`` to ``QueryableAttribute``
(a superclass) would interact with Python's operator system such that
an expression like ``aliased(MyClass.x) > MyClass.x`` would reverse itself
to read ``myclass.x < myclass_1.x``.   The adapted attribute will also
refer to the new :class:`.AliasedClass` as its parent which was not
always the case before. [ticket:2872]
2013-11-23 17:03:48 -05:00
Mike Bayer 1b25ed907f - merge ticket_1418 branch, [ticket:1418]
- The system of loader options has been entirely rearchitected to build
upon a much more comprehensive base, the :class:`.Load` object.  This
base allows any common loader option like :func:`.joinedload`,
:func:`.defer`, etc. to be used in a "chained" style for the purpose
of specifying options down a path, such as ``joinedload("foo").subqueryload("bar")``.
The new system supersedes the usage of dot-separated path names,
multiple attributes within options, and the usage of ``_all()`` options.
-  Added a new load option :func:`.orm.load_only`.  This allows a series
of column names to be specified as loading "only" those attributes,
deferring the rest.
2013-10-06 20:29:08 -04:00
Mike Bayer d5363fca54 - Fixed an obscure bug where the wrong results would be
fetched when joining/joinedloading across a many-to-many
relationship to a single-table-inheriting
subclass with a specific discriminator value, due to "secondary"
rows that would come back.  The "secondary" and right-side
tables are now inner joined inside of parenthesis for all
ORM joins on many-to-many relationships so that the left->right
join can accurately filtered.
[ticket:2369]
2013-06-07 23:04:33 -04:00
Mike Bayer 1cc6494802 add a test for the exception we want to raise here 2013-05-30 20:26:45 -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 a5ede47f12 A major fix to the way in which a select() object produces
labeled columns when apply_labels() is used; this mode
produces a SELECT where each column is labeled as in
<tablename>_<columnname>, to remove column name collisions
for a multiple table select.   The fix is that if two labels
collide when combined with the table name, i.e.
"foo.bar_id" and "foo_bar.id", anonymous aliasing will be
applied to one of the dupes.  This allows the ORM to handle
both columns independently; previously, 0.7
would in some cases silently emit a second SELECT for the
column that was "duped", and in 0.8 an ambiguous column error
would be emitted.   The "keys" applied to the .c. collection
of the select() will also be deduped, so that the "column
being replaced" warning will no longer emit for any select()
that specifies use_labels, though the dupe key will be given
an anonymous label which isn't generally user-friendly.
[ticket:2702]
2013-04-11 16:14:23 -04:00
Mike Bayer 9066d99a0f - clean up entity correlation tests in test_query 2013-03-09 12:28:18 -05:00
Mike Bayer ce3333a65c The :meth:.Query.select_from method can now be used with a
:func:`.aliased` construct without it interfering with the entities
being selected.  [ticket:2635]
2012-12-13 18:45:15 -05:00
Mike Bayer 0c9d55db73 The auto-correlation feature of :func:.select, and
by proxy that of :class:`.orm.Query`, will not
      take effect for a SELECT statement that is being
      rendered directly in the FROM list of the enclosing
      SELECT.  Correlation in SQL only applies to column
      expressions such as those in the WHERE, ORDER BY,
      columns clause. [ticket:2595]
2012-10-22 13:29:12 -04: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 444abbe847 - got firebird running
- add some failure cases
- [bug] Firebird now uses strict "ansi bind rules"
so that bound parameters don't render in the
columns clause of a statement - they render
literally instead.

- [bug] Support for passing datetime as date when
using the DateTime type with Firebird; other
dialects support this.
2012-09-23 18:09:18 -04:00
Mike Bayer 65bdf245c6 - [feature] ORM entities can be passed
to select() as well as the select_from(),
correlate(), and correlate_except()
methods, where they will be unwrapped
into selectables. [ticket:2245]
2012-07-23 18:22:06 -04:00
Mike Bayer 7472505874 - justify NamedTuple, now called KeyedTuple
- fix this test
2012-07-16 17:56:53 -04:00
Diana Clarke 8b16cd876c make auto-correlation the same for Query & select() 2012-04-02 21:42:17 -04: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 00a2f0ef27 - added "adapt_on_names" boolean flag to orm.aliased()
construct.  Allows an aliased() construct
    to link the ORM entity to a selectable that contains
    aggregates or other derived forms of a particular
    attribute, provided the name is the same as that
    of the entity mapped column.
2011-09-19 16:48:39 -04:00
Mike Bayer cdf727aeb2 - Fixed bug whereby the source clause
used by query.join() would be inconsistent
if against a column expression that combined
multiple entities together.  [ticket:2197]
2011-07-20 18:03:35 -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 ebb803395b - rework of Query._adapt_clause to support [ticket:2155],
be clearer in its intent.
- Fine tuning of Query clause adaptation when
from_self(), union(), or other "select from
myself" operation, such that plain SQL expression
elements added to filter(), order_by() etc.
which are present in the nested "from myself"
query *will* be adapted in the same way an ORM
expression element will, since these
elements are otherwise not easily accessible.
[ticket:2155]
2011-04-30 14:43:03 -04:00
Mike Bayer 674d4f8d3f - a "having" clause would be copied from the
inside to the outside query if from_self()
were used; in particular this would break
an 0.7 style count() query [ticket:2130].
(also in 0.6.7)
2011-04-13 19:27:40 -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
Jim Phares b327b981be Fixed order_by in test.orm.test_froms.MixedEntitiesTest.test_values. 2011-03-14 11:51:38 -04:00
Mike Bayer 85084caeff - A single contains_eager() call across
multiple entities will indicate all collections
along that path should load, instead of requiring
distinct contains_eager() calls for each endpoint
(which was never correctly documented).
[ticket:2032]

- The "name" field used in orm.aliased() now renders
in the resulting SQL statement.
2011-02-05 16:09:49 -05: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