Commit Graph

413 Commits

Author SHA1 Message Date
Mike Bayer c848624f9d - SqlSoup overhaul
- Added "map_to()" method to SqlSoup, which is a "master"
method which accepts explicit arguments for each aspect of
the selectable and mapping, including a base class per
mapping. [ticket:1975]

- Mapped selectables used with the map(), with_labels(),
join() methods no longer put the given argument into the
internal "cache" dictionary.  Particularly since the
join() and select() objects are created in the method
itself this was pretty much a pure memory leaking behavior.
2010-11-24 12:21:59 -05:00
Mike Bayer e187cc538d - merge metadata/schema/declarative branch, [ticket:1893] 2010-11-20 15:30:12 -05:00
Mike Bayer 9ed764650c - merge reverse inheriting col order, [ticket:1892] 2010-11-20 13:49:17 -05:00
Mike Bayer 007344a40a - the ordering of columns in a multi-column property now is in
reverse order of which they were added to the property. A
  typical effect of this is that the ".id" attribute on a
  joined-inheritance subclass, where both parent/child tables
  name the PK column ".id", will reference the ".id" column of
  the child table, not the parent, thus allowing join conditions
  and such to be constructed more intuitively. This is a
  behavior change for some joined-table inheritance queries.
  [ticket:1892]
- it's now an error condition to map to a join where multiple
  same-named columns from each table combine themselves
  implicitly. An explicit mention in the "properties" dictionary
  should be specified, using a list of columns, or
  column_property(*cols) with declarative. [ticket:1892]
2010-11-20 13:44:03 -05:00
Mike Bayer c5442b3adb - merge hybrid attributes branch, [ticket:1903] 2010-11-20 12:55:46 -05:00
Mike Bayer 61c76f92df - repair remaining tests 2010-11-20 11:35:16 -05:00
Mike Bayer 6dfbe839aa merge tip 2010-11-18 19:01:17 -05:00
Mike Bayer fd4f39648a merge tip 2010-11-18 18:57:33 -05:00
Mike Bayer 08e5c35c2d merge tip 2010-11-18 18:53:29 -05:00
Mike Bayer 6dbf2c3314 merge tip 2010-11-18 18:50:24 -05:00
Mike Bayer d3ca415649 - An error is raised if __table_args__ is not in tuple
or dict format, and is not None.  [ticket:1972]
2010-11-17 10:55:10 -05:00
Mike Bayer e1402efb19 - move sqlalchemy.test to test.lib 2010-11-15 19:37:50 -05:00
Mike Bayer 166a8a0b73 [ticket:1893] implementation 2010-11-15 19:05:48 -05:00
Mike Bayer 20ad3b16e8 [ticket:1966] implementation 2010-11-15 19:05:23 -05:00
Mike Bayer f252af2b21 merge tip 2010-11-14 17:54:47 -05: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
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 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 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 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 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 904466a293 merge latest tip 2010-09-03 18:01:59 -04:00
Mike Bayer 092fbb40eb - The include_properties and exclude_properties arguments
to mapper() now accept Column objects as members in
addition to strings.  This so that same-named Column
objects, such as those within a join(), can be
disambiguated.

- A warning is now emitted if a mapper is created against a
join or other single selectable that includes multiple
columns with the same name in its .c. collection,
and those columns aren't explictly named as part of
the same or separate attributes (or excluded).
In 0.7 this warning will be an exception.   Note that
this warning is not emitted when the combination occurs
as a result of inheritance, so that attributes
still allow being overridden naturally.
[ticket:1896].  In 0.7 this will be improved further.

- The primary_key argument to mapper() can now specify
a series of columns that are only a subset of
the calculated "primary key" columns of the mapped
selectable, without an error being raised.  This
helps for situations where a selectable's effective
primary key is simpler than the number of columns
in the selectable that are actually marked as
"primary_key", such as a join against two
tables on their primary key columns [ticket:1896].
2010-08-30 17:41:47 -04:00
Mike Bayer 9aa5d574fe - a few fixes
- what will be the test suite
2010-08-08 15:23:37 -04:00
Mike Bayer 31a28392d1 - Fixed bug where "Can't add additional column" message
would display the wrong name.
2010-08-02 19:18:24 -04:00
Mike Bayer e616c2fb3c - if @classproperty is used with a regular class-bound
mapper property attribute, it will be called to get the
actual attribute value during initialization. Currently,
there's no advantage to using @classproperty on a column
or relationship attribute of a declarative class that
isn't a mixin - evaluation is at the same time as if
@classproperty weren't used. But here we at least allow
it to function as expected.
- docs for column_property() with declarative
- mixin docs in declarative made more clear - mixins
are optional - each subsection starts with, "in *declarative mixins*",
to reduce confusion
2010-08-02 15:29:31 -04:00
Mike Bayer f2b43da1a8 tidy test/base, test/ex, test/ext 2010-07-11 13:41:38 -04:00
Mike Bayer d6614c63b2 transfer docstrings from @classproperty to props 2010-07-04 12:06:19 -04:00
Mike Bayer 55ae7d7842 - Added support for @classproperty to provide
any kind of schema/mapping construct from a
declarative mixin, including columns with foreign
keys, relationships, column_property, deferred.
This solves all such issues on declarative mixins.
An error is raised if any MapperProperty subclass
is specified on a mixin without using @classproperty.
[ticket:1751] [ticket:1796] [ticket:1805]

- un-anglicized the declarative docs
2010-07-03 14:53:37 -04:00
Mike Bayer 0025a6a50e - The 'default' compiler is automatically copied over
when overriding the compilation of a built in
clause construct, so no KeyError is raised if the
user-defined compiler is specific to certain
backends and compilation for a different backend
is invoked. [ticket:1838]
2010-07-02 14:07:42 -04:00
Chris Withers 3c56bfde95 keep ordering of columns with mixins constant 2010-07-02 14:57:19 +01:00
Mike Bayer 29eb88eefb - Fixed bug that would prevent overridden clause
compilation from working for "annotated" expression
elements, which are often generated by the ORM.
2010-06-26 17:20:17 -04:00
Mike Bayer 6de7db07ce - a mixin class can now define a column that matches
one which is present on a __table__ defined on a
subclass.  It cannot, however, define one that is
not present in the __table__, and the error message
here now works.  [ticket:1821]
2010-06-19 13:25:37 -04:00
Mike Bayer a8e53a4f31 - Column.copy() takes along the "unique" attribute
among others, fixes [ticket:1829] regarding declarative
mixins
2010-06-15 17:56:17 -04:00
Mike Bayer 0934e217f8 - the SqlSoup constructor accepts a base argument which specifies
the base class to use for mapped classes, the default being
`object`.  [ticket:1783]
2010-05-08 15:08:48 -04:00
Chris Withers 5114807408 docs for new mixin class control abilities 2010-04-13 16:46:07 +01:00
Chris Withers 80897e74cb add another edge case example 2010-04-13 16:28:32 +01:00
Chris Withers aaa0ba0525 helper method for spotting inherited tables 2010-04-13 11:29:39 +01:00
Chris Withers 7339ee67e1 correct ordering 2010-04-13 01:55:32 +01:00
Chris Withers 67cdce0549 beef up test cases to reveal that I'm not as close as I'd thought :-( 2010-04-13 00:56:15 +01:00
Chris Withers 5762c9c12b correct this test case 2010-04-12 23:22:44 +01:00
Chris Withers 6fc4cba130 improve test case correctness 2010-04-09 19:02:32 +01:00
Chris Withers 5fd49b42ea learn to spell 2010-04-09 17:35:16 +01:00
Chris Withers 03ac691bd2 more testcases for propogation with mixins in declarative 2010-04-09 17:32:05 +01:00
Chris Withers 736682a589 ugh, didn't mean to commit that :-S 2010-04-07 18:14:06 +01:00
Chris Withers a5c9696a7c Add instructions to install nose adn NB that it won't happen by magic 2010-04-07 18:09:21 +01:00
Mike Bayer e9cdc0b86e test another version of the mixin here 2010-04-06 12:32:51 -04:00
Mike Bayer 87b454be9a - Further reworked the "mixin" logic in declarative to
additionally allow __mapper_args__ as a @classproperty
on a mixin, such as to dynamically assign polymorphic_identity.
2010-04-06 12:27:01 -04:00