From a9afbd89437c680d1a270c28ce8beca58c34e49e Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 26 Feb 2006 19:15:43 +0000 Subject: [PATCH] register_deleted/register_dirty perform pre-check before doing the "validate" operation to cut down on method overhaed --- CHANGES | 4 ++++ lib/sqlalchemy/mapping/objectstore.py | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 52b2846fff..c85ad7820f 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,10 @@ such as in an inheritance relationship, this is fixed. - overhaul to sql/schema packages so that the sql package can run all on its own, producing selects, inserts, etc. without any engine dependencies. Table/Column are the "physical" subclasses of TableClause/ColumnClause. +- fixes to mapper inheritance, involving properties that relate to the same table +involved in the mapper inheritance scheme +- made objectstore "check for out-of-identitymap" more aggressive, will perform the +check when object attributes are modified or the object is deleted 0.1.2 - fixed a recursive call in schema that was somehow running 994 times then returning normally. broke nothing, slowed down everything. thanks to jpellerin for finding this. diff --git a/lib/sqlalchemy/mapping/objectstore.py b/lib/sqlalchemy/mapping/objectstore.py index 92052bd286..aed221be83 100644 --- a/lib/sqlalchemy/mapping/objectstore.py +++ b/lib/sqlalchemy/mapping/objectstore.py @@ -372,8 +372,9 @@ class UnitOfWork(object): self.new.append(obj) def register_dirty(self, obj): - self._validate_obj(obj) - self.dirty.append(obj) + if not self.dirty.contains(obj): + self._validate_obj(obj) + self.dirty.append(obj) def is_dirty(self, obj): if not self.dirty.contains(obj): @@ -382,12 +383,13 @@ class UnitOfWork(object): return True def register_deleted(self, obj): - self._validate_obj(obj) - self.deleted.append(obj) - mapper = object_mapper(obj) - # TODO: should the cascading delete dependency thing - # happen wtihin PropertyLoader.process_dependencies ? - mapper.register_deleted(obj, self) + if not self.deleted.contains(obj): + self._validate_obj(obj) + self.deleted.append(obj) + mapper = object_mapper(obj) + # TODO: should the cascading delete dependency thing + # happen wtihin PropertyLoader.process_dependencies ? + mapper.register_deleted(obj, self) def unregister_deleted(self, obj): try: -- 2.47.2