Commit Graph

4276 Commits

Author SHA1 Message Date
Mike Bayer c10104f0a8 - 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]
rel_0_5_2
2009-01-24 17:29:56 +00:00
Mike Bayer febf00ea5d moved the non-expire of unloaded deferred attributes into the attributes package 2009-01-24 15:43:05 +00:00
Mike Bayer a03aed2dca - session.expire() and related methods will not expire() unloaded
deferred attributes.  This prevents them from being needlessly
loaded when the instance is refreshed.
2009-01-24 00:22:49 +00:00
Michael Trier 84a38c81e4 Correction to reflection fix r5718 to handle Binary / other numeric types. 2009-01-23 01:45:20 +00:00
Rick Morrison 0caf971263 mssql: modified table reflection code to use only kwargs when constructing coldefs. 2009-01-23 00:53:32 +00:00
Mike Bayer fc7de2aafd - 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.
2009-01-22 18:28:27 +00:00
Mike Bayer 3954df86cb - 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]
2009-01-22 03:55:48 +00:00
Michael Trier a7459fe1ab Trying one more time to get the decimal handling on mssql right. Closes #1282. 2009-01-22 01:55:06 +00:00
Michael Trier 52e2c2d916 Restored convert_unicode handling on mssql. Fixes #1291. 2009-01-22 01:46:04 +00:00
Mike Bayer 7c56371f81 - 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.
2009-01-20 21:35:57 +00:00
Mike Bayer 9fc05aae02 added some missing internal types for reflection, [ticket:1287] 2009-01-20 04:12:00 +00:00
Mike Bayer c1384f4c83 remove comparison/group by on TEXT columns 2009-01-19 22:28:48 +00:00
Mike Bayer 072039945b - 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.
2009-01-18 17:08:28 +00:00
Mike Bayer 86fcffc854 dont need pre-0.5 note rel_0_5_1 2009-01-17 21:43:19 +00:00
Michael Trier 27c4e7aade Corrected handling of large decimal values on mssql. Added more robust tests.
- Removed string manipulation on floats. Float types are now passed through
  to mssql as is.
- Fixes #1280
2009-01-17 20:57:18 +00:00
Mike Bayer f5eca3933e more session updates 2009-01-17 20:06:54 +00:00
Mike Bayer 2a3135744a docstring fixup 2009-01-17 19:30:32 +00:00
Mike Bayer 2ab5b4f30c fix errant foreign key 2009-01-17 19:28:46 +00:00
Mike Bayer e1cdfc9400 fixed more save/clear calls 2009-01-17 19:07:19 +00:00
Mike Bayer b996bcff52 - 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.
2009-01-17 18:19:29 +00:00
Mike Bayer 2ac2770155 explicit rollback to get the connection back to the pool 2009-01-17 17:04:51 +00:00
Mike Bayer 345eaeed74 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. 2009-01-17 06:27:02 +00:00
Mike Bayer b58d6fe9d9 - misc savepoint test
- don't need dialect_impl() for Text
2009-01-16 20:16:31 +00:00
Mike Bayer 79a7f1723a - 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]
2009-01-15 18:08:48 +00:00
Mike Bayer 454f1d7f58 - 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.
2009-01-15 17:08:56 +00:00
Mike Bayer 37b7e458c2 - 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]
2009-01-14 20:48:01 +00:00
Mike Bayer 76a7818013 - 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.
2009-01-14 19:55:20 +00:00
Lele Gaifax 4fad095858 Fix a hyperref 2009-01-14 17:02:17 +00:00
Mike Bayer 49f6342e37 prefer this methods 2009-01-13 15:56:51 +00:00
Mike Bayer 3e3f309cf9 - It's an error to add new Column objects to a declarative class
that specified an existing table using __table__.
2009-01-13 15:45:59 +00:00
Mike Bayer b99bdc7cee - Column with no name (as in declarative) won't raise a
NoneType error when it's string output is requsted
(such as in a stack trace).
2009-01-13 15:38:38 +00:00
Mike Bayer b23f8c0f2e - 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.
2009-01-13 06:11:17 +00:00
Jason Kirtland 313762e86f - Tightened up **kw on ColumnProperty and its front-end functions. 2009-01-13 02:43:52 +00:00
Mike Bayer 4ae6690bb9 happy new year 2009-01-12 21:19:11 +00:00
Mike Bayer 32add82d01 - 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.

- docs/tests
2009-01-12 20:36:06 +00:00
Mike Bayer dc0bbdd92a oh, its UNION ordering that's changing 2009-01-12 16:50:19 +00:00
Mike Bayer a052a44f76 more comparator tweaks 2009-01-12 16:28:01 +00:00
Mike Bayer 68c247358b Ensure RowTuple names are correct by adding "key" to QueryableAttribute. 2009-01-12 15:58:09 +00:00
Mike Bayer fd3b037e52 suspect the InstrumentedSet/set comparison is failing for some reason 2009-01-12 04:04:33 +00:00
Mike Bayer ab9bf61445 *more* sqlite appeasement 2009-01-12 00:12:10 +00:00
Mike Bayer 91001b84c6 mysql/pg sensitive fixes 2009-01-12 00:06:47 +00:00
Mike Bayer 16c710a227 don't INSERT a blank row if no rows passed. (breaks all the tests for SQLite on the buildbot....) 2009-01-11 23:55:35 +00:00
Mike Bayer fc46b9eb5b 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.
2009-01-11 23:37:19 +00:00
Mike Bayer f2c302d03a added an order by 2009-01-11 23:34:36 +00:00
Mike Bayer 209e888e1b - 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.
2009-01-11 22:41:20 +00:00
Michael Trier db33ad9dec Corrected SAVEPOINT support on the adodbapi dialect by changing the handling
of savepoint_release, which is unsupported on mssql.

The way it was being discarded previously resulted in an empty execute being
called on the dialect; adodbapi didn't like that much.
2009-01-11 19:15:37 +00:00
Michael Trier 9a3b662ec1 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.
2009-01-11 19:15:30 +00:00
Mike Bayer 7b3b9f559a - 0.5.1 bump
- modernized mapper()/no table exception
- added __tablename__ exception to declarative since ppl keep complaining
2009-01-11 16:45:45 +00:00
Mike Bayer 4316ecb358 clarified docs on foreign key cascades, mapper extension methods during delete() and update() methods 2009-01-10 01:30:56 +00:00
Mike Bayer e9f787f9fe query.delete(False) is not so bad 2009-01-08 15:33:34 +00:00