Commit Graph

3973 Commits

Author SHA1 Message Date
Audrius Kažukauskas dbdf4f25e2 Add ANY/ALL construct support for PostgreSQL's ARRAY type 2013-01-28 19:58:06 +02:00
Mike Bayer e26b28224d Fixed bug where :meth:.Table.tometadata would fail if a
:class:`.Column` had both a foreign key as well as an
alternate ".key" name for the column.   Also in 0.7.10.
[ticket:2643]
2013-01-27 11:23:59 -05:00
Mike Bayer 2cf83604c6 #2629
insert().returning() raises an informative CompileError if attempted
to compile on a dialect that doesn't support RETURNING.
2013-01-25 12:57:59 -05:00
Mike Bayer a477f8a61e the consideration of a pending object as
an "orphan" has been modified to more closely match the
behavior as that of persistent objects, which is that the object
is expunged from the :class:`.Session` as soon as it is
de-associated from any of its orphan-enabled parents.  Previously,
the pending object would be expunged only if de-associated
from all of its orphan-enabled parents.  The new flag ``legacy_is_orphan``
is added to :func:`.orm.mapper` which re-establishes the
legacy behavior. [ticket:2655]
2013-01-24 21:31:23 -05:00
Mike Bayer b1df6fab53 Fixed the (most likely never used) "@collection.link" collection
method, which fires off each time the collection is associated
or de-associated with a mapped object - the decorator
was not tested or functional.  The decorator method
is now named :meth:`.collection.linker` though the name "link"
remains for backwards compatibility.  Courtesy Luca Wehrstedt.
[ticket:2653]
2013-01-21 18:17:10 -05:00
Mike Bayer 2c425c9680 - Made some fixes to the system of producing custom instrumented
collections, mainly that the usage of the @collection decorators
will now honor the __mro__ of the given class, applying the
logic of the sub-most classes' version of a particular collection
method.   Previously, it wasn't predictable when subclassing
an existing instrumented class such as :class:`.MappedCollection`
whether or not custom methods would resolve correctly.
[ticket:2654]

- The undocumented (and hopefully unused) system of producing
custom collections using an ``__instrumentation__`` datastructure
associated with the collection has been removed, as this was a complex
and untested feature which was also essentially redundant versus the
decorator approach.   Other internal simplifcations to the
orm.collections module have been made as well.
2013-01-21 17:57:24 -05:00
Mike Bayer 5af97bee84 clean all pep8 warnings 2013-01-21 16:16:57 -05:00
Mike Bayer b1a01a6256 - replace mssql_ordering with generalized #695 solution
- documentation for mssql index options plus changelog and fixes
2013-01-20 12:43:39 -05:00
Mike Bayer bc75bbd62d Merged in dharland/sqlalchemy (pull request #35)
Add extra mssql dialect options to Index
2013-01-20 12:23:39 -05:00
Mike Bayer 2244c3febe - "postgres_where" has been removed 2013-01-16 23:53:00 -05:00
Mike Bayer 7fedf99586 :class:.Index now supports arbitrary SQL expressions and/or
functions, in addition to straight columns.   Common modifiers
include using ``somecolumn.desc()`` for a descending index and
``func.lower(somecolumn)`` for a case-insensitive index, depending on the
capabilities of the target backend.
[ticket:695]
2013-01-16 21:04:32 -05:00
Mike Bayer 8700264340 - preparing for #695, modernize constraint/index tests 2013-01-16 20:10:55 -05:00
Derek Harland f5a5a6bf43 Add mssql_include option for mssql dialect 2013-01-14 17:03:38 +13:00
Derek Harland 38f7650072 Add mssql_ordering option for mssql dialect 2013-01-14 17:02:20 +13:00
Derek Harland 7198abb13e Add mssql_clustered option for mssql dialect 2013-01-14 17:00:37 +13:00
Mike Bayer 46a9209cde Added a py3K conditional around unnecessary .decode()
call in mssql information schema, fixes reflection
in Py3K. Also in 0.7.10. [ticket:2638]
2013-01-12 19:51:13 -05:00
Mike Bayer e6f29c7394 - update some profiling stats due to the #2650 change 2013-01-12 17:36:07 -05:00
Mike Bayer 576224edd0 - add workaround for sqlite memusage tests, so no longer need to count to 220/skip tests
- Fixed potential memory leak which could occur if an
arbitrary number of :class:`.sessionmaker` objects
were created.   The anonymous subclass created by
the sessionmaker, when dereferenced, would not be garbage
collected due to remaining class-level references from the
event package.  This issue also applies to any custom system
that made use of ad-hoc subclasses in conjunction with
an event dispatcher.  Also in 0.7.10. [ticket:2650]
2013-01-12 17:21:35 -05:00
Mike Bayer 56b1f4c884 - changelog for pullreq 32
- Fixed a regression whereby the "collation" parameter
of the character types CHAR, NCHAR, etc. stopped working,
as "collation" is now supported by the base string types.
The TEXT, NCHAR, CHAR, VARCHAR types within the
MSSQL dialect are now synonyms for the base types.
- move out the type rendering tests into DB-agnostic tests
and remove some of the old "create" statements.  tests here
are still very disorganized.
2013-01-12 12:14:15 -05:00
Mike Bayer 17c300eb07 Merged in dharland/sqlalchemy (pull request #32: Allow the MSSQL dialect to support identity columns that are not part of the primary key) 2013-01-12 11:43:36 -05:00
Mike Bayer 06ddce3215 :meth:.Query.merge_result can now load rows from an outer join
where an entity may be ``None`` without throwing an error.
[ticket:2640]
2013-01-08 10:55:46 -05:00
Mike Bayer a94f2f81af Fixed bug in :func:.postgresql.array construct whereby using it
inside of an :func:`.expression.insert` construct would produce an
error regarding a parameter issue in the ``self_group()`` method.
2013-01-02 11:26:37 -05:00
Mike Bayer b30ef87d27 Extended the :doc:/core/inspection system so that all Python descriptors
associated with the ORM or its extensions can be retrieved.
This fulfills the common request of being able to inspect
all :class:`.QueryableAttribute` descriptors in addition to
extension types such as :class:`.hybrid_property` and
:class:`.AssociationProxy`.  See :attr:`.Mapper.all_orm_descriptors`.
2012-12-29 19:31:28 -05:00
Mike Bayer 5b23a68080 - add tests to ensure SELECT of dynamic collection not emitted
on regular append/remove history
- fix the real cause of the original #2637 issue, backrefs call upon
the "pop()" method now which wasn't implemented for Dynamic
2012-12-22 18:40:06 -05:00
Mike Bayer efbbe88705 - revert the full iteration of the collection for a passive history event; that's
the wrong behavior, and for the original #2637 issue we will have to fix the
association proxy, which is #2642
2012-12-22 10:36:55 -05:00
Mike Bayer 3522785ef4 - significantly rework the approach to collection events and history within DynamicAttributeImpl
- Fixes to the "dynamic" loader on :func:`.relationship`, includes
that backrefs will work properly even when autoflush is disabled,
history events are more accurate in scenarios where multiple add/remove
of the same object occurs, as can often be the case in conjunction
with the association proxy.  [ticket:2637]
2012-12-21 17:53:57 -05:00
Mike Bayer cf50ac219e - cleanup on these tests
- add "extend()" to AppenderQuery
2012-12-21 13:29:48 -05:00
Mike Bayer 850e881ce2 More adjustment to this SQLite related issue which was released in
0.7.9, to intercept legacy SQLite quoting characters when reflecting
foreign keys.  In addition to intercepting double quotes, other
quoting characters such as brackets, backticks, and single quotes
are now also intercepted. [ticket:2568]
2012-12-14 10:29:46 -05:00
Mike Bayer ce3333a65c The :meth:.Query.select_from method can now be used with a
:func:`.aliased` construct without it interfering with the entities
being selected.  [ticket:2635]
2012-12-13 18:45:15 -05:00
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 d9d6dcea77 add future 2012-12-11 10:34:33 -05:00
Mike Bayer 70d38af42e Fixed table reflection for Oracle when accessing a synonym that refers
to a DBLINK remote database; while the syntax has been present in the
Oracle dialect for some time, up until now it has never been tested.
The syntax has been tested against a sample database linking to itself,
however there's still some uncertainty as to what should be used for the
"owner" when querying the remote database for table information.
Currently, the value of "username" from user_db_links is used to
match the "owner".  [ticket:2619]
2012-12-09 18:28:08 -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
Mike Bayer 9d817406e2 The Oracle LONG type, while an unbounded text type, does not appear
to use the cx_Oracle.LOB type when result rows are returned,
so the dialect has been repaired to exclude LONG from
having cx_Oracle.LOB filtering applied.  Also in 0.7.10.
[ticket:2620]
2012-12-06 19:30:49 -05:00
Mike Bayer af1a545bdd Repaired the usage of `.prepare()` in conjunction with
cx_Oracle so that a return value of ``False`` will result
in no call to ``connection.commit()``, hence avoiding
"no transaction" errors.   Two-phase transactions have
now been shown to work in a rudimental fashion with
SQLAlchemy and cx_oracle, however are subject to caveats
observed with the driver; check the documentation
for details.  Also in 0.7.10.
[ticket:2611]
2012-12-06 19:10:06 -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
Derek Harland 72b1f475af Add several MSSQL dialect tests for sequence declarations 2012-12-04 14:49:03 +13:00
Mike Bayer 69e967e3c3 merge decimal thing 2012-12-03 19:57:28 -05:00
Mike Bayer d89d71d1da The :class:.MutableComposite type did not allow for the
:meth:`.MutableBase.coerce` method to be used, even though
the code seemed to indicate this intent, so this now works
and a brief example is added.  As a side-effect,
the mechanics of this event handler have been changed so that
new :class:`.MutableComposite` types no longer add per-type
global event handlers.  Also in 0.7.10

[ticket:2624]
2012-12-03 19:49:42 -05:00
Mike Bayer dda33be687 cleanup 2012-12-03 19:01:25 -05: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 b66dad46f3 - refactor of pathing mechanics, to address #2614, #2617
- paths now store Mapper + MapperProperty now instead of string key,
so that the parent mapper for the property is known, supports same-named
properties on multiple subclasses
- the Mapper within the path is now always relevant to the property
to the right of it.  PathRegistry does the translation now, instead
of having all the outside users of PathRegistry worry about it,
to produce a path that is much more consistent.  Paths are now
consistent with mappings in all cases.  Special logic to get at
"with_polymorphic" structures and such added also.
- AliasedClass now has two modes, "use_mapper_path" and regular;
"use_mapper_path" is for all those situations where we put an AliasedClass
in for a plain class internally, and want it to "path" with the
plain mapper.
- The AliasedInsp is now the first class "entity" for an AliasedClass,
and is passed around internally and used as attr._parententity
and such.  it is the AliasedClass analogue for Mapper.
2012-12-01 20:12:23 -05:00
Richard Mitchell 92535b4b57 Allow use of synonyms in primaryjoin / secondaryjoin conditions 2012-11-27 14:03:42 +00:00