Commit Graph

841 Commits

Author SHA1 Message Date
Mike Bayer fbd81de0eb Fixed a regression caused by 🎫2410 whereby a
:class:`.CheckConstraint` would apply itself back to the
original table during a :meth:`.Table.tometadata` operation, as
it would parse the SQL expression for a parent table. The
operation now copies the given expression to correspond to the
new table.
[ticket:2633]
2012-12-11 16:31:41 -05:00
Mike Bayer 3859742a91 Fixed bug where using server_onupdate=<FetchedValue|DefaultClause>
without passing the "for_update=True" flag would apply the default
object to the server_default, blowing away whatever was there.
The explicit for_update=True argument shouldn't be needed with this usage
(especially since the documentation shows an example without it being
used) so it is now arranged internally using a copy of the given default
object, if the flag isn't set to what corresponds to that argument.
Also in 0.7.10. [ticket:2631]
2012-12-08 20:28:43 -05:00
Mike Bayer 33bafcb132 Fixed bug whereby using a label_length on dialect that was smaller
than the size of actual column identifiers would fail to render
the columns correctly in a SELECT statement.
[ticket:2610]
2012-12-08 19:25:04 -05:00
Mike Bayer c183aa098b - refactor test_labels into all compiler/defaultdialect tests 2012-12-08 19:10:44 -05:00
Mike Bayer 9608eb8f1a attempt to hide these from 2to3 2012-12-08 17:50:51 -05:00
Mike Bayer 8070cbde71 internally at least refer to multirow as "multivalues", to distinguish between
an INSERT that's used in executemany() as opposed to one which has a VALUES
clause with multiple entries.
2012-12-08 16:17:20 -05:00
Mike Bayer 927b985983 - multivalued inserts, [ticket:2623]
- update "not supported" messages for empty inserts, mutlivalue inserts

- rework the ValuesBase approach for multiple value sets so that stmt.parameters
does store a list for multiple values; the _has_multiple_parameters flag now indicates
which of the two modes the statement is within.  it now raises exceptions if a subsequent
call to values() attempts to call a ValuesBase with one mode in the style of the other
mode; that is, you can't switch a single- or multi- valued ValuesBase to the other mode,
and also if a multiple value is passed simultaneously with a kwargs set.
Added tests for these error conditions

- Calling values() multiple times in multivalue mode now extends the parameter list to
include the new parameter sets.

- add error/test if multiple *args were passed to ValuesBase.values()

- rework the compiler approach for multivalue inserts, back to where
_get_colparams() returns the same list of (column, value) as before, thereby
maintaining the identical number of append() and other calls when multivalue
is not enabled.  In the case of multivalue, it makes a last-minute switch to return
a list of lists instead of the single list.  As it constructs the additional lists, the inline
defaults and other calculated default parameters of the first parameter
set are copied into the newly generated lists so that these features continue
to function for a multivalue insert.   Multivalue inserts now add no additional
function calls to the compilation for regular insert constructs.

- parameter lists for multivalue inserts now includes an integer index for all
parameter sets.

- add detailed documentation for ValuesBase.values(), including careful wording
to describe the difference between multiple values and an executemany() call.

- add a test for multivalue insert + returning - it works !

- remove the very old/never used "postgresql_returning"/"firebird_returning" flags.
2012-12-08 14:25:42 -05:00
Mike Bayer 1ee4736bea merge latest default 2012-12-08 11:23:21 -05:00
Idan Kamara d57c1c2ddd compiler: add support for multirow inserts
Some databases support this syntax for inserts:

INSERT INTO table (id, name) VALUES
('v1', 'v2'),
('v3', 'v4');

which greatly increases INSERT speed.

It is now possible to pass a list of lists/tuples/dictionaries as
the values param to the Insert construct. We convert it to a flat
dictionary so we can continue using bind params. The above query
will be converted to:

INSERT INTO table (id, name) VALUES
(:id, :name),
(:id0, :name0);

Currently only supported on postgresql, mysql and sqlite.
2012-12-06 00:11:52 +02:00
Diana Clarke e99f8be371 visit_DECIMAL should include precision and scale (when provided) just like visit_NUMERIC see #2618 2012-12-03 07:40:00 -05:00
Mike Bayer 4950b85e83 - BinaryExpression now keeps track of "left" and "right" as passed in,
so that they can be compared in ``__nonzero__`` prior to their
self_group() step.  [ticket:2621]
2012-12-02 12:37:52 -05:00
Mike Bayer d1bf4d2b86 - adjust this test for the ugly reality of the "name normalize" backends, where because we've decided
that "lowercase" is the case insensitive casing, we can't distinguish between case insensitive/not
on a database that returns case-insensitive names as UPPERCASE, for names that are UPPERCASE.
[ticket:2615]
2012-11-23 19:32:41 -05:00
Diana Clarke 66c5bc6c70 just a pep8 pass before I play with these tests 2012-11-23 11:09:57 -05:00
Diana Clarke 0c9eb43926 second pass: increasing coverage, and commenting the "why" certain things are being tested (when I know) b/c it wasn't initially clear to me why case was being toggled everywhere, etc. 2012-11-22 13:20:20 -05:00
Diana Clarke 1ea0a71c60 first pass cleaning up test_labels #2610 2012-11-21 22:36:46 -05:00
Diana Clarke 0587a7ecdd this test class had 2 'test_labels' methods, just changing one of them to 'test_labels3' for now 2012-11-21 20:57:49 -05:00
Mike Bayer 1e29a74bd6 Fixed a gotcha where inadvertently calling list() on a
:class:`.ColumnElement` would go into an endless loop, if
      :meth:`.ColumnOperators.__getitem__` were implemented.
      A new NotImplementedError is emitted via ``__iter__()``.
2012-11-18 10:38:02 -05:00
Mike Bayer 94f8a792aa fix this test 2012-11-14 21:47:41 -05:00
Mike Bayer 27db59b337 Fixed bug whereby using "key" with Column
in conjunction with "schema" for the owning
Table would fail to locate result rows due
to the MSSQL dialect's "schema rendering"
logic's failure to take .key into account.
Also in 0.7.10. [ticket:2607]
2012-11-13 23:43:31 -05:00
Mike Bayer 6397a4ff4b Fixed bug in type_coerce() whereby typing information
could be lost if the statement were used as a subquery
inside of another statement, as well as other similar
situations.  Among other things, would cause
typing information to be lost when the Oracle/mssql dialects
would apply limit/offset wrappings. [ticket:2603]
2012-11-12 15:48:40 -05:00
Mike Bayer 12df8a9901 - support "fails_if" requirements as __requires__; so far this just skips, doesn't
actually run the test
- add requirements for date/datetime/time capabilities
- remove test/sql/test_types->DateTest and create new tests in suite/test_types
- move the StringTest with the "no length create" test to the suite, though this is a
weird test
2012-11-12 14:30:18 -05:00
Mike Bayer d30ab8495c Fixed bug whereby the ".key" of a Column wasn't being
used when producing a "proxy" of the column against
a selectable.   This probably didn't occur in 0.7
since 0.7 doesn't respect the ".key" in a wider
range of scenarios. [ticket:2597]
2012-10-31 14:30:47 -04:00
Mike Bayer a13812606c - remove remote_foreign annotation
- support annotations on Column where name isn't immediately present
2012-10-28 18:23:57 -04:00
Mike Bayer d0651ef4b3 Added :meth:.ColumnOperators.notin_,
:meth:`.ColumnOperators.notlike`,
:meth:`.ColumnOperators.notilike` to :class:`.ColumnOperators`.
[ticket:2580]
2012-10-24 16:01:17 -04:00
Mike Bayer 07d7c4905d Fixed bug where keyword arguments passed to
:meth:`.Compiler.process` wouldn't get propagated
to the column expressions present in the columns
clause of a SELECT statement.  In particular this would
come up when used by custom compilation schemes that
relied upon special flags. [ticket:2593]
2012-10-24 15:37:06 -04:00
Mike Bayer e656bf4f47 - move most/all operator specific tests into test_operator, convert fully to TOT 2012-10-24 14:29:52 -04:00
Mike Bayer c859893cb8 - get 100% lint/pep8 happening for test_compiler; next we will begin
cutting up tests and removing old ones
- move test_in() to test_operators
- slice up migrated operator tests into TOT
2012-10-24 14:02:37 -04: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 ba67f7dbc5 - [bug] TypeDecorator now includes a generic repr()
that works in terms of the "impl" type by default.
    This is a behavioral change for those TypeDecorator
    classes that specify a custom __init__ method; those
    types will need to re-define __repr__() if they need
    __repr__() to provide a faithful constructor representation.
    [ticket:2594]
2012-10-18 12:29:41 -04:00
Mike Bayer 2484ef34c2 - [feature] The Query can now load entity/scalar-mixed
"tuple" rows that contain
    types which aren't hashable, by setting the flag
    "hashable=False" on the corresponding TypeEngine object
    in use.  Custom types that return unhashable types
    (typically lists) can set this flag to False.
    [ticket:2592]
  - [bug] Applying a column expression to a select
    statement using a label with or without other
    modifying constructs will no longer "target" that
    expression to the underlying Column; this affects
    ORM operations that rely upon Column targeting
    in order to retrieve results.  That is, a query
    like query(User.id, User.id.label('foo')) will now
    track the value of each "User.id" expression separately
    instead of munging them together.  It is not expected
    that any users will be impacted by this; however,
    a usage that uses select() in conjunction with
    query.from_statement() and attempts to load fully
    composed ORM entities may not function as expected
    if the select() named Column objects with arbitrary
    .label() names, as these will no longer target to
    the Column objects mapped by that entity.
    [ticket:2591]
2012-10-15 20:07:13 -04:00
Mike Bayer c307df6596 - [feature] "scalar" selects now have a WHERE method
to help with generative building.  Also slight adjustment
    regarding how SS "correlates" columns; the new methodology
    no longer applies meaning to the underlying
    Table column being selected.  This improves
    some fairly esoteric situations, and the logic
    that was there didn't seem to have any purpose.
  - [feature] Some support for auto-rendering of a
    relationship join condition based on the mapped
    attribute, with usage of core SQL constructs.
    E.g. select([SomeClass]).where(SomeClass.somerelationship)
    would render SELECT from "someclass" and use the
    primaryjoin of "somerelationship" as the WHERE
    clause.   This changes the previous meaning
    of "SomeClass.somerelationship" when used in a
    core SQL context; previously, it would "resolve"
    to the parent selectable, which wasn't generally
    useful.  Related to [ticket:2245].
2012-10-15 17:21:38 -04:00
Mike Bayer 06af57b05f - keep dialect at default for type compile
- python2.5/3 fixes
2012-10-11 11:15:29 -04:00
Mike Bayer d2410df9ca - create new sqlalchemy.testing.suite.test_types, starting with Unicode round trip tests.
- clean out existing test_types:UnicodeTest to be strictly individual unit tests
against Unicode(), String(), etc. with no database access.
2012-10-10 20:12:25 -04:00
Mike Bayer 084b559b44 - [feature] Added "collation" parameter to all
String types.  When present, renders as
    COLLATE <collation>.  This to support the
    COLLATE keyword now supported by several
    databases including MySQL, SQLite, and Postgresql.
    [ticket:2276]

  - [change] The Text() type renders the length
    given to it, if a length was specified.
2012-10-10 19:34:29 -04:00
Mike Bayer ef7c2f359d - don't call get_lastrowid() on explicit returning
- don't hardwire "subqueries" requirement in the base, mysql < 4.1 isn't working anyway
- don't need explicit FB/PG exclusions in test_returning
- hit db.connect() for the returning requirement
2012-10-04 17:36:02 -04:00
Mike Bayer 62b7a8133a - [bug] Fixed bug in over() construct whereby
passing an empty list for either partition_by
    or order_by, as opposed to None, would fail
    to generate correctly.
    Courtesy Gunnlaugur Por Briem.
    [ticket:2574]
2012-09-30 17:18:14 -04:00
Mike Bayer b9ea55f861 - more tests, move some tests out of test_reflection, test_query 2012-09-27 16:11:32 -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 1a7778632d - further reorganization of test suite:
- bootstrap and lib move to all absolute imports
  - testing.py is no longer internally referenced.
  - requirements move to be a pluggable class which can
    be overridden.
  - cleanup

in the interests of third party testing, test/lib and test/bootstrap
may move to be an independent package.
2012-09-26 17:21:21 -04:00
Mike Bayer c7c17e991c - [bug] Fixed the DropIndex construct to support
an Index associated with a Table in a remote
    schema. [ticket:2571]
2012-09-24 11:17:16 -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 152163b333 - [bug] When the primary key column of a Table
is replaced, such as via extend_existing,
    the "auto increment" column used by insert()
    constructs is reset.  Previously it would
    remain referring to the previous primary
    key column.  [ticket:2525]
2012-09-23 12:51:24 -04:00
Mike Bayer e354dd10f8 - [feature] An explicit error is raised when
a ForeignKeyConstraint() that was
    constructed to refer to multiple remote tables
    is first used. [ticket:2455]
2012-09-23 12:42:38 -04:00
Mike Bayer 4da34b4cb7 - clean pyflakes 2012-09-23 12:31:41 -04:00
Mike Bayer 23d300c874 - [bug] A tweak to column precedence which moves the
"concat" and "match" operators to be the same as
    that of "is", "like", and others; this helps with
    parenthesization rendering when used in conjunction
    with "IS". [ticket:2564]
2012-09-22 16:48:49 -04:00
Mike Bayer 6c50ffcf44 - aaand actually get is/isnot to be usable with None/NULL 2012-09-22 16:45:02 -04:00
Mike Bayer 1ceda8c23c - [bug] Added missing operators is_(), isnot()
to the ColumnOperators base, so that these long-available
    operators are present as methods like all
    the other operators.  [ticket:2544]
2012-09-22 16:14:58 -04:00
Mike Bayer 7e815c67a9 finished fixes for mxodbc; need to use at least version 3.2.1 2012-09-21 17:43:22 -04:00
Mike Bayer cd8b9dcd37 - [feature] The cast() and extract() constructs
will now be produced via the func.* accessor
as well, as users naturally try to access these
names from func.* they might as well do
what's expected, even though the returned
object is not a FunctionElement.
[ticket:2562]
2012-09-10 12:58:11 -04:00
Mike Bayer 1c325dc9c7 - [feature] Added a hook to the system of rendering
CREATE TABLE that provides access to the render for each
Column individually, by constructing a @compiles
function against the new schema.CreateColumn
construct.  [ticket:2463]
2012-09-09 14:39:25 -04:00