Commit Graph

47 Commits

Author SHA1 Message Date
Mike Bayer 9b73e997b2 - [bug] The names of the columns on the
.c. attribute of a select().apply_labels()
is now based on <tablename>_<colkey> instead
of <tablename>_<colname>, for those columns
that have a distinctly named .key.
[ticket:2397]
2012-04-24 11:24:23 -04:00
Mike Bayer 541e59c3d7 - [bug] UPDATE..FROM syntax with SQL Server
requires that the updated table be present
in the FROM clause when an alias of that
table is also present in the FROM clause.
The updated table is now always present
in the FROM, when FROM is present
in the first place.  Courtesy sayap.
[ticket:2468]
2012-04-18 19:52:58 -04:00
Mike Bayer 7142a17291 - [feature] Added new for_update/with_lockmode()
options for Postgresql: for_update="read"/
with_lockmode("read"),
for_update="read_nowait"/
with_lockmode("read_nowait").
These emit "FOR SHARE" and "FOR SHARE NOWAIT",
respectively.  Courtesy Diana Clarke
[ticket:2445]
2012-03-21 22:58:55 -04:00
Mike Bayer 1607b74f85 - [feature] Added cte() method to Query,
invokes common table expression support
from the Core (see below). [ticket:1859]

- [feature] Added support for SQL standard
common table expressions (CTE), allowing
SELECT objects as the CTE source (DML
not yet supported).  This is invoked via
the cte() method on any select() construct.
[ticket:1859]
2012-03-03 13:00:44 -05:00
Mike Bayer abe6c0f08a - [bug] A warning is emitted when a not-present
column is stated in the values() clause
of an insert() or update() construct.
Will move to an exception in 0.8.
[ticket:2413]
2012-02-21 10:49:38 -05:00
Mike Bayer 2dbeeff50b - [bug] Added support for using the .key
of a Column as a string identifier in a
result set row.   The .key is currently
listed as an "alternate" name for a column,
and is superseded by the name of a column
which has that key value as its regular name.
For the next major release
of SQLAlchemy we may reverse this precedence
so that .key takes precedence, but this
is not decided on yet.  [ticket:2392]
2012-02-05 16:58:32 -05:00
Mike Bayer dbd46170fb mark this test as unsupported before 2.6, there's some unicode
issue I'm not exactly sure of what nature it is
2012-01-28 16:00:34 -05:00
Mike Bayer 09553dc90f - [feature] Dialect-specific compilers now raise
CompileException for all type/statement compilation
issues, instead of InvalidRequestError or ArgumentError.
The DDL for CREATE TABLE will re-raise
CompileExceptions to include table/column information
for the problematic column.  [ticket:2361]
2012-01-28 15:20:21 -05:00
Mike Bayer c6e07f6a59 - [bug] Fixed issue where the "required" exception
would not be raised for bindparam() with required=True,
if the statement were given no parameters at all.
[ticket:2381]
2012-01-28 14:20:25 -05:00
Mike Bayer 0c3a53d433 sort of muscling this out, mysql a PITA 2011-11-21 20:40:31 -05:00
Mike Bayer 3104da4139 fix test 2011-09-24 12:13:45 -04:00
Mike Bayer 840aab3bea - Behavioral improvement: empty
conjunctions such as and_() and or_() will be
    flattened in the context of an enclosing conjunction,
    i.e. and_(x, or_()) will produce 'X' and not 'X AND
    ()'. [ticket:2257].
2011-09-09 16:03:23 -04:00
Mike Bayer 5751eb17f1 - Query will convert an OFFSET of zero when
slicing into None, so that needless OFFSET
clauses are not invoked.
- mssql: "0" is accepted as an argument for limit() which
will produce "TOP 0". [ticket:2222]
- add tests to default compiler test for LIMIT/OFFSET generation
2011-08-06 15:03:33 -04:00
Mike Bayer 69dcd805d2 - Added explicit true()/false() constructs to expression
lib - coercion rules will intercept "False"/"True"
into these constructs.  In 0.6, the constructs were
typically converted straight to string, which was
no longer accepted in 0.7.  [ticket:2117]
2011-04-17 15:37:12 -04:00
Mike Bayer 509f3fb492 - Fixed incorrect usage of "," in over() clause
being placed between the "partition" and "order by"
clauses.  [ticket:2134]
2011-04-17 13:40:37 -04:00
Mike Bayer 2d34ded2d8 - fixed bug where "from" clause gathering from an
over() clause would be an itertools.chain() and
    not a list, causing "can only concatenate list"
    TypeError when combined with other clauses.
2011-04-14 23:44:03 -04:00
Mike Bayer 51fea2e159 - The limit/offset keywords to select() as well
as the value passed to select.limit()/offset()
will be coerced to integer.  [ticket:2116]
(also in 0.6.7)
- Oracle dialect adds use_binds_for_limits=False
create_engine() flag, will render the LIMIT/OFFSET
values inline instead of as binds, reported to
modify the execution plan used by Oracle.
[ticket:2116] (Also in 0.6.7)
2011-04-07 13:34:38 -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
Taavi Burns f9e58cad3b Fix 3 errors in py32, from patch from lsblakk. There are still 8 failures. See #2088. 2011-03-16 00:32:33 -04:00
Mike Bayer 33eae4a140 make it more explicit in tests which dialect we want to use for things 2011-02-11 11:24:54 -05:00
Mike Bayer 020d6ef8f0 - Added over() function, method to FunctionElement
classes, produces the _Over() construct which
in turn generates "window functions", i.e.
"<window function> OVER (PARTITION BY <partition by>,
ORDER BY <order by>)".
[ticket:1844]
2011-02-10 21:57:44 -05:00
Mike Bayer 67e0f356b2 - A TypeDecorator of Integer can be used with a primary key
column, and the "autoincrement" feature of various dialects
  as well as the "sqlite_autoincrement" flag will honor
  the underlying database type as being Integer-based.
 [ticket:2005]

- Result-row processors are applied to pre-executed SQL
  defaults, as well as cursor.lastrowid, when determining
  the contents of result.inserted_primary_key.
  [ticket:2006]

- Bind parameters present in the "columns clause" of a select
  are now auto-labeled like other "anonymous" clauses,
  which among other things allows their "type" to be meaningful
  when the row is fetched, as in result row processors.

- TypeDecorator is present in the "sqlalchemy" import space.
2011-01-11 15:22:46 -05:00
Mike Bayer 350aed3fdb - whitespace removal bonanza 2011-01-02 14:23:42 -05:00
Michael Trier 15ea17d7f8 Added NULLS FIRST and NULLS LAST support.
It's implemented as an extension to the asc() and desc() operators, called
nullsfirst() and nullslast().  [ticket:723]
2010-12-19 19:25:33 -05:00
Mike Bayer f1e54a69fb - merge default tip 2010-12-05 14:56:26 -05:00
Mike Bayer 58b2939433 - sqlalchemy.test and nose plugin moves back to being entirely
outside of "sqlalchemy" and under "test/".

Rationale:

- coverage plugin works without issue, without need for an awkward
additional package install
- command line for "nosetests" isn't polluted with SQLAlchemy options

[ticket:1949]
2010-11-28 14:19:44 -05:00
Mike Bayer 59a177a4c0 - _literal_as_text raises if the incoming arg is not a Visitable or basestring.
[ticket:1847]
2010-11-28 11:24:57 -05:00
Mike Bayer 77f641429f - Fixed operator precedence rules for multiple
chains of a single non-associative operator.
I.e. "x - (y - z)" will compile as "x - (y - z)"
and not "x - y - z".  Also works with labels,
i.e. "x - (y - z).label('foo')"
[ticket:1984]
- Single element tuple expressions inside an IN clause
parenthesize correctly, also from [ticket:1984],
added tests for PG
- re-fix again importlater, [ticket:1983]
2010-11-25 12:20:13 -05:00
Mike Bayer ea55a4644c - bindparam() gets a new option "callable", which is a lambda or def
evaluated at execution time to determine the value.  This replaces
the implicit recognition of callables sent as the primary value
of bindparam(), which was an undocumented behavior used by the ORM.
The argument is separated now so that values can be passed to
bindparams that are also callables without ambiguity, such
as user defined objects that include a __call__() method.
[ticket:1950]
2010-11-20 15:43:12 -05:00
Mike Bayer e3ca3a773f - merge FromObj cleanup, immutable .c attribute patch, [ticket:1917] 2010-11-20 15:35:43 -05:00
Mike Bayer 041a329e69 - adapt initial patch from [ticket:1917] to current tip
- raise TypeError for immutability
2010-11-16 15:53:14 -05:00
Mike Bayer e1402efb19 - move sqlalchemy.test to test.lib 2010-11-15 19:37:50 -05:00
Mike Bayer 6fb06409c6 merge tip 2010-11-14 18:25:13 -05:00
Mike Bayer b96e6232a4 cleanup most egregiously long lines 2010-10-24 13:26:34 -04:00
Mike Bayer 90c8d8e0c9 merge tip 2010-09-19 16:11:16 -04:00
Mike Bayer c5c8cdf3b4 - as_scalar(), label() can be called on a selectable
which contains a Column that is not yet named.
[ticket:1862]
2010-09-18 13:34:04 -04:00
Mike Bayer 003149c504 - An informative error message is raised if a Column
which has not yet been assigned a name, i.e. as in
declarative, is used in a context where it is
exported to the columns collection of an enclosing
select() construct, or if any construct involving
that column is compiled before its name is
assigned.  [ticket:1862]
2010-09-18 13:18:44 -04:00
Mike Bayer e4bc7d2894 - move LIMIT/OFFSET rendering to be as bind parameters, for all backends
which support it.  This includes SQLite, MySQL, Postgresql, Firebird,
Oracle (already used binds with ROW NUMBER OVER), MSSQL (when ROW NUMBER
is used, not TOP).   Not included are Informix, Sybase, MaxDB, Access
[ticket:805]
- LIMIT/OFFSET parameters need to stay as literals within SQL
constructs.  This because they may not be renderable as binds on
some backends.
2010-08-29 16:35:02 -04:00
Mike Bayer 7dcfc49b34 fix test 2010-06-24 12:45:37 -04:00
Mike Bayer 074ecc4376 - expr.in_() now accepts a text() construct as the argument.
Grouping parenthesis are added automatically, i.e. usage
is like `col.in_(text("select id from table"))`.
[ticket:1793]
2010-05-08 16:25:30 -04:00
Mike Bayer 5c758932a5 - Restored some bind-labeling logic from 0.5 which ensures
that tables with column names that overlap another column
of the form "<tablename>_<columnname>" won't produce
errors if column._label is used as a bind name during
an UPDATE.  Test coverage which wasn't present in 0.5
has been added.  [ticket:1755]
2010-03-31 13:01:40 -04:00
Mike Bayer 5d0d680693 comment out test that relies on dictionary ordering for now 2010-03-27 18:15:05 -04:00
Mike Bayer 36047e9bb2 - Added with_hint() method to Query() construct. This calls
directly down to select().with_hint() and also accepts
entities as well as tables and aliases.  See with_hint() in the
SQL section below. [ticket:921]
- Added with_hint() method to select() construct.  Specify
a table/alias, hint text, and optional dialect name, and
"hints" will be rendered in the appropriate place in the
statement.  Works for Oracle, Sybase, MySQL.  [ticket:921]
2010-03-27 17:18:53 -04:00
Mike Bayer 6acc9e6d9e - The Oracle dialect will issue VARCHAR type definitions
using character counts, i.e. VARCHAR2(50 CHAR), so that
the column is sized in terms of characters and not bytes.
Column reflection of character types will also use
ALL_TAB_COLUMNS.CHAR_LENGTH instead of
ALL_TAB_COLUMNS.DATA_LENGTH.  Both of these behaviors take
effect when the server version is 9 or higher - for
version 8, the old behaviors are used.  [ticket:1744]
2010-03-25 22:26:11 +00:00
Mike Bayer 1321db6473 - Fixed bug introduced in 0.6beta2 where column labels would
render inside of column expressions already assigned a label.
[ticket:1747]
2010-03-23 20:41:40 -04:00
Mike Bayer 0f55ef3bea rename test_select to test_compiler 2010-03-19 15:32:17 -04:00