Commit Graph

142 Commits

Author SHA1 Message Date
Mike Bayer d28ba32271 - The "entity_name" feature of SQLAlchemy mappers
has been removed.  For rationale, see
http://groups.google.com/group/sqlalchemy/browse_thread/thread/9e23a0641a88b96d?hl=en
2008-08-02 22:21:42 +00:00
Mike Bayer 419753f59b - An inheriting class can now override an attribute
inherited from the base class with a plain descriptor,
or exclude an inherited attribute via the
include_properties/exclude_properties collections.
2008-07-20 18:23:44 +00:00
Jason Kirtland 8fa48edbf9 - Removed 2.3 set emulations/enhancements.
(sets.Set-based collections & DB-API returns still work.)
2008-07-15 19:23:52 +00:00
Mike Bayer 44aa875212 - The "allow_column_override" flag from mapper() has
been removed.  This flag is virtually always misunderstood.
Its specific functionality is available via the
include_properties/exclude_properties mapper arguments.
2008-07-14 20:04:35 +00:00
Gaëtan de Menten d0c243711b session.Query().iterate_instances() has been renamed to just instances(). The old instances() method returning a list instead of an iterator no longer
exists. If you were relying on that behavior, you should use `list(your_query.instances())`.
2008-06-25 15:55:49 +00:00
Mike Bayer c5e2d673a9 - implemented [ticket:887], refresh readonly props upon save
- moved up "eager_defaults" active refresh step (this is an option used by just one user pretty much)
to be per-instance instead of per-table
- fixed table defs from previous deferred attributes enhancement
- CompositeColumnLoader equality comparison fixed for a/b == None; I suspect the composite capability in SA
needs a lot more work than this
2008-06-21 17:23:14 +00:00
Mike Bayer 060c3ce33c - In addition to expired attributes, deferred attributes
also load if their data is present in the result set
[ticket:870]
2008-06-21 16:08:04 +00:00
Mike Bayer 3cd10102e4 - Query.UpdateDeleteTest.test_delete_fallback fails on mysql due to subquery in DELETE; not sure how to do this exact operation in MySQL
- added query_cls keyword argument to sessionmaker(); allows user-defined Query subclasses to be generated by query().
- added @attributes.on_reconstitute decorator, MapperExtension.on_reconstitute, both receieve 'on_load' attribute event allowing
non-__init__ dependent instance initialization routines.
- push memusage to the top to avoid pointless heisenbugs
- renamed '_foostate'/'_fooclass_manager' to '_sa_instance_state'/'_sa_class_manager'
- removed legacy instance ORM state accessors
- query._get() will use _remove_newly_deleted instead of expunge() on ObjectDeleted, so that transaction rollback
restores the previous state
- removed MapperExtension.get(); replaced by a user-defined Query subclass
- removed needless **kwargs from query.get()
- removed Session.get(cls, id); this is redundant against Session.query(cls).get(id)
- removed Query.load() and Session.load(); the use case for this method has never been clear, and the same functionality is available in more explicit ways
2008-06-09 01:24:08 +00:00
Mike Bayer a52a8dd876 fixes for PG, Mysql 2008-05-14 18:28:39 +00:00
Mike Bayer 1b6306c69e - fixed propagation of operate() for aliased relation descriptors
- ColumnEntity gets a selectable
2008-05-13 19:52:15 +00:00
Jason Kirtland b97c8f2d60 - Reworked test/orm/mapper
- Exposed some uncovered (and broken) functionality
- Fixed [ticket:1038]
2008-05-13 16:39:47 +00:00
Lele Gaifax 973bc8831c Added explicit sequences on a few primary keys and minor fixes wrt Firebird 2008-05-12 09:33:16 +00:00
Mike Bayer d3621ae961 - fixed a fairly critical bug in clause adaption/corresponding column in conjunction with annotations
- implicit order by is removed, modified many tests to explicitly set ordering, probably many more to go
once it hits the buildbot.
2008-05-09 23:58:30 +00:00
Jason Kirtland e41c0f4107 Test suite modernization in progress. Big changes:
- @unsupported now only accepts a single target and demands a reason
   for not running the test.
 - @exclude also demands an exclusion reason
 - Greatly expanded @testing.requires.<feature>, eliminating many
   decorators in the suite and signficantly easing integration of
   multi-driver support.
 - New ORM test base class, and a featureful base for mapped tests
 - Usage of 'global' for shared setup going away, * imports as well
2008-05-09 20:26:09 +00:00
Mike Bayer 4a6afd469f r4695 merged to trunk; trunk now becomes 0.5.
0.4 development continues at /sqlalchemy/branches/rel_0_4
2008-05-09 16:34:10 +00:00
Mike Bayer 99f02b59af - fixed reentrant mapper compile hang when
a declared attribute is used within ForeignKey,
ie. ForeignKey(MyOtherClass.someattribute)
2008-05-02 18:23:16 +00:00
Mike Bayer b089e8615b - refined mapper._save_obj() which was unnecessarily calling
__ne__() on scalar values during flush [ticket:1015]
2008-04-26 16:13:49 +00:00
Mike Bayer 4cf26a9e1b - restored usage of append_result() extension method for primary
query rows, when the extension is present and only a single-
entity result is being returned.
2008-04-18 14:49:21 +00:00
Mike Bayer 5080a17409 - removed ancient assertion that mapped selectables require
"alias names" - the mapper creates its own alias now if
none is present.  Though in this case you need to use
the class, not the mapped selectable, as the source of
column attributes - so a warning is still issued.
2008-04-07 19:49:41 +00:00
Mike Bayer c4955c05a3 - merged with_polymorphic branch, which was merged with query_columns branch
- removes everything to do with select_table, which remains as a keyword argument synonymous with
with_polymorphic=('*', select_table).
- all "polymorphic" selectables find their way to Query by way of _set_select_from() now, so that
all joins/aliasing/eager loads/etc. is handled consistently.  Mapper has methods for producing
polymorphic selectables so that Query and eagerloaders alike can get to them.
- row aliasing simplified, so that they don't need to nest.  they only need the source selectable
and adapt to whatever incoming columns they get.
- Query is more egalitarian about mappers/columns now.  Still has a strong sense of "entity zero",
but also introduces new unpublished/experimental _values() method which sets up a columns-only query.
- Query.order_by() and Query.group_by() take *args now (also still take a list, will likely deprecate
in 0.5).  May want to do this for select() as well.
- the existing "check for False discriminiator" "fix" was not working completely, added coverage
- orphan detection was broken when the target object was a subclass of the mapper with the orphaned
relation, fixed that too.
2008-03-29 00:00:49 +00:00
Mike Bayer dde6466660 - already-compiled mappers will still trigger compiles of
other uncompiled mappers when used [ticket:995]
2008-03-23 16:36:47 +00:00
Jason Kirtland c37ed5cbb3 - Added comparable_property(), adds query Comparator behavior to regular, unmanaged Python properties
- Some aspects of MapperProperty initialization are streteched pretty thin now
  and need a refactor; will proceed with these on the user_defined_state branch
2008-03-17 22:06:49 +00:00
Mike Bayer d8e258410e - adjusted generative.py test for revised error message
- mapper with non_primary asserts primary mapper already created
- added any()/instance compare test to query
2008-03-06 16:53:40 +00:00
Jason Kirtland 4f6d0ff71e - Synonyms riding on top of existing descriptors are now full proxies
to those descriptors.
2008-03-06 14:12:22 +00:00
Mike Bayer c0b5a0446b - updated the naming scheme of the base test classes in test/testlib/testing.py;
tests extend from either TestBase or ORMTest, using additional mixins for
special assertion methods as needed
2008-02-11 00:28:39 +00:00
Mike Bayer 9eced72c03 finally, a really straightforward reduce() method which reduces cols
to the minimal set for every test case I can come up with, and
now replaces all the cruft in Mapper._compile_pks() as well as
Join.__init_primary_key().  mappers can now handle aliased selects
and figure out the correct PKs pretty well [ticket:933]
2008-01-15 17:59:27 +00:00
Jason Kirtland 17d3c8764e - testbase is gone, replaced by testenv
- Importing testenv has no side effects- explicit functions provide similar behavior to the old immediate behavior of testbase
- testing.db has the configured db
- Fixed up the perf/* scripts
2008-01-12 22:03:42 +00:00
Jason Kirtland c194962019 - Undeclared SAWarnings are now fatal to tests as well.
- Fixed typo that was killing runs of individual named tests.
2008-01-12 04:52:05 +00:00
Jason Kirtland bf36c648f2 Reworked r4042- undeclared deprecation warnings are now *fatal* to tests. No surprises. 2008-01-10 02:37:39 +00:00
Jason Kirtland 84576e3258 test suite deprecation rampage 2008-01-09 22:54:51 +00:00
Mike Bayer a78914942c - synonyms can now be created against props that don't exist yet,
which are later added via add_property().  This commonly includes
backrefs. (i.e. you can make synonyms for backrefs without
worrying about the order of operations) [ticket:919]
2008-01-05 23:27:02 +00:00
Mike Bayer a582fe3b26 - mapped classes which extend "object" and do not provide an
__init__() method will now raise TypeError if non-empty *args
or **kwargs are present at instance construction time (and are
not consumed by any extensions such as the scoped_session mapper),
consistent with the behavior of normal Python classes [ticket:908]
2007-12-29 19:20:38 +00:00
Mike Bayer dc94cb7b10 - MapperExtension.before_update() and after_update() are now called
symmetrically; previously, an instance that had no modified column
attributes (but had a relation() modification) could be called with
before_update() but not after_update() [ticket:907]
2007-12-29 18:33:27 +00:00
Mike Bayer c114f096bd - reworked all lazy/deferred/expired callables to be
serializable class instances, added pickling tests
- cleaned up "deferred" polymorphic system so that the
mapper handles it entirely
- columns which are missing from a Query's select statement
now get automatically deferred during load.
2007-12-21 06:57:20 +00:00
Mike Bayer 2db36bf59c - inheriting mappers now inherit the MapperExtensions of their parent
mapper directly, so that all methods for a particular MapperExtension
are called for subclasses as well.  As always, any MapperExtension
can return either EXT_CONTINUE to continue extension processing
or EXT_STOP to stop processing.  The order of mapper resolution is:
<extensions declared on the classes mapper> <extensions declared on the
classes' parent mapper> <globally declared extensions>.

Note that if you instantiate the same extension class separately
and then apply it individually for two mappers in the same inheritance
chain, the extension will be applied twice to the inheriting class,
and each method will be called twice.

To apply a mapper extension explicitly to each inheriting class but
have each method called only once per operation, use the same
instance of the extension for both mappers.
[ticket:490]
2007-12-20 02:37:48 +00:00
Mike Bayer 6c4ad36cc9 - simplified _mapper_registry further. its now just a weakkeydict of mapper->True, stores
all mappers including non primaries, and is strictly used for the list of "to compile/dispose".
- all global references are now weak referencing.  if you del a mapped class and any dependent classes,
its mapper and all dependencies fall out of scope.
- attributes.py still had issues which were barely covered by tests.  added way more tests (coverage.py still says 71%, doh)
fixed things, took out unnecessary commit to states.  attribute history is also asserted for ordering.
2007-12-14 23:11:13 +00:00
Mike Bayer 0df750223a - merged instances_yields branch r3908:3934, minus the "yield" part which remains slightly problematic
- cleanup of mapper._instance, query.instances().  mapper identifies objects which are part of the
current load using a app-unique id on the query context.
- attributes refactor; attributes now mostly use copy-on-modify instead of copy-on-load behavior,
simplified get_history(), added a new set of tests
- fixes to OrderedSet such that difference(), intersection() and others can accept an iterator
- OrderedIdentitySet passes in OrderedSet to the IdentitySet superclass for usage in difference/intersection/etc. operations so that these methods actually work with ordering behavior.
- query.order_by() takes into account aliased joins, i.e.  query.join('orders', aliased=True).order_by(Order.id)
- cleanup etc.
2007-12-14 05:53:18 +00:00
Mike Bayer 86f12f93cc - eagerload(), lazyload(), eagerload_all() take an optional
second class-or-mapper argument, which will select the mapper
to apply the option towards.  This can select among other
mappers which were added using add_entity().

- eagerloading will work with mappers added via add_entity().
2007-12-11 19:33:36 +00:00
Mike Bayer 41df778985 - more query tests
- trying to refine some of the adaptation stuff
- query.from_statement() wont allow further generative criterion
- added a warning to columncollection when selectable is formed with
conflicting columns (only in the col export phase)
- some method rearrangement on schema/columncollection....
- property conflicting relation warning doesnt raise for concrete
2007-12-10 04:31:17 +00:00
Mike Bayer 65b204c122 some updates, remove an old test (really crufty old stuff here) 2007-12-08 21:49:03 +00:00
Mike Bayer 56c544edab [ticket:888] continued, synonym add_prop 2007-12-08 19:56:11 +00:00
Mike Bayer 33f62587cd fixed key error when no pks could be located 2007-12-07 15:28:20 +00:00
Mike Bayer 9e4052dc8b - a major behavioral change to collection-based backrefs: they no
longer trigger lazy loads !  "reverse" adds and removes
are queued up and are merged with the collection when it is
actually read from and loaded; but do not trigger a load beforehand.
For users who have noticed this behavior, this should be much more
convenient than using dynamic relations in some cases; for those who
have not, you might notice your apps using a lot fewer queries than
before in some situations. [ticket:871]
2007-12-05 20:43:16 +00:00
Mike Bayer aa71eed4e2 fixed replacement of existing column properties with synonyms, [ticket:888] 2007-12-04 15:53:23 +00:00
Mike Bayer c6d01a56e1 - several ORM attributes have been removed or made private:
mapper.get_attr_by_column(), mapper.set_attr_by_column(),
mapper.pks_by_table, mapper.cascade_callable(),
MapperProperty.cascade_callable(), mapper.canload()
- refinements to mapper PK/table column organization, session cascading,
some naming convention work
2007-12-01 23:00:05 +00:00
Mike Bayer 4ee7070223 new synonym() behavior, including auto-attribute gen, attribute decoration,
and auto-column mapping implemented; [ticket:801]
2007-11-28 21:13:35 +00:00
Mike Bayer 79aa1a6b25 fixed both group-deferred attributes and expired attributes to not
blow away changes made on attributes before the load takes place
2007-11-18 05:16:52 +00:00
Mike Bayer 622a26a655 - session.refresh() and session.expire() now support an additional argument
"attribute_names", a list of individual attribute keynames to be refreshed
or expired, allowing partial reloads of attributes on an already-loaded
instance.
- finally simplified the behavior of deferred attributes, deferred polymorphic
load, session.refresh, session.expire, mapper._postfetch to all use a single
codepath through query._get(), which now supports a list of individual attribute names
to be refreshed.  the *one* exception still remaining is mapper._get_poly_select_loader(),
which may stay that way since its inline with an already processing load operation.
otherwise, query._get() is the single place that all "load this instance's row" operation
proceeds.
- cleanup all over the place
2007-11-18 02:13:56 +00:00
Mike Bayer a03aa84c31 - DeferredColumnLoader checks row for column, if present sends it to
ColumnLoader to create the row processor
- eager loaders ensure deferred foreign key cols are present in the primary list of columns (and secondary...).  because eager loading with LIMIT/OFFSET doesn't re-join to the parent table anymore this is now necessary. [ticket:864]
2007-11-14 16:43:21 +00:00
Jason Kirtland bcb586a93c Migrated maxdb behavioral assumptions from unsupported to fails_on 2007-11-05 22:11:30 +00:00