On 19 November 2010 11:11, Chris Mayan <[email protected]> wrote:

> Hello,
>
> What I really wanted I now believe has to be done and provided by the
> native DB or implemented via some plumbing connection between rails and the
> db (which I don't think is provided by any vendors…).
>
> Something akin to a subscriber/publisher design pattern, where I can
> subscribe to the DB from rails and say, "Notify me when anything to do with
> this row" has changed..
>

While I don't believe it is a good idea to do, but definitely MSSQL2005>=
provides that. They even invalidated application cache if something has
changed on the DB.


> Like I don't understand why this is not a standard in any ORM
> implementation…
>
It seems you are looking into MS Access days when all the connections were
stateful. And that was a problem too :)


> To me the idea of encapsulating a complete DB row as an object is
> meaningless if the underlying data can change at any time, and I can't tell
> until I try to save it. Like once I create that ActiveRecord object.. it's
> stale. So all calculations that I perform on those attributes of that object
> could well and truly be meaningless.
>

I do not think that it is very accurate. In *most* cases the data is
up-to-date because you connect to database for a short period of time
(UnitOfWork) do the work and disconnect. That is the problem when you hold
an object for long period of time (which you never do in a web app).


I would rather have it so that I am midway calculating the state of an
> object, and realise halfway that the underlying model has changed, so even
> before I attempt to save it I can rectify my calculations on the fly.
>
Did you have a look at MagLev?

I'm assuming that when you say row locking thats pessimistic locking? Which
> is the other alternative which I will give a go as well, although I think on
> initial inspection has the possibility of deadlocking this particular
> scenario..
>
You do not want to have overoptimistic locking in a web app. Deadlock is
almost guaranteed :)


So that's actually my problem - I read a value and depend on that value, and
> so during the time of me calculating things with that value if it has
> changed, I need to know, but I can't until I have done my calculations, and
> find that value has changed when I try to save - but some instances, you
> don't even need to save.. you just do the calculation and pass that along..
> which by that stage is incorrect.
>
If you will wrap all your calculations within a transaction you are
guaranteed to have correct values. Doesn't it solve the problem?

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to