Mike Bayer [Sun, 1 Feb 2009 18:20:20 +0000 (18:20 +0000)]
- Fixed missing _label attribute on Function object, others
when used in a select() with use_labels (such as when used
in an ORM column_property()). [ticket:1302]
Mike Bayer [Thu, 29 Jan 2009 16:09:14 +0000 (16:09 +0000)]
- The per-dialect cache used by TypeEngine to cache
dialect-specific types is now a WeakKeyDictionary.
This to prevent dialect objects from
being referenced forever for an application that
creates an arbitrarily large number of engines
or dialects. There is a small performance penalty
which will be resolved in 0.6. [ticket:1299]
Mike Bayer [Thu, 29 Jan 2009 06:40:29 +0000 (06:40 +0000)]
- improvements to the "determine direction" logic of
relation() such that the direction of tricky situations
like mapper(A.join(B)) -> relation-> mapper(B) can be
determined.
Mike Bayer [Wed, 28 Jan 2009 01:28:20 +0000 (01:28 +0000)]
- _CalculatedClause is gone
- Function rolls the various standalone execution functionality of CC into itself,
accesses its internal state more directly
- collate just uses _BinaryExpression, don't know why it didn't do this already
- added new _Case construct, compiles directly
- the world is a happier place
Mike Bayer [Tue, 27 Jan 2009 01:05:20 +0000 (01:05 +0000)]
- Query now implements __clause_element__() which produces
its selectable, which means a Query instance can be accepted
in many SQL expressions, including col.in_(query),
union(query1, query2), select([foo]).select_from(query),
etc.
- the __selectable__() interface has been replaced entirely
by __clause_element__().
Mike Bayer [Sat, 24 Jan 2009 17:29:56 +0000 (17:29 +0000)]
- refined and clarified query.__join() for readability
- _ORMJoin() gets a new flag join_to_left to specify if
we really want to alias from the existing left side or not. eager loading
wants this flag off in almost all cases, query.join() usually wants it on.
- query.join()/outerjoin() will now properly join an aliased()
construct to the existing left side, even if query.from_self()
or query.select_from(someselectable) has been called.
[ticket:1293]
Mike Bayer [Sat, 24 Jan 2009 00:22:49 +0000 (00:22 +0000)]
- session.expire() and related methods will not expire() unloaded
deferred attributes. This prevents them from being needlessly
loaded when the instance is refreshed.
Mike Bayer [Thu, 22 Jan 2009 18:28:27 +0000 (18:28 +0000)]
- Fixed an eager loading bug whereby self-referential eager
loading would prevent other eager loads, self referential or not,
from joining to the parent JOIN properly. Thanks to Alex K
for creating a great test case.
Mike Bayer [Thu, 22 Jan 2009 03:55:48 +0000 (03:55 +0000)]
- Adjusted the attribute instrumentation change from 0.5.1 to
fully establish instrumentation for subclasses where the mapper
was created after the superclass had already been fully
instrumented. [ticket:1292]
Mike Bayer [Tue, 20 Jan 2009 21:35:57 +0000 (21:35 +0000)]
- Further refined 0.5.1's warning about delete-orphan cascade
placed on a many-to-many relation. First, the bad news:
the warning will apply to both many-to-many as well as
many-to-one relations. This is necessary since in both
cases, SQLA does not scan the full set of potential parents
when determining "orphan" status - for a persistent object
it only detects an in-python de-association event to establish
the object as an "orphan". Next, the good news: to support
one-to-one via a foreign key or assocation table, or to
support one-to-many via an association table, a new flag
single_parent=True may be set which indicates objects
linked to the relation are only meant to have a single parent.
The relation will raise an error if multiple parent-association
events occur within Python.
- Fixed bug in delete-orphan cascade whereby two one-to-one
relations from two different parent classes to the same target
class would prematurely expunge the instance. This is
an extension of the non-ticketed fix in r4247.
- the order of "sethasparent" flagging in relation to
AttributeExtensions has been refined such that false setparents
are issued before the event, true setparents issued afterwards.
event handlers "know" that a remove event originates
from a non-orphan but need to know if its become an orphan,
and that append events will become non-orphans but need to know
if the event originates from a non-orphan.
Mike Bayer [Sun, 18 Jan 2009 17:08:28 +0000 (17:08 +0000)]
- Further fixes to the "percent signs and spaces in column/table
names" functionality. [ticket:1284]
- Still doesn't work for PG/MySQL, which unfortunately would require
post_process_text() calls all over the place. Perhaps % escaping
can be assembled into IdentifierPreparer.quote() since that's where
identifier names are received.
Mike Bayer [Sat, 17 Jan 2009 18:19:29 +0000 (18:19 +0000)]
- The "clear()", "save()", "update()", "save_or_update()"
Session methods have been deprecated, replaced by
"expunge_all()" and "add()". "expunge_all()" has also
been added to ScopedSession.
Mike Bayer [Sat, 17 Jan 2009 06:27:02 +0000 (06:27 +0000)]
WeakCompositeKey was coded incorrectly and was not weakly referencing anything. However when repaired, the usage within RelationLoader._create_joins() still creates cycles between key elements and the value placed in the dict. In the interests of risk reduction, WCK is now removed and the two caches it was used for are now non-cached. Speed comparisons with one join/eager-heavy web application show no noticeable effect in response time.
Mike Bayer [Thu, 15 Jan 2009 18:08:48 +0000 (18:08 +0000)]
- Using delete-orphan on a many-to-many relation is deprecated.
This produces misleading or erroneous results since SQLA does
not retrieve the full list of "parents" for m2m. To get delete-orphan
behavior with an m2m table, use an explcit association class
so that the individual association row is treated as a parent.
[ticket:1281]
- delete-orphan cascade always requires delete cascade. Specifying
delete-orphan without delete now raises a deprecation warning.
[ticket:1281]
Mike Bayer [Thu, 15 Jan 2009 17:08:56 +0000 (17:08 +0000)]
- Query.from_self() as well as query.subquery() both disable
the rendering of eager joins inside the subquery produced.
The "disable all eager joins" feature is available publically
via a new query.enable_eagerloads() generative. [ticket:1276]
- Added a rudimental series of set operations to Query that
receive Query objects as arguments, including union(),
union_all(), intersect(), except_(), insertsect_all(),
except_all(). See the API documentation for
Query.union() for examples.
- Fixed bug that prevented Query.join() and eagerloads from
attaching to a query that selected from a union or aliased union.
Mike Bayer [Wed, 14 Jan 2009 20:48:01 +0000 (20:48 +0000)]
- use ForeignKey.column as _colspec source in Column._make_proxy(), preventing needless
redundant string arithmetic in memoized ForeignKey.column method
- _pre_existing_column attribute becomes optional, only needed for original Table-bound column, not proxies
- compare two ForeignKeys based on target_fullname, don't assume self._colspec is a string
- Fixed bug when overriding a Column with a ForeignKey
on a reflected table, where derived columns (i.e. the
"virtual" columns of a select, etc.) would inadvertently
call upon schema-level cleanup logic intended only
for the original column. [ticket:1278]
Mike Bayer [Wed, 14 Jan 2009 19:55:20 +0000 (19:55 +0000)]
- Improved the methodology to handling percent signs in column
names from [ticket:1256]. Added more tests. MySQL and
Postgres dialects still do not issue correct CREATE TABLE
statements for identifiers with percent signs in them.
Mike Bayer [Tue, 13 Jan 2009 06:11:17 +0000 (06:11 +0000)]
- Fixed a bug with the unitofwork's "row switch" mechanism,
i.e. the conversion of INSERT/DELETE into an UPDATE, when
combined with joined-table inheritance and an object
which contained no defined values for the child table where
an UPDATE with no SET clause would be rendered.
Mike Bayer [Mon, 12 Jan 2009 20:36:06 +0000 (20:36 +0000)]
- Can now specify Column objects on subclasses which have no
table of their own (i.e. use single table inheritance).
The columns will be appended to the base table, but only
mapped by the subclass.
- For both joined and single inheriting subclasses, the subclass
will only map those columns which are already mapped on the
superclass and those explicit on the subclass. Other
columns that are present on the `Table` will be excluded
from the mapping by default, which can be disabled
by passing a blank `exclude_properties` collection to the
`__mapper_args__`. This is so that single-inheriting
classes which define their own columns are the only classes
to map those columns. The effect is actually a more organized
mapping than you'd normally get with explicit `mapper()`
calls unless you set up the `exclude_properties` arguments
explicitly.
Mike Bayer [Sun, 11 Jan 2009 23:37:19 +0000 (23:37 +0000)]
NotSupportedError is a DBAPI wrapper which takes four args and is expected to originate from the DBAPI layer.
Moved those error throws to CompileError/InvalidRequestError.
Mike Bayer [Sun, 11 Jan 2009 22:41:20 +0000 (22:41 +0000)]
- Concrete inheriting mappers now instrument attributes which are inherited from the superclass, but are not defined for the concrete mapper itself, with an InstrumentedAttribute that issues a descriptive error when accessed. [ticket:1237]
- Added a new `relation()` keyword `back_populates`. This allows configuation of backreferences using explicit relations. [ticket:781] This is required when creating bidirectional relations between a hierarchy of concrete mappers and another class. [ticket:1237]
- Test coverage added for `relation()` objects specified on concrete mappers. [ticket:1237]
- A short documentation example added for bidirectional relations specified on concrete mappers. [ticket:1237]
- Mappers now instrument class attributes upon construction with the final InstrumentedAttribute object which remains persistent. The `_CompileOnAttr`/`__getattribute__()` methodology has been removed. The net effect is that Column-based mapped class attributes can now be used fully at the class level without invoking a mapper compilation operation, greatly simplifying typical usage patterns within declarative. [ticket:1269]
- Index now accepts column-oriented InstrumentedAttributes (i.e. column-based mapped class attributes) as column arguments. [ticket:1214]
- Broke up attributes.register_attribute into two separate functions register_descriptor and register_attribute_impl. The first assembles an InstrumentedAttribute or Proxy descriptor, the second assembles the AttributeImpl inside the InstrumentedAttribute. register_attribute remains for outside compatibility. The argument lists have been simplified.
- Removed class_manager argument from all but MutableScalarAttributeImpl (the branch had removed class_ as well but this has been reverted locally to support the serializer extension).
- Mapper's previous construction of _CompileOnAttr now moves to a new MapperProperty.instrument_class() method which is called on all MapperProperty objects at the moment the mapper receives them. All MapperProperty objects now call attributes.register_descriptor within that method to assemble an InstrumentedAttribute object directly.
- InstrumentedAttribute now receives the "property" attribute from the given PropComparator. The guesswork within the constructor is removed, and allows "property" to serve as a mapper compilation trigger.
- RelationProperty.Comparator now triggers compilation of its parent mapper within a util.memoized_property accessor for the "property" attribute, which is used instead of "prop" (we can probably remove "prop").
- ColumnProperty and similar handle most of their initialization in their __init__ method since they must function fully at the class level before mappers are compiled.
- SynonymProperty and ComparableProperty move their class instrumentation logic to the new instrument_class() method.
- LoaderStrategy objects now add their state to existing InstrumentedAttributes using attributes.register_attribute_impl. Both column and relation-based loaders instrument in the same way now, with a unique InstrumentedAttribute *and* a unique AttributeImpl for each class in the hierarchy. attribute.parententity should now be correct in all cases.
- Removed unitofwork.register_attribute, and simpified the _register_attribute methods into a single function in strategies.py. unitofwork exports the UOWEventHandler extension directly.
- To accomodate the multiple AttributeImpls across a class hierarchy, the sethasparent() method now uses an optional "parent_token" attribute to identify the "parent". AbstractRelationLoader sends the MapperProperty along to serve as this token. If the token isn't present (which is only the case in the attributes unit tests), the AttributeImpl is used instead, which is essentially the same as the old behavior.
- Added new ConcreteInheritedProperty MapperProperty. This is invoked for concrete mappers within _adapt_inherited_property() to accomodate concrete mappers which inherit unhandled attributes from the base class, and basically raises an exception upon access. [ticket:1237]
- attributes.register_attribute and register_descriptor will now re-instrument an attribute unconditionally without checking for a previous attribute. Not sure if this is controversial. It's needed so that ConcreteInheritedProperty instrumentation can be overridden by an incoming legit MapperProperty without any complexity.
- Added new UninstrumentedColumnLoader LoaderStrategy. This is used by the polymorphic_on argument when the given column is not represented within the mapped selectable, as is typical with a concrete scenario which maps to a polymorphic union. It does not configure class instrumentation, keeping polymorphic_on from getting caught up in the new concrete attribute-checking logic.
- RelationProperty now records its "backref" attributes using a set assigned to `_reverse_property` instead of a scalar. The `back_populates` keyword allows any number of properties to be involved in a single bidirectional relation. Changes were needed to RelationProperty.merge(), DependencyProcessor to accomodate for the new multiple nature of this attribute.
- Generalized the methodology used by ManyToManyDP to check for "did the other dependency already handle this direction", building on the `_reverse_property` collection.
- post_update logic within dependency.py moves to use the same methodology as ManyToManyDP so that "did the other dependency do this already" checks are made to be specific to the two dependent instances.
- Caught that RelationProperty.merge() was writing to instance.__dict__ directly (!) - repaired to talk to instance_state.dict.
- Removed needless eager loading example from concrete mapper docs.
- Added test for [ticket:965].
- Added the usual Node class/nodes table to orm/_fixtures.py, but haven't used it for anything yet. We can potentially update test/orm/query.py to use this fixture.
- Other test/documentation cleanup.
Michael Trier [Sun, 11 Jan 2009 19:15:30 +0000 (19:15 +0000)]
Modified the do_begin handling in mssql to use the Cursor not the Connection.
This corrects a problem where we were trying to call execute on the Connection
object instead of against the cursor. This is supported on pyodbc but not in
the DBAPI. Overrode the behavior in pymssql to not do special do_begin
processing on that dialect.
Mike Bayer [Tue, 6 Jan 2009 04:30:11 +0000 (04:30 +0000)]
- query.join() raises an error when the target of the join
doesn't match the property-based attribute - while it's
unlikely anyone is doing this, the SQLAlchemy author was
guilty of this particular loosey-goosey behavior.
Michael Trier [Mon, 5 Jan 2009 22:05:51 +0000 (22:05 +0000)]
mssql date / time refactor.
- Added new MSSmallDateTime, MSDateTime2, MSDateTimeOffset, MSTime types
- Refactored the Date/Time types. The smalldatetime data type no longer
truncates to a date only, and will now be mapped to the MSSmallDateTime
type. Closes #1254.
Mike Bayer [Mon, 5 Jan 2009 19:23:56 +0000 (19:23 +0000)]
- property.of_type() is now recognized on a single-table
inheriting target, when used in the context of
prop.of_type(..).any()/has(), as well as
query.join(prop.of_type(...)).
Mike Bayer [Mon, 5 Jan 2009 15:34:09 +0000 (15:34 +0000)]
- Generalized the IdentityManagedState._instance_dict() callable
to the IdentityMap class so that Weak/StrongInstanceDict both
have the same behavior wrt the state referencing the map
- Fixed bug when using weak_instance_map=False where modified
events would not be intercepted for a flush(). [ticket:1272]
Mike Bayer [Sat, 3 Jan 2009 22:15:38 +0000 (22:15 +0000)]
added teardown_instance() to complement setup_instance().
Based on the instance/class agnostic behavior of ClassManager, this might be the best we can
do regarding [ticket:860]
Mike Bayer [Sat, 3 Jan 2009 20:52:34 +0000 (20:52 +0000)]
- query.order_by() accepts None which will remove any pending
order_by state from the query, as well as cancel out any
mapper/relation configured ordering. This is primarily useful
for overriding the ordering specified on a dynamic_loader().
[ticket:1079]
Michael Trier [Sat, 3 Jan 2009 03:59:49 +0000 (03:59 +0000)]
Excluded another failing test from the mssql dialect.
MSSQL doesn't allow ON UPDATE for self-referential keys. The tree of cascading
referential actions must only have one path to a particular table on the
cascading referential actions tree.
Mike Bayer [Sat, 3 Jan 2009 02:42:34 +0000 (02:42 +0000)]
- Fixed some deep "column correspondence" issues which could
impact a Query made against a selectable containing
multiple versions of the same table, as well as
unions and similar which contained the same table columns
in different column positions at different levels.
[ticket:1268]