Commit Graph

1515 Commits

Author SHA1 Message Date
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 485fb57fc7 - added a handy multi-use "identity_key()" method to Session, allowing
the generation of identity keys for primary key values, instances,
and rows, courtesy Daniel Miller
2007-03-13 03:45:28 +00:00
Mike Bayer f18f2f50cb some docs 2007-03-13 02:45:40 +00:00
Mike Bayer 0e058d4b6c some formatting 2007-03-13 02:37:44 +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 585eacba01 cleanup of reversed 2007-03-09 00:12:49 +00:00
Mike Bayer c7a6d735ca - fixed usage of 2.4-only "reversed" in topological.py [ticket:506] 2007-03-08 23:14:25 +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 b401cd2ea7 decorated ImportError thrown when the <database>:// module isnt found 2007-03-06 17:17:27 +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 eb75392529 dont continue remote table if warning 2007-03-04 18:09:43 +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 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 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 962c22c9ed migrated (most) docstrings to pep-257 format, docstring generator using straight <pre> + trim() func
for now.  applies most of [ticket:214], compliemnts of Lele Gaifax
2007-02-25 22:44:52 +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 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 f0b72859f9 - a full select() construct can be passed to query.select() (which
worked anyway), but also query.selectfirst(), query.selectone() which
will be used as is (i.e. no query is compiled). works similarly to
sending the results to instances().
2007-02-22 22:59:51 +00:00
Mike Bayer 275640dc61 - added selectfirst(), selectfirst_by() to assign_mapper [ticket:467] 2007-02-22 03:16:58 +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
Rick Morrison 6834dcac1c Tested with pymssql 0.8.0
mssql: added query_timeout, fixes for passing auto_insert in dburl
2007-02-21 01:38:58 +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
Mike Bayer ae000fb550 - added "alias" argument to contains_eager(). use it to specify the string name
or Alias instance of an alias used in the query for the eagerly loaded child items.
    easier to use than "decorator"
2007-02-20 01:04:07 +00:00
Mike Bayer eb311db5ec - moved SynonymProperty to interfaces, since its more generalized and synonym-aware operations
take place without knowning so much about properties
- mapper options like eagerload(), lazyload(), deferred(), will work for "synonym()" relationships [ticket:485]
2007-02-20 00:09:37 +00:00
Rick Morrison 0911d4a61e 2007-02-19 19:03:33 +00:00
Mike Bayer f3055fe4ac removed not-always-applicable check for "polymorphic_identity" 2007-02-19 07:06:38 +00:00
Mike Bayer b880049b50 - oracle issues a log warning when a related table cant be reflected due to certain
permission errors [ticket:363]
2007-02-19 04:28:51 +00:00
Rick Morrison e7ac502b81 Completed previously missed patches from tickets 422 and 415
get unit tests to work with pyodbc [ticket:481]
fix blank password on adodbapi [ticket:371]
2007-02-18 19:43:05 +00:00
Mike Bayer 3b3d94c9ab - modified patch for [ticket:379] - detecting synonyms, dblinks in reflection. test passes
except for DBLINK which I cannot get to work on my oracle-xe database.
- probable (also untested) fix for [ticket:363], better error message if we get None back for
remote table information (which is due to rights)
2007-02-17 23:40:31 +00:00
Mike Bayer 2019974544 - fixes to tometadata() operation to propigate Constraints at column and table level 2007-02-17 19:08:36 +00:00
Mike Bayer b5bb6bb06d - fixed generation of CHECK constraints on columns [ticket:464] 2007-02-17 03:46:13 +00:00
Mike Bayer f4b1484ff5 - extension() query option propigates to Mapper._instance() method so that
all loading-related methods get called [ticket:454]
2007-02-17 03:14:36 +00:00
Mike Bayer 3e5eeb064a - moved change for [ticket:466] to ansisql, since thats the syntax for all databases.
the change is across all dialects, not just oracle
2007-02-17 02:39:28 +00:00
Mike Bayer 123498ee1f added PGInet type [ticket:444] 2007-02-17 02:36:11 +00:00
Mike Bayer 225e51a796 - added a Sequence to the unicode test tables to help Oracle
- fixed named PrimaryKeyConstraint generation on oracle [ticket:466] courtesy andrija at gmail
2007-02-17 02:31:56 +00:00
Mike Bayer ffd0e0e181 [ticket:463] fix to OrderedSet 2007-02-17 02:23:10 +00:00
Mike Bayer 8cf4e15c92 commented out ImportError for now; will issue new ticket for handling dialect importerrors more effectively 2007-02-17 01:49:52 +00:00
Mike Bayer 5f83c55fc7 - fixed oracle list of binary types to check for their presence in the module (such as BFILE not in all versions of cx_Oracle)
- removed oracle-handicap from binary unit test to test [ticket:435] fix, added an extra row containing None
2007-02-17 01:18:54 +00:00