On Mon, 2006-12-11 at 23:02 +0300, Oleg Broytmann wrote:
> On Mon, Dec 11, 2006 at 02:57:03PM -0500, David Turner wrote:
> > This is not quite true, if I understand correctly. First, sqlobject
> > creates the base row, then (if necessary) it calls methods to get
> > default values for the derived class, then it creates the derived row.
> > So the user's program does have control during those methods (and this
> > is where I ran into the problem).
> Shouldn't it be considered a bug in the user program if it access the DB
> during row creation?
I don't see why it should be.
The actual use case I had in mind was that a table's elements acted as a
sortable list, so the table has a column sort_index, which is unique. I
want to set the sort_index on new elements to be one plus the max of the
sort_index on the old elements -- that is, new elements should appear at
the end of the list.
I could, of course, calculate the sort_index somewhere else, rather than
using SQLObject's default feature. But then there's the risk of race
conditions, which I expect the ORM to insulate me from.
Generally, I think the ORM should always present a consistent view of
the data to user programs at all times.