Commit Graph

120 Commits

Author SHA1 Message Date
Mike Bayer 6eca02a31f - union() and union_all() will not whack
any order_by() that has been applied to the
select()s inside.  If you union() a
select() with order_by() (presumably to support
LIMIT/OFFSET), you should also call self_group()
on it to apply parenthesis.
2008-12-06 00:14:50 +00:00
Mike Bayer cfca625e94 docstring updates 2008-11-07 22:36:21 +00:00
Ants Aasma 11619ad8ee Slightly changed behavior of IN operator for comparing to empty collections. Now results in inequality comparison against self. More portable, but breaks with stored procedures that aren't pure functions. 2008-10-20 20:41:09 +00:00
Mike Bayer a20222fc22 - 0.5.0rc3, doh
- The internal notion of an "OID" or "ROWID" column has been
removed.  It's basically not used by any dialect, and the
possibility of its usage with psycopg2's cursor.lastrowid
is basically gone now that INSERT..RETURNING is available.

- Removed "default_order_by()" method on all FromClause
objects.
- profile/compile/select test is 8 function calls over on buildbot 2.4 for some reason, will adjust after checking
the results of this commit
2008-10-18 18:14:06 +00:00
Michael Trier b3c39decc1 Correction of mssql schema reflection in reflectable. Still a problem since the assumed default is dbo, whereas it could be modified by the connection. Allows SchemaTest.test_select to pass now. 2008-10-11 16:14:07 +00:00
Mike Bayer d47a469732 - version bump
- turned properties in sql/expressions.py to @property
- column.in_(someselect) can now be used as
a columns-clause expression without the subquery
bleeding into the FROM clause [ticket:1074]
2008-09-16 18:17:34 +00:00
Mike Bayer 01de711098 - 0.5.0rc1
- removed unneeded grouping from BooleanClauseList, generated needless parens
2008-09-11 20:48:39 +00:00
Mike Bayer 3b724ae1cc - Bind params now subclass ColumnElement which allows them to be
selectable by orm.query (they already had most ColumnElement
semantics).

- Added select_from() method to exists() construct, which becomes
more and more compatible with a regular select().

- Bind parameters/literals given a True/False value will detect
their type as Boolean
2008-09-09 15:54:10 +00:00
Mike Bayer e158234478 - The exists() construct won't "export" its contained list
of elements as FROM clauses, allowing them to be used more
effectively in the columns clause of a SELECT.

- and_() and or_() now generate a ColumnElement, allowing
boolean expressions as result columns, i.e.
select([and_(1, 0)]).  [ticket:798]
2008-09-08 22:50:37 +00:00
Mike Bayer 665cd4d36a - Temporarily rolled back the "ORDER BY" enhancement
from [ticket:1068].  This feature is on hold
pending further development.
2008-08-06 15:46:31 +00:00
Mike Bayer edf6b16fae - compiler visit_label() checks a flag "within_order_by" and will render its own name
and not its contained expression, if the dialect reports true for supports_simple_order_by_label.
the flag is not propagated forwards, meant to closely mimic the syntax Postgres expects which is
that only a simple name can be in the ORDER BY, not a more complex expression or function call
with the label name embedded (mysql and sqlite support more complex expressions).

This further sets the standard for propigation of **kwargs within compiler, that we can't just send
**kwargs along blindly to each XXX.process() call; whenever a **kwarg needs to propagate through,
most methods will have to be aware of it and know when they should send it on forward and when not.
This was actually already the case with result_map as well.

The supports_simple_order_by dialect flag defaults to True but is conservatively explicitly set to
False on all dialects except SQLite/MySQL/Postgres to start.

[ticket:1068]
2008-08-03 21:19:32 +00:00
Jason Kirtland b155b60280 - Spiffed up the deprecated decorators & @flipped 'em up top 2008-07-16 17:34:41 +00:00
Mike Bayer deaff3e97f - Fixed bug when calling select([literal('foo')])
or select([bindparam('foo')]).
2008-07-15 15:04:43 +00:00
Mike Bayer 45a2b0fedf possible fix for MS-SQL version of match() test, but the real solution here may be to have the correct default paramstyle set up on the MS-SQL dialect. 2008-07-14 19:39:50 +00:00
Michael Trier f899157ca9 Added new basic match() operator that performs a full-text search. Supported on PostgreSQL, SQLite, MySQL, MS-SQL, and Oracle backends. 2008-07-13 04:45:37 +00:00
Mike Bayer 4a6afd469f r4695 merged to trunk; trunk now becomes 0.5.
0.4 development continues at /sqlalchemy/branches/rel_0_4
2008-05-09 16:34:10 +00:00
Mike Bayer 3560379ff7 fix order by for MySQL environment 2008-04-26 20:18:31 +00:00
Mike Bayer f3bcc15c5c - improved behavior of text() expressions when used as
FROM clauses, such as select().select_from(text("sometext"))
[ticket:1014]
- removed _TextFromClause; _TextClause just adds necessary FromClause descriptors
at the class level
2008-04-26 16:34:14 +00:00
Jason Kirtland 2479711370 - Support for COLLATE: collate(expr, col) and expr.collate(col) 2008-04-16 00:53:21 +00:00
Mike Bayer e3b2305d67 - merged -r4458:4466 of query_columns branch
- this branch changes query.values() to immediately return an iterator, adds a new "aliased" construct which will be the primary method to get at aliased columns when using values()
- tentative ORM versions of _join and _outerjoin are not yet public, would like to integrate with Query better (work continues in the branch)
- lots of fixes to expressions regarding cloning and correlation.  Some apparent ORM bug-workarounds removed.
- to fix a recursion issue with anonymous identifiers, bind parameters generated against columns now just use the name of the column instead of the tablename_columnname label (plus the unique integer counter).  this way expensive recursive schemes aren't needed for the anon identifier logic.   This, as usual, impacted a ton of compiler unit tests which needed a search-n-replace for the new bind names.
2008-04-07 01:12:44 +00:00
Mike Bayer de209ded31 factored down exportable_columns/flatten_cols/proxy_column/oid_etc_yada down to a single, streamlined "_populate_column_collection" method called for all selectables 2008-04-04 18:41:08 +00:00
Mike Bayer 1a68456795 fixed union() bug whereby oid_column would not be available if no oid_column in embedded selects 2008-04-04 16:06:58 +00:00
Mike Bayer 7512b5e548 - schema-qualified tables now will place the schemaname
ahead of the tablename in all column expressions as well
as when generating column labels.  This prevents cross-
schema name collisions in all cases [ticket:999]
- the "use_schema" argument to compiler.visit_column() is removed.  It uses
schema in all cases now.
- added a new test to the PG dialect to test roundtrip insert/update/delete/select
statements with full schema qualification
2008-03-30 21:48:19 +00:00
Mike Bayer 30020880d9 - can now allow selects which correlate all FROM clauses
and have no FROM themselves.  These are typically
used in a scalar context, i.e. SELECT x, (SELECT x WHERE y)
FROM table.  Requires explicit correlate() call.
2008-03-28 15:55:26 +00:00
Mike Bayer 8d0c5672f0 added escape kw arg to contains(), startswith(), endswith(), [ticket:791] 2008-03-19 20:25:51 +00:00
Mike Bayer 0cc04e6e1b - like() and ilike() take an optional keyword argument
"escape=<somestring>", which is set as the escape character
using the syntax "x LIKE y ESCAPE '<somestring>'"
[ticket:993]
2008-03-19 19:35:42 +00:00
Mike Bayer 7f43bc55e0 - can again create aliases of selects against textual
FROM clauses, [ticket:975]
2008-02-19 23:46:14 +00:00
Mike Bayer c0b5a0446b - updated the naming scheme of the base test classes in test/testlib/testing.py;
tests extend from either TestBase or ORMTest, using additional mixins for
special assertion methods as needed
2008-02-11 00:28:39 +00:00
Mike Bayer 842934f40c - added generative where(<criterion>) method to delete()
and update() constructs which return a new object with
criterion joined to existing criterion via AND, just
like select().where().
- compile assertions use assertEquals()
2008-02-08 22:57:45 +00:00
Mike Bayer d2f9015c12 lock in replacing '%' with '%%' 2008-02-04 22:35:29 +00:00
Mike Bayer a0ffeb5464 - some consolidation of tests in select.py, moved
other tests to more specific modules
- added "now()" as a generic function; on SQLite and
Oracle compiles as "CURRENT_TIMESTAMP"; "now()"
on all others [ticket:943]
2008-02-01 01:16:18 +00:00
Jason Kirtland 7bf0fca858 - Workaround for datetime quirk, LHS comparisons to SA expressions now work. 2008-01-31 21:32:38 +00:00
Mike Bayer a5b23bda66 - the startswith(), endswith(), and contains() operators
now concatenate the wildcard operator with the given
operand in SQL, i.e. "'%' || <bindparam>" in all cases,
accept text('something') operands properly [ticket:962]

- cast() accepts text('something') and other non-literal
operands properly [ticket:962]
2008-01-31 03:57:20 +00:00
Mike Bayer 840a2fabb8 - some expression fixup:
- the '.c.' attribute on a selectable now gets an
entry for every column expression in its columns
clause; previously, "unnamed" columns like functions
and CASE statements weren't getting put there.  Now
they will, using their full string representation
if no 'name' is available.
- The anonymous 'label' generated for otherwise
unlabeled functions and expressions now propagates
outwards at compile time for expressions like
select([select([func.foo()])])
- a CompositeSelect, i.e. any union(), union_all(),
intersect(), etc. now asserts that each selectable
contains the same number of columns.  This conforms
to the corresponding SQL requirement.
- building on the above ideas, CompositeSelects
now build up their ".c." collection based on
the names present in the first selectable only;
corresponding_column() now works fully for all
embedded selectables.
2008-01-19 18:36:52 +00:00
Jason Kirtland 17d3c8764e - testbase is gone, replaced by testenv
- Importing testenv has no side effects- explicit functions provide similar behavior to the old immediate behavior of testbase
- testing.db has the configured db
- Fixed up the perf/* scripts
2008-01-12 22:03:42 +00:00
Mike Bayer 05a693fcb7 fixed NOT ILIKE 2008-01-11 21:30:02 +00:00
Mike Bayer 6d2d5e923e - added "ilike()" operator to column operations.
compiles to ILIKE on postgres, lower(x) LIKE lower(y)
on all others [ticket:727]
2008-01-11 21:24:01 +00:00
Jason Kirtland bf36c648f2 Reworked r4042- undeclared deprecation warnings are now *fatal* to tests. No surprises. 2008-01-10 02:37:39 +00:00
Jason Kirtland 84576e3258 test suite deprecation rampage 2008-01-09 22:54:51 +00:00
Mike Bayer 6eb9c11e7b - fixed bug in union() so that select() statements which don't derive
from FromClause objects can be unioned
2008-01-08 21:53:37 +00:00
Mike Bayer e8feacf1db - fixed an attribute history bug whereby assigning a new collection
to a collection-based attribute which already had pending changes
would generate incorrect history [ticket:922]

- fixed delete-orphan cascade bug whereby setting the same
object twice to a scalar attribute could log it as an orphan
[ticket:925]
- generative select.order_by(None) / group_by(None) was not managing to
reset order by/group by criterion, fixed [ticket:924]
2008-01-07 18:52:02 +00:00
Mike Bayer 64de56e55e fix select tests for labeled functions 2008-01-04 03:09:17 +00:00
Mike Bayer f6068a3522 - select().as_scalar() will raise an exception if the select does not have
exactly one expression in its columns clause.
- added "helper exception" to select.type access, generic functions raise
the chance of this happening
- a slight behavioral change to attributes is, del'ing an attribute
does *not* cause the lazyloader of that attribute to fire off again;
the "del" makes the effective value of the attribute "None".  To
re-trigger the "loader" for an attribute, use
session.expire(instance, [attrname]).
- fix ormtutorial for IS NULL
2007-12-18 00:24:03 +00:00
Mike Bayer 5cdb942791 - Query.select_from() now replaces all existing FROM criterion with
the given argument; the previous behavior of constructing a list
of FROM clauses was generally not useful as is required
filter() calls to create join criterion, and new tables introduced
within filter() already add themselves to the FROM clause.  The
new behavior allows not just joins from the main table, but select
statements as well.  Filter criterion, order bys, eager load
clauses will be "aliased" against the given statement.
2007-12-09 23:27:04 +00:00
Mike Bayer 78bb82a44b changed the anonymous numbering scheme to be more appealing
got tests running
2007-12-08 18:38:18 +00:00
Mike Bayer 7bf90e2f4d fix to unique bind params, you *can* use the same unique bindparam multiple times
in a statement.  the collision check is strictly detecting non-unique's that happen to have
the same name.
2007-12-07 16:47:00 +00:00
Mike Bayer 541b6772e9 - generation of "unique" bind parameters has been simplified to use the same
"unique identifier" mechanisms as everything else.  This doesn't affect
user code, except any code that might have been hardcoded against the generated
names.  Generated bind params now have the form "<paramname>_<num>",
whereas before only the second bind of the same name would have this form.

- bindparam() objects themselves can be used as keys for execute(), i.e.
statement.execute({bind1:'foo', bind2:'bar'})
2007-12-06 22:23:10 +00:00
Mike Bayer 238c2c8dbe - basic framework for generic functions, [ticket:615]
- changed the various "literal" generation functions to use an anonymous
bind parameter.  not much changes here except their labels now look
like ":param_1", ":param_2" instead of ":literal"
- from_obj keyword argument to select() can be a scalar or a list.
2007-12-05 03:07:21 +00:00
Mike Bayer ea46e556f9 - anonymous column expressions are automatically labeled.
e.g. select([x* 5]) produces "SELECT x * 5 AS anon_1".
    This allows the labelname to be present in the cursor.description
    which can then be appropriately matched to result-column processing
    rules. (we can't reliably use positional tracking for result-column
    matches since text() expressions may represent multiple columns).

  - operator overloading is now controlled by TypeEngine objects - the
    one built-in operator overload so far is String types overloading
    '+' to be the string concatenation operator.
    User-defined types can also define their own operator overloading
    by overriding the adapt_operator(self, op) method.

  - untyped bind parameters on the right side of a binary expression
    will be assigned the type of the left side of the operation, to better
    enable the appropriate bind parameter processing to take effect
    [ticket:819]
2007-11-10 03:02:16 +00:00
Jason Kirtland 681c8fc51c - mysql float types now do an end run around the base class and respect precision=None and length=None
- Added the mysteriously missing mysql cast support
- Added mysql REAL synonym for schema generation
2007-11-09 19:55:31 +00:00