Commit Graph

5242 Commits

Author SHA1 Message Date
Mike Bayer c13846c6b6 - sending None as an argument to func.<something> will produce
an argument of NULL
2007-03-28 23:18:04 +00:00
Mike Bayer e064aaff14 unit test fix, same child object was being attached to two parents in a one-to-many which produced inconsistent results 2007-03-28 22:57:00 +00:00
Mike Bayer 5df24224ca error raised if trying to auto-join on a self referential 2007-03-28 17:48:02 +00:00
Mike Bayer e0b638a704 - column label and bind param "truncation" also generate
deterministic names now, based on their ordering within the
full statement being compiled.  this means the same statement
will produce the same string across application restarts and
allowing DB query plan caching to work better.
- cleanup to sql.ClauseParameters since it was just falling
apart, API made more explicit
- many unit test tweaks to adjust for bind params not being
"pre" truncated, changes to ClauseParameters
2007-03-28 07:19:14 +00:00
Mike Bayer ccbcbda43e added label truncation for bind param names which was lost in the previous related commit.
added more tests plus test for column targeting with text() clause.
2007-03-28 01:39:58 +00:00
Mike Bayer 0491452799 - fix for fetchmany() "size" argument being positional in most
dbapis [ticket:505]
2007-03-28 00:09:55 +00:00
Mike Bayer de4c25cd02 - fixes [ticket:185], join object determines primary key and removes
columns that are FK's to other columns in the primary key collection.
- removed workaround code from query.py get()
- removed obsolete inheritance test from mapper
- added new get() test to inheritance.py for this particular issue
- ColumnCollection has nicer string method
2007-03-27 22:06:36 +00:00
Mike Bayer 32440f2b3b - preliminary support for unicode table and column names added. 2007-03-27 16:04:34 +00:00
Mike Bayer 7300b198b9 - improved/fixed custom collection classes when giving it "set"/
"sets.Set" classes or subclasses (was still looking for append()
methods on them during lazy loads)
- moved CustomCollectionsTest from unitofwork to relationships
- added more custom collections test to attributes module
2007-03-26 19:59:39 +00:00
Mike Bayer 748f9b9acf - column labels are now generated in the compilation phase, which
means their lengths are dialect-dependent.  So on oracle a label
that gets truncated to 30 chars will go out to 63 characters
on postgres.  Also, the true labelname is always attached as the
accessor on the parent Selectable so theres no need to be aware
of the genrerated label names [ticket:512].
- ResultProxy column targeting is greatly simplified, and relies
upon the ANSICompiler's column_labels map to translate the built-in
label on a _ColumnClause (which is now considered to be a unique
identifier of that column) to the label which was generated at compile
time.
- still need to put a baseline of ColumnClause targeting for
ResultProxy objects that originated from a textual query.
2007-03-24 19:24:27 +00:00
Mike Bayer eac7ca356a dan's latest patch for session.identity_key() 2007-03-22 20:54:52 +00:00
Mike Bayer cef652a2d6 - slightly better support for bind params as column clauses, either
via bindparam() or via literal(), i.e. select([literal('foo')])
- removed "table" argument from column().  this does not add the column
to the table anyway so was misleading.
- Select _exportable_columns() only exports Selectable instances
- Select uses _exportable_columns() when searching for engines
instead of _raw_columns for similar reasons (non selectables have no engine)
- _BindParamClause no longer has a _make_proxy().  its not a ColumnElement.
- _Label detects underlying column element and will generate its own
column()._make_proxy() if the element is not a ColumnElement.  this
allows a Label to be declared for nearly anything and it can export
itself as a column on a containing Selectable.
2007-03-21 20:43:34 +00:00
Mike Bayer e918ea6898 the "tack on the leftover tasks at the end" step of the "circular dependency sort"
makes a copy of those tasks with the circular_parent marked.  this way the tasks
do not iterate through their child items polymorphically, which is necessary because
the "circular sort" stores individual subclass tasks separately (i.e. saving/deleting
should not traverse polymorhically for those tasks)
2007-03-20 15:27:34 +00:00
Mike Bayer f6d48da9de - many-to-many table will be properly handled even for operations that
occur on the "backref" side of the operation [ticket:249]
2007-03-19 17:54:29 +00:00
Rick Morrison 0a09256619 mssql: now passes still more unit tests, [ticket:481] 2007-03-19 02:00:32 +00:00
Mike Bayer 8f788f683b - check for tables in the primaryjoin/secondaryjoin that arent parent of parent/child mappers.
dont include those clauses when looking for foreign_keys (which also takes care of remote_side).
if those cols are present in foreign_keys, lazyloader makes binds out of them and tries to
target those columns on the mapper, raising either the "conflicting column" error if they have the same
name, or the "cant find column on mapping" if it has a unique name.  added tests for both.
2007-03-18 21:45:55 +00:00
Mike Bayer 037ee9fbf8 - flush fixes on self-referential relationships that contain references
to other instances outside of the cyclical chain, when the initial
self-referential objects are not actually part of the flush
2007-03-17 20:46:52 +00:00
Mike Bayer c249066dbf "alltests" runners call testbase.main(), which takes an optional suite,
so that exit code is propigated
2007-03-15 18:11:05 +00:00
Rick Morrison 30b20e3c56 MSSQL now passes still more unit tests [ticket:481]
Fix to null FLOAT fields in mssql-trusted.patch
MSSQL: LIMIT with OFFSET now raises an error
MSSQL: can now specify Windows authorization
MSSQL: ignores seconds on DATE columns (DATE fix, part 1)
2007-03-15 02:31:15 +00:00
Rick Morrison bfbbb2afb1 fix CASE statement when else_ is zero 2007-03-15 01:58:46 +00:00
Mike Bayer a5bf257126 - eager loading will not "aliasize" "order by" clauses that were placed
in the select statement by something other than the eager loader
itself, to fix possibility of dupe columns as illustrated in
[ticket:495].  however, this means you have to be more careful with
the columns placed in the "order by" of Query.select(), that you have
explicitly named them in your criterion (i.e. you cant rely on the
eager loader adding them in for you)

- query._join_to (which powers join, join_via, etc) properly takes
secondary table into account when constructing joins
2007-03-14 23:48:07 +00:00
Mike Bayer 6a3c374b95 - for hackers, refactored the "visitor" system of ClauseElement and
SchemaItem so that the traversal of items is controlled by the
ClauseVisitor itself, using the method visitor.traverse(item).
accept_visitor() methods can still be called directly but will
not do any traversal of child items.  ClauseElement/SchemaItem now
have a configurable get_children() method to return the collection
of child elements for each parent object. This allows the full
traversal of items to be clear and unambiguous (as well as loggable),
with an easy method of limiting a traversal (just pass flags which
are picked up by appropriate get_children() methods). [ticket:501]
- accept_schema_visitor() methods removed, replaced with
get_children(schema_visitor=True)
- various docstring/changelog cleanup/reformatting
2007-03-11 20:52:02 +00:00
Mike Bayer 320cb9b75f - oracle:
- got binary working for any size input !  cx_oracle works fine,
      it was my fault as BINARY was being passed and not BLOB for
      setinputsizes (also unit tests werent even setting input sizes).
    - auto_setinputsizes defaults to True for Oracle, fixed cases where
      it improperly propigated bad types.
2007-03-10 23:31:40 +00:00
Mike Bayer dc2d085a75 - Query has add_entity() and add_column() generative methods. these
will add the given mapper/class or ColumnElement to the query at compile
time, and apply them to the instances method.  the user is responsible
for constructing reasonable join conditions (otherwise you can get
full cartesian products).  result set is the list of tuples, non-uniqued.
- fixed multi-mapper instances() to pad out shorter results with None so
zip() gets everything
2007-03-10 03:41:55 +00:00
Mike Bayer b2e04755cc - the full featureset of the SelectResults extension has been merged
into a new set of methods available off of Query.  These methods
all provide "generative" behavior, whereby the Query is copied
and a new one returned with additional criterion added.
The new methods include:

  filter() - applies select criterion to the query
  filter_by() - applies "by"-style criterion to the query
  avg() - return the avg() function on the given column
  join() - join to a property (or across a list of properties)
  outerjoin() - like join() but uses LEFT OUTER JOIN
  limit()/offset() - apply LIMIT/OFFSET
  range-based access which applies limit/offset:
     session.query(Foo)[3:5]
  distinct() - apply DISTINCT
  list() - evaluate the criterion and return results

no incompatible changes have been made to Query's API and no methods
have been deprecated.  Existing methods like select(), select_by(),
get(), get_by() all execute the query at once and return results
like they always did.  join_to()/join_via() are still there although
the generative join()/outerjoin() methods are easier to use.

- the return value for multiple mappers used with instances() now returns
a cartesian product of the requested list of mappers, represented
as a list of tuples.  this corresponds to the documented behavior.
So that instances match up properly, the "uniquing" is disabled when
this feature is used.
- strings and columns can also be sent to the *args of instances() where
those exact result columns will be part of the result tuples.
- query() method is added by assignmapper.  this helps with
navigating to all the new generative methods on Query.
2007-03-10 02:49:12 +00:00
Mike Bayer 46b82976bf - fixed use_alter flag on ForeignKeyConstraint [ticket:503] 2007-03-07 18:05:39 +00:00
Mike Bayer 231acabf72 - options() method on SelectResults now implemented "generatively"
like the rest of the SelectResults methods [ticket:472]
2007-03-07 01:31:41 +00:00
Mike Bayer 7b43cd5092 added "enable_typechecks=True" flag on relation so the new type check from #500 can be disabled, since people are going to want to disable it. 2007-03-06 16:47:43 +00:00
Mike Bayer 9154e1eff1 - added concept of 'require_embedded' to corresponding_column.
requires that the target column be present in a sub-element of the
target selectable.
- embedded logic above more appropriate for ClauseAdapter functionality
since its trying to "pull up" clauses that represent columns within
a larger union up to the level of the union itself.
- the "direction" test against the "foreign_keys" collection apparently
works for an exact "column 'x' is present in the collection", no proxy
relationships needed.  fixes the case of relating a selectable/alias
to one of its underlying tables, probably fixes other scenarios
2007-03-05 23:08:52 +00:00
Mike Bayer 7693a680ed - put an aggressive check for "flushing object A with a collection
of B's, but you put a C in the collection" error condition -
**even if C is a subclass of B**, unless B's mapper loads polymorphically.
Otherwise, the collection will later load a "B" which should be a "C"
(since its not polymorphic) which breaks in bi-directional relationships
(i.e. C has its A, but A's backref will lazyload it as a different
instance of type "B") [ticket:500]
2007-03-05 05:12:09 +00:00
Mike Bayer bc1cc72d89 "modernized" polymorph test, name change to "test_roundtrip" 2007-03-03 21:25:44 +00:00
Mike Bayer e736817a92 - bindparam() names are now repeatable! specify two
distinct bindparam()s with the same name in a single statement,
and the key will be shared.  proper positional/named args translate
at compile time.  for the old behavior of "aliasing" bind parameters
with conflicting names, specify "unique=True" - this option is
still used internally for all the auto-genererated (value-based)
     bind parameters.
2007-03-03 21:02:26 +00:00
Mike Bayer c8a78834f5 cleanup; removed "separate foreign key" tests, polymorphic joined-table inheritance requires the same pk col name across tables;
added additional polymorphic load assertions
2007-03-03 20:24:13 +00:00
Mike Bayer 2a77850707 - added "fold_equivalents" argument to Join.select(), which removes
'duplicate' columns from the resulting column clause that are known to be
equivalent based on the join condition.  this is of great usage when
constructing subqueries of joins which Postgres complains about if
duplicate column names are present.
- added support to polymorphic stuff for more than one "equivalent column",
when trying to target columns in the polymorphic union; this applies
to multi-leveled inheritance
- put above-two concepts together to get the abc_inheritance tests to work
with postgres
2007-03-02 21:22:14 +00:00
Mike Bayer 7e2ae824a5 - use_labels flag on select() wont auto-create labels for literal text
column elements, since we can make no assumptions about the text. to
create labels for literal columns, you can say "somecol AS somelabel",
or use literal_column("somecol").label("somelabel")
- quoting wont occur for literal columns when they are "proxied" into the
column collection for their selectable (is_literal flag is propigated)
2007-03-01 20:14:17 +00:00
Mike Bayer d94384253f added a unit test for nested session transactions 2007-02-28 21:42:54 +00:00
Mike Bayer 7970f8193e a generating testcase that tests a three-level inheritance chain (A->B->C) and all one-to-many and many-to-one relationships between
all distinct A,B,C.  still needs support for foreign key to parent table not the same col as the pk col
2007-02-28 03:35:32 +00:00
Mike Bayer e878ec167e this test works with both one to many and many to one, but i think its intended to be one-to-many 2007-02-28 01:25:52 +00:00
Mike Bayer ba5337982e - fixed function execution with explicit connections, when you dont
explicitly say "select()" off the function, i.e.
conn.execute(func.dosomething())
2007-02-27 19:04:43 +00:00
Mike Bayer 8fa3becd5f - more fixes to polymorphic relations, involving proper lazy-clause
generation on many-to-one relationships to polymorphic mappers
[ticket:493]
2007-02-25 01:27:15 +00:00
Mike Bayer abc9971544 fix typo 2007-02-25 01:24:33 +00:00
Mike Bayer 777037d46d - added "refresh-expire" cascade [ticket:492] 2007-02-24 21:58:38 +00:00
Mike Bayer 41802e102c - correlated subqueries work inside of ORDER BY, GROUP BY 2007-02-24 00:17:08 +00:00
Mike Bayer 736bc3bd51 - exists() becomes useable as a standalone selectable, not just in a
WHERE clause
2007-02-23 20:46:27 +00:00
Mike Bayer b59f4d1a4a restored sequence back, needed by PG for the unit test 2007-02-22 03:51:21 +00:00
Mike Bayer 66623acb4b added collengths to use varchar instead of TEXT 2007-02-22 03:13:43 +00:00
Mike Bayer 67baacf01b - removed deprecated method of specifying custom collections on classes;
you must now use the "collection_class" option. the old way was
beginning to produce conflicts when people used assign_mapper(), which
now patches an "options" method, in conjunction with a relationship
named "options". (relationships take precedence over monkeypatched
assign_mapper methods).
2007-02-21 21:55:45 +00:00
Mike Bayer e5c06951dd - eager relation loading bug fixed for eager relation on multiple
descendant classes [ticket:486]
2007-02-21 20:57:31 +00:00
Mike Bayer bd2f52a7e3 fix to the fix for [ticket:454], prevent other mappers in a load operation from using the main extension option send to the query (i.e. mappers used for eager loads etc). 2007-02-20 18:01:16 +00:00
Mike Bayer fa46e0ec66 - added "contains_alias()" option for result set mapping to an alias of the mapped table 2007-02-20 02:12:46 +00:00