Commit Graph

976 Commits

Author SHA1 Message Date
Mike Bayer 2537773d1e a few oracle test failures 2013-12-28 18:24:43 -05:00
Mike Bayer cac7320eeb - adjust the behavior of cast() to only provide a type for the bindparam()
if we are coercing straight from string.  [ticket:2899]
- rework the tests here to be individual
2013-12-28 16:37:54 -05:00
Mike Bayer 65bd6ec966 - Fixed issue where a primary key column that has a Sequence on it,
yet the column is not the "auto increment" column, either because
it has a foreign key constraint or ``autoincrement=False`` set,
would attempt to fire the Sequence on INSERT for backends that don't
support sequences, when presented with an INSERT missing the primary
key value.  This would take place on non-sequence backends like
SQLite, MySQL. [ticket:2896]
2013-12-20 10:26:09 -05:00
Mike Bayer 5f76f29c15 - Fixed bug with :meth:.Insert.from_select method where the order
of the given names would not be taken into account when generating
the INSERT statement, thus producing a mismatch versus the column
names in the given SELECT statement.  Also noted that
:meth:`.Insert.from_select` implies that Python-side insert defaults
cannot be used, since the statement has no VALUES clause. [ticket:2895]
2013-12-19 16:02:14 -05:00
Mike Bayer 2692238f45 - Improvements to the system by which SQL types generate within
``__repr__()``, particularly with regards to the MySQL integer/numeric/
character types which feature a wide variety of keyword arguments.
The ``__repr__()`` is important for use with Alembic autogenerate
for when Python code is rendered in a migration script.
[ticket:2893]
2013-12-18 18:26:15 -05:00
Mike Bayer f701f87c13 - skip this test for oracle 2013-12-18 14:02:40 -05:00
Mike Bayer be06bcf3b9 - remove very ancient TypeEngine constructor, not used by anything 2013-12-17 17:56:03 -05:00
Mike Bayer 80b6591dbe - The :func:.cast function, when given a plain literal value,
will now apply the given type to the given literal value on the
bind parameter side according
to the type given to the cast.   This essentially replaces what would
normally be the detected type of the literal value.   This only
takes effect if the auto-detected type of the literal value is either
"nulltype" (e.g. couldn't detect)
or a type that is of the same "affinity" as the cast type.
The net change here is that the :func:`.cast` function includes more
of the functionality already present in the :func:`.type_coerce` function.
2013-12-17 15:38:35 -05:00
Mike Bayer 207aaf2f41 - for [ticket:2651], leaving CheckConstraint alone, preferring to keep
backwards compatibility.  A note about backslashing escapes is added.
Because the Text() construct now supports bind params better, the example
given in the code raises an exception now, so that should cover us.
The exception itself has been enhanced to include the key name of the
bound param.  We're backporting this to 0.8 but 0.8 doesn't have the
text->bind behavior that raises.
2013-12-16 19:32:10 -05:00
Mike Bayer d5384d6011 - implement "literal binds" for the text() clause, [ticket:2882] 2013-12-11 20:00:39 -05:00
Mike Bayer 84af7e6c22 - The :class:.ForeignKey class more aggressively checks the given
column argument.   If not a string, it checks that the object is
at least a :class:`.ColumnClause`, or an object that resolves to one,
and that the ``.table`` attribute, if present, refers to a
:class:`.TableClause` or subclass, and not something like an
:class:`.Alias`.  Otherwise, a :class:`.ArgumentError` is raised.
[ticket:2883]
2013-12-11 19:48:27 -05:00
Mike Bayer b653fb3a23 - The precedence rules for the :meth:.ColumnOperators.collate operator
have been modified, such that the COLLATE operator is now of lower
precedence than the comparison operators.  This has the effect that
a COLLATE applied to a comparison will not render parenthesis
around the comparison, which is not parsed by backends such as
MSSQL.  The change is backwards incompatible for those setups that
were working around the issue by applying :meth:`.Operators.collate`
to an individual element of the comparison expression,
rather than the comparison expression as a whole. [ticket:2879]
2013-12-05 19:03:31 -05:00
Mike Bayer 207fafe7e3 - add support for bindparam() called from AsFromText
- get PG dialect to work around "no nonexistent binds" rule for now,
though we might want to reconsider this behavior
2013-11-29 19:06:33 -05:00
Mike Bayer 6c83ef761b - New improvements to the :func:.text construct, including
more flexible ways to set up bound parameters and return types;
in particular, a :func:`.text` can now be turned into a full
FROM-object, embeddable in other statements as an alias or CTE
using the new method :meth:`.TextClause.columns`.
[ticket:2877]
2013-11-29 15:05:19 -05:00
Mike Bayer 31cecebd48 - add support for specifying tables or entities for "of"
- implement Query with_for_update()
- rework docs and tests
2013-11-28 23:23:27 -05:00
Mike Bayer 4aaf3753d7 - fix up rendering of "of"
- move out tests, dialect specific out of compiler, compiler tests use new API,
legacy API tests in test_selecatble
- add support for adaptation of ForUpdateArg, alias support in compilers
2013-11-28 22:25:09 -05:00
Mike Bayer bb60a8ad94 - work in progress, will squash 2013-11-28 12:37:15 -05:00
Mike Bayer f112dc1d53 - Fixed bug where SQL statement would be improperly ASCII-encoded
when a pre-DBAPI :class:`.StatementError` were raised within
:meth:`.Connection.execute`, causing encoding errors for
non-ASCII statements.  The stringification now remains within
Python unicode thus avoiding encoding errors. [ticket:2871]
2013-11-22 18:35:36 -05:00
Mike Bayer 9499b88f85 fix [ticket:2868] some more 2013-11-21 15:39:05 -05:00
Mike Bayer 42fd77a4bf - Fixed a regression caused by 🎫2812 where the repr() for
table and column names would fail if the name contained non-ascii
characters. [ticket:2868]
2013-11-21 13:16:49 -05:00
Mike Bayer 02f21ffcf3 - The :class:.RowProxy object is now sortable in Python as a regular
tuple is; this is accomplished via ensuring tuple() conversion on
both sides within the ``__eq__()`` method as well as
the addition of a ``__lt__()`` method. [ticket:2848]
2013-11-19 19:29:18 -05:00
Mike Bayer 59ca4633ac - remove informix dialect, moved out to https://bitbucket.org/zzzeek/sqlalchemy_informixdb
- remove informix, maxdb, access symbols from tests etc.
2013-11-17 13:45:23 -05:00
Mike Bayer 5d0e84434f - Fixed a regression introduced by the join rewriting feature of
🎫`2369` and 🎫`2587` where a nested join with one side
already an aliased select would fail to translate the ON clause on the
outside correctly; in the ORM this could be seen when using a
SELECT statement as a "secondary" table. [ticket:2858]
2013-11-01 15:24:43 -04:00
Mike Bayer 3a4567a718 - add migration notes for [ticket:2838]
- have TypeDecorator use process_bind_param for literal values if no
process_literal_param is set
2013-10-24 16:13:32 -04:00
Mike Bayer f035b6e0a4 An overhaul of expression handling for special symbols particularly
with conjunctions, e.g.
``None`` :func:`.expression.null` :func:`.expression.true`
:func:`.expression.false`, including consistency in rendering NULL
in conjunctions, "short-circuiting" of :func:`.and_` and :func:`.or_`
expressions which contain boolean constants, and rendering of
boolean constants and expressions as compared to "1" or "0" for backends
that don't feature ``true``/``false`` constants. [ticket:2804]
2013-10-23 17:44:52 -04:00
Mike Bayer 9caa92b96f - A :func:.bindparam construct with a "null" type (e.g. no type
specified) is now copied when used in a typed expression, and the
new copy is assigned the actual type of the compared column.  Previously,
this logic would occur on the given :func:`.bindparam` in place.
Additionally, a similar process now occurs for :func:`.bindparam` constructs
passed to :meth:`.ValuesBase.values` for a :class:`.Insert` or
:class:`.Update` construct. [ticket:2850]
2013-10-21 16:49:46 -04:00
Mike Bayer 5697662416 - Fixed bug where :func:.type_coerce would not interpret ORM
elements with a ``__clause_element__()`` method properly.
[ticket:2849]
2013-10-21 15:06:41 -04:00
Mike Bayer 4663ec98b2 - The typing system now handles the task of rendering "literal bind" values,
e.g. values that are normally bound parameters but due to context must
be rendered as strings, typically within DDL constructs such as
CHECK constraints and indexes (note that "literal bind" values
become used by DDL as of 🎫`2742`).  A new method
:meth:`.TypeEngine.literal_processor` serves as the base, and
:meth:`.TypeDecorator.process_literal_param` is added to allow wrapping
of a native literal rendering method. [ticket:2838]
- enhance _get_colparams so that we can send flags like literal_binds into
INSERT statements
- add support in PG for inspecting standard_conforming_strings
- add a new series of roundtrip tests based on INSERT of literal plus SELECT
for basic literal rendering in dialect suite
2013-10-20 16:59:56 -04:00
Mike Bayer 0b0764b62b - add a type_coerce() step within Enum, Boolean to the CHECK constraint,
so that the custom type isn't exposed to an operation that is against the
"impl" type's constraint, [ticket:2842]
- this change showed up as some recursion overflow in pickling with labels,
add a __reduce__() there....pickling of expressions is less and less something
that's very viable...
2013-10-20 16:25:46 -04:00
Mike Bayer 73669c7284 - The :meth:.Table.tometadata method now produces copies of
all :attr:`.SchemaItem.info` dictionaries from all :class:`.SchemaItem`
objects within the structure including columns, constraints,
foreign keys, etc.   As these dictionaries
are copies, they are independent of the original dictionary.
Previously, only the ``.info`` dictionary of :class:`.Column` was transferred
within this operation, and it was only linked in place, not copied.
[ticket:2716]
2013-10-18 20:01:45 -04:00
Mike Bayer 78a38967c4 The `.unique flag on :class:.Index could be produced as None`
if it was generated from a :class:`.Column` that didn't specify ``unique``
(where it defaults to ``None``).  The flag will now always be ``True`` or
``False``. [ticket:2825]
2013-10-14 14:53:28 -04:00
Mike Bayer 9bc9d5c106 - Fixed bug in default compiler plus those of postgresql, mysql, and
mssql to ensure that any literal SQL expression values are
rendered directly as literals, instead of as bound parameters,
within a CREATE INDEX statement. [ticket:2742]
- don't need expression_as_ddl(); literal_binds and include_table
take care of this functionality.
2013-10-12 20:04:55 -04:00
Mike Bayer 1f1ad557af The `default argument of :class:.Column` now accepts a class
or object method as an argument, in addition to a standalone function;
will properly detect if the "context" argument is accepted or not.
2013-10-11 16:16:08 -04:00
Mike Bayer 9d38ed3340 The "name" attribute is set on :class:.Index before the "attach"
events are called, so that attachment events can be used to dynamically
generate a name for the index based on the parent table and/or
columns. [ticket:2835]
2013-10-11 15:55:57 -04:00
Mike Bayer e74627f827 A :func:.select that is made to refer to itself in its FROM clause,
typically via in-place mutation, will raise an informative error
message rather than causing a recursion overflow.
[ticket:2815]
2013-10-08 20:06:58 -04:00
Mike Bayer 9df4651fba Fixed bug where using an annotation such as :func:.remote or
:func:`.foreign` on a :class:`.Column` before association with a parent
:class:`.Table` could produce issues related to the parent table not
rendering within joins, due to the inherent copy operation performed
by an annotation. [ticket:2813]
2013-10-08 19:47:13 -04:00
Mike Bayer d79e1d69a6 - fix propagation of quote flag within _gen_label() so that if the
name is already an instance of _anonymous_label(), we don't downgrade
it to a plain quoted_name - fixes regression from [ticket:2812].
[ticket:2834]
2013-10-05 23:47:49 -04:00
Mike Bayer 08a6a8b519 - Removed some now unneeded version checks [ticket:2829] courtesy alex gaynor 2013-09-22 20:35:40 -04:00
Mike Bayer 835f1a38bf repair missing oracle skip 2013-08-28 10:16:52 -04:00
Mike Bayer 650c7e46be - these tests now fail on a normalize name DB, as they should! because we're quoting the lowercase name. 2013-08-28 00:11:15 -04:00
Mike Bayer 5672f78806 callcounts 2013-08-27 23:51:34 -04:00
Mike Bayer 7bf231232c - cx_oracle seems to have a bug here though it is hard to track down
- cx_oracle dialect doesn't use normal col names, lets just not rely on that for now
2013-08-27 21:37:22 -04:00
Mike Bayer 031ef08078 - A rework to the way that "quoted" identifiers are handled, in that
instead of relying upon various ``quote=True`` flags being passed around,
these flags are converted into rich string objects with quoting information
included at the point at which they are passed to common schema constructs
like :class:`.Table`, :class:`.Column`, etc.   This solves the issue
of various methods that don't correctly honor the "quote" flag such
as :meth:`.Engine.has_table` and related methods.  The :class:`.quoted_name`
object is a string subclass that can also be used explicitly if needed;
the object will hold onto the quoting preferences passed and will
also bypass the "name normalization" performed by dialects that
standardize on uppercase symbols, such as Oracle, Firebird and DB2.
The upshot is that the "uppercase" backends can now work with force-quoted
names, such as lowercase-quoted names and new reserved words.
[ticket:2812]
2013-08-27 20:43:22 -04:00
Mike Bayer e9c748a7bf - ensure rowcount is returned for an UPDATE with no implicit returning
- modernize test for that
- use py3k compatible next() in test_returning/test_versioning
2013-08-25 17:37:59 -04:00
Mike Bayer d6ce68727f - The `version_id_generator parameter of Mapper` can now be specified
to rely upon server generated version identifiers, using triggers
or other database-provided versioning features, by passing the value
``False``.  The ORM will use RETURNING when available to immediately
load the new version identifier, else it will emit a second SELECT.
[ticket:2793]
- The ``eager_defaults`` flag of :class:`.Mapper` will now allow the
newly generated default values to be fetched using an inline
RETURNING clause, rather than a second SELECT statement, for backends
that support RETURNING.
- Added a new variant to :meth:`.ValuesBase.returning` called
:meth:`.ValuesBase.return_defaults`; this allows arbitrary columns
to be added to the RETURNING clause of the statement without interfering
with the compilers usual "implicit returning" feature, which is used to
efficiently fetch newly generated primary key values.  For supporting
backends, a dictionary of all fetched values is present at
:attr:`.ResultProxy.returned_defaults`.
- add a glossary entry for RETURNING
- add documentation for version id generation, [ticket:867]
2013-08-25 14:03:54 -04:00
Mike Bayer 00f3ca98ce forgot to add system to the copy() method
Conflicts:
	lib/sqlalchemy/schema.py
2013-08-25 12:35:06 -04:00
Mike Bayer 2452c49cc4 added "system=True" to Column, so that we generally don't have to bother
with CreateColumn rules
2013-08-25 12:29:22 -04:00
Mike Bayer 236db85f96 Fixed regression dating back to 0.7.9 whereby the name of a CTE might
not be properly quoted if it was referred to in multiple FROM clauses.
Also in 0.8.3, 0.7.11. [ticket:2801]
2013-08-18 14:46:04 -04:00
Mike Bayer f6198d9abf - A large refactoring of the `sqlalchemy.sql` package has reorganized
the import structure of many core modules.
``sqlalchemy.schema`` and ``sqlalchemy.types``
remain in the top-level package, but are now just lists of names
that pull from within ``sqlalchemy.sql``.  Their implementations
are now broken out among ``sqlalchemy.sql.type_api``, ``sqlalchemy.sql.sqltypes``,
``sqlalchemy.sql.schema`` and ``sqlalchemy.sql.ddl``, the last of which was
moved from ``sqlalchemy.engine``.  ``sqlalchemy.sql.expression`` is also
a namespace now which pulls implementations mostly from ``sqlalchemy.sql.elements``,
``sqlalchemy.sql.selectable``, and ``sqlalchemy.sql.dml``.
Most of the "factory" functions
used to create SQL expression objects have been moved to classmethods
or constructors, which are exposed in ``sqlalchemy.sql.expression``
using a programmatic system.  Care has been taken such that all the
original import namespaces remain intact and there should be no impact
on any existing applications.   The rationale here was to break out these
very large modules into smaller ones, provide more manageable lists
of function names, to greatly reduce "import cycles" and clarify the
up-front importing of names, and to remove the need for redundant
functions and documentation throughout the expression package.
2013-08-12 17:50:37 -04:00
Mike Bayer 34ef21909b - The :meth:.Operators.notin_ operator added in 0.8 now properly
produces the negation of the expression "IN" returns
when used against an empty collection.  Also in 0.8.3.
2013-08-07 13:28:45 -05:00