Commit Graph

2853 Commits

Author SHA1 Message Date
Mike Bayer 92fb9f91af - New Query methods: query.label(name), query.as_scalar(),
return the query's statement as a scalar subquery
with /without label [ticket:1920];
query.with_entities(*ent), replaces the SELECT list of
the query with new entities.
Roughly equivalent to a generative form of query.values()
which accepts mapped entities as well as column
expressions.
2010-10-23 13:07:56 -04:00
Mike Bayer c5579f77e2 - A mixin can now specify a column that overrides
a column of the same name associated with a superclass.
Thanks to Oystein Haaland.
2010-10-21 16:54:39 -04:00
Mike Bayer ee345b055c - Fixed bug in TypeDecorator whereby the dialect-specific
type was getting pulled in to generate the DDL for a
given type, which didn't always return the correct result.

- TypeDecorator can now have a fully constructed type
specified as its "impl", in addition to a type class.

- TypeDecorator will now place itself as the resulting
type for a binary expression where the type coercion
rules would normally return its impl type - previously,
a copy of the impl type would be returned which would
have the TypeDecorator embedded into it as the "dialect"
impl, this was probably an unintentional way of achieving
the desired effect.

- TypeDecorator.load_dialect_impl() returns "self.impl" by
default, i.e. not the dialect implementation type of
"self.impl".   This to support compilation correctly.
Behavior can be user-overridden in exactly the same way
as before to the same effect.
2010-10-21 16:42:32 -04:00
Mike Bayer f3c9c87a24 - Fixed mysql bug involving reflection of CURRENT_TIMESTAMP
default used with ON UPDATE clause, thanks to
Taavi Burns [ticket:1940]
2010-10-20 17:44:35 -04:00
Mike Bayer 60197fb0f4 - Fixed bug which prevented "domain" built from a
custom type such as "enum" from being reflected.
[ticket:1933]
2010-10-20 17:28:08 -04:00
Mike Bayer 42ac34a701 - Added "as_tuple" flag to pg ARRAY type, returns results
as tuples instead of lists to allow hashing.
2010-10-20 16:17:17 -04:00
Mike Bayer db318240d1 - Fixed bug where aliasing of tables with "schema" would
fail to compile properly.  [ticket:1943]
2010-10-20 16:15:54 -04:00
Mike Bayer 976df5bf96 - the NoseSQLAlchemyPlugin has been moved to a
new package "sqlalchemy_nose" which installs
along with "sqlalchemy".  This so that the "nosetests"
script works as always but also allows the
--with-coverage option to turn on coverage before
SQLAlchemy modules are imported, allowing coverage
to work correctly.
- added some new ignores
2010-10-17 15:23:14 -04:00
Mike Bayer aa20e20b88 - forgot to add the immediate loader tests 2010-10-17 15:10:08 -04:00
Mike Bayer a714db53b3 - Fixed MSSQL reflection bug which did not properly handle
reflection of unknown types.  [ticket:1946]
2010-10-16 12:15:40 -04:00
Mike Bayer 35508a30d7 - engine_from_config() now accepts 'debug' for
'echo', 'echo_pool', 'force' for 'convert_unicode',
boolean values for 'use_native_unicode'.
[ticket:1899]
2010-10-15 11:43:59 -04:00
Mike Bayer b47983f8ec - Fixed labeling bug in Query whereby the NamedTuple
would mis-apply labels if any of the column
expressions were un-labeled.
2010-10-14 12:04:51 -04:00
Chris Withers a376f3e2da warn when two classes with the same name end up in the declarative registry 2010-10-06 12:04:25 +01:00
Mike Bayer ee9102622c - default compilation of a type will check if the type class's module is
inside of sqlalchemy.dialects, in which case that dialect's default
will be used instead of DefaultDialect.
2010-10-03 13:11:41 -04:00
Mike Bayer 15442ed1f4 - added "views=True" option to metadata.reflect(),
will add the list of available views to those
being reflected.  [ticket:1936]
2010-10-02 18:05:19 -04:00
Mike Bayer 19d5287d83 - this test began working for oracle as of r14af1f73fbbd. Additionally,
the operation wasn't actually "working" on sqlite, mysql prior to that
rev, but no assertions checked. added assertions for those.
2010-10-02 01:30:17 -04:00
Mike Bayer 761b4f29e2 - *Major* cleanup / modernization of the Informix
dialect for 0.6, courtesy Florian Apolloner.
[ticket:1906]
2010-10-01 21:26:05 -04:00
Mike Bayer 4557fd5a9a - Fixed bug in query.update() where 'evaluate' or 'fetch'
expiration would fail if the column expression key was
a class attribute with a different keyname as the
actual column name.  [ticket:1935]
2010-10-01 20:55:42 -04:00
Mike Bayer 83a87b3f54 - add additional logic that duplicates mapper's prop.copy(); prop.columns.append(col)
logic when columns are present in a joined subclass with an attribute name different
than the column name itself [ticket:1931]
- add coverage to verify that we need to check (obj.name or name) when
deciding if a Column from a mixin should be added to the mapped table
2010-10-01 20:29:04 -04:00
Mike Bayer 755aca7f5f - reworked the internals of mapper.cascade_iterator() to
cut down method calls by about 9% in some circumstances.
[ticket:1932]
2010-10-01 14:23:01 -04:00
Mike Bayer e9e221977b - CircularDependencyError now has .cycles and .edges
members, which are the set of elements involved in
one or more cycles, and the set of edges as 2-tuples.
[ticket:1890]
2010-09-29 02:11:38 -04:00
Mike Bayer ec3e6c7dc2 - Fixed bug whereby columns on a mixin wouldn't propagate
correctly to a single-table inheritance scheme where
the attribute name is different than that of the column.
[ticket:1930].   Note [ticket:1931] which is the same
issue for joined inh, not yet resolved.
2010-09-28 12:43:36 -04:00
Mike Bayer abc8e45b2f @mapperproperty -> @declared_attr 2010-09-27 10:01:48 -04:00
Mike Bayer 1ff666ffdf - @classproperty 's official name/location for usage
with declarative is sqlalchemy.ext.declarative.mapperproperty.
Same thing, but moving there since it is more of a
"marker" that's specific to declararative,
not just an attribute technique.  [ticket:1915]
2010-09-25 19:25:31 -04:00
Mike Bayer a4a09a687a - Fixed recursion overflow which could occur when operating
with two expressions both of type "NullType", but
not the singleton NULLTYPE instance. [ticket:1907]
2010-09-25 18:38:01 -04:00
Mike Bayer eae4de02a9 - in depth docs about some merge() tips
- docs about backref cascade
- Another new flag on relationship(), cascade_backrefs,
disables the "save-update" cascade when the event was
initiated on the "reverse" side of a bidirectional
relationship.   This is a cleaner behavior so that
many-to-ones can be set on a transient object without
it getting sucked into the child object's session,
while still allowing the forward collection to
cascade.   We *might* default this to False in 0.7.
2010-09-22 14:22:16 -04:00
Mike Bayer 7b8b23b427 - Query.select_from() has been beefed up to help
ensure that a subsequent call to query.join()
will use the select_from() entity, assuming it's
a mapped entity and not a plain selectable,
as the default "left" side, not the first entity
in the Query object's list of entities.
2010-09-21 18:09:29 -04:00
Mike Bayer 8ec3e077e5 use default dialect for compile tests 2010-09-21 11:12:33 -04:00
Mike Bayer c9125a9efd - Patched a case where query.join() would adapt the
right side to the right side of the left's join
inappropriately [ticket:1925]
2010-09-21 10:11:10 -04:00
Mike Bayer 634d547425 - scoped_session emits a warning when configure() is
called if a Session is already present (checks only the
current thread) [ticket:1924]
2010-09-21 09:33:30 -04:00
Mike Bayer 4fbd16e045 - @classproperty (soon/now @mapperproperty) takes effect for
__mapper_args__, __table_args__, __tablename__ on
a base class that is not a mixin, as well as mixins.
[ticket:1922]
2010-09-20 12:00:14 -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 c9d7e38780 - add pk instructions for oracle 2010-09-18 12:38:27 -04:00
Mike Bayer 611fb77186 - use "key in dict" rather than KeyError if the usual case
is that the key is not present.
- don't need to uniquify Index schemes, just don't copy Indexes
that were known to be generated from the index=True flag
- user facing changes go in CHANGES
- Table.c allows string lookup
2010-09-18 11:40:25 -04:00
Chris Withers f08ea3c113 d.uh 2010-09-17 12:26:49 +01:00
Chris Withers 065eb91c4d merge 2010-09-16 21:11:32 +01:00
Chris Withers 4bcb4c98f9 add warning about dodgy use of tometadata 2010-09-16 21:10:17 +01:00
Chris Withers 27cf184b50 tometadata now copies indexes as well 2010-09-16 20:58:15 +01:00
Chris Withers fd6c85cf7f make sure kwargs are copied by tometadata 2010-09-16 20:03:18 +01:00
Mike Bayer 90d4cdbac8 - Fixed a regression in 0.6.4 whereby the change that
allowed cursor errors to be raised consistently broke
the result.lastrowid accessor.   Test coverage has
been added for result.lastrowid.   Note that lastrowid
is only supported by Pysqlite and some MySQL drivers,
so isn't super-useful in the general case.
2010-09-16 11:29:01 -04:00
Mike Bayer 52735e75c5 - fix test_single test to use default dialect
- The exception raised by Session when it is used
subsequent to a subtransaction rollback (which is what
happens when a flush fails in autocommit=False mode) has
now been reworded (this is the "inactive due to a
rollback in a subtransaction" message). In particular,
if the rollback was due to an exception during flush(),
the message states this is the case, and reiterates the
string form of the original exception that occurred
during flush. If the session is closed due to explicit
usage of subtransactions (not very common), the message
just states this is the case.

- The exception raised by Mapper when repeated requests to
its initialization are made after initialization already
failed no longer assumes the "hasattr" case, since
there's other scenarios in which this message gets
emitted, and the message also does not compound onto
itself multiple times - you get the same message for
each attempt at usage. The misnomer "compiles" is being
traded out for "initialize".
2010-09-15 22:20:01 -04:00
Mike Bayer 6409a06df1 - Fixed a regression in 0.6.5 which occurred if you
passed an empty list to "include_properties" on
mapper() [ticket:1918]
2010-09-15 19:17:14 -04:00
Mike Bayer 03523970d9 - Fixed bug that would prevent "subqueryload" from
working correctly with single table inheritance
    for a relationship from a subclass - the "where
    type in (x, y, z)" only gets placed on the inside,
    instead of repeatedly.

  - When using from_self() with single table inheritance,
    the "where type in (x, y, z)" is placed on the outside
    of the query only, instead of repeatedly.   May make
    some more adjustments to this.
2010-09-13 22:55:54 -04:00
Mike Bayer 2ed6f06329 - adjustments for test success on postgresql, mysql 2010-09-13 02:39:39 -04:00
Mike Bayer f5d2bb60a8 - Fixed recursion bug which could occur when moving
an object from one reference to another, with
backrefs involved, where the initiating parent
was a subclass (with its own mapper) of the
previous parent.
2010-09-13 02:09:38 -04:00
Mike Bayer 18f6a06a51 more docs on this 2010-09-12 19:52:41 -04:00
Mike Bayer 7ddd7fc20d turn this test back to what it was 2010-09-12 19:24:40 -04:00
Mike Bayer fe250af8eb - lazy loads for relationship attributes now use
the current state, not the "committed" state,
of foreign and primary key attributes
when issuing SQL, if a flush is not in process.
Previously, only the database-committed state would
be used.  In particular, this would cause a many-to-one
get()-on-lazyload operation to fail, as autoflush
is not triggered on these loads when the attributes are
determined and the "committed" state may not be
available.  [ticket:1910]

- A new flag on relationship(), load_on_pending, allows
the lazy loader to fire off on pending objects without a
flush taking place, as well as a transient object that's
been manually "attached" to the session. Note that this
flag blocks attribute events from taking place when an
object is loaded, so backrefs aren't available until
after a flush. The flag is only intended for very
specific use cases.
2010-09-12 19:18:08 -04:00
Mike Bayer bad4493842 - Slight improvement to the behavior of "passive_updates=False"
when placed only on the many-to-one side of a
    relationship; documentation has been clarified
    that passive_updates=False should really be on the
    one-to-many side.

  - Placing passive_deletes=True on a many-to-one emits
    a warning, since you probably intended to put it on
    the one-to-many side.
2010-09-12 12:37:43 -04:00