a. If I fetch the same table twice will both results contain identical record objects or they differ? b. I have to monitor changes of certain tables and send only different records to client side (Java applet). Is there a convenient way to do or I have to do it manually? Thanks, Gábor
On 6/6/05, Gábor SEBESTYÉN <segabor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> a. If I fetch the same table twice will both results contain > identical record objects or they differ?Depends on whether the table has changed. There''s no magic caching in AR, so you''ll get what''s actually in the table> b. I have to monitor changes of certain tables and send only > different records to client side (Java applet). Is there a convenient > way to do or I have to do it manually?You could use modified_at and do a search like: Blah.find(:all, :conditions=>["modified_at > ?", @session[:last_query_time]]) @session[:last_query_time] = Time.now> Thanks, > > Gábor > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Cheers Koz
its actually updated_at ( and created_at ) i don''t think modified_at is taken care of automatically... On 6/5/05, Michael Koziarski <koziarski-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 6/6/05, Gábor SEBESTYÉN <segabor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > a. If I fetch the same table twice will both results contain > > identical record objects or they differ? > > Depends on whether the table has changed. There''s no magic caching > in AR, so you''ll get what''s actually in the table > > > b. I have to monitor changes of certain tables and send only > > different records to client side (Java applet). Is there a convenient > > way to do or I have to do it manually? > > You could use modified_at and do a search like: > > Blah.find(:all, :conditions=>["modified_at > ?", @session[:last_query_time]]) > @session[:last_query_time] = Time.now > > > > Thanks, > > > > Gábor > > > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > Cheers > > Koz > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://typo.leetsoft.com - Open source weblog engine http://blog.leetsoft.com - Technical weblog
On 6/6/05, Tobias Luetke <tobias.luetke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> its actually updated_at ( and created_at ) i don''t think modified_at > is taken care of automatically...This is true. I should really read the docs once in a while .... ;)> On 6/5/05, Michael Koziarski <koziarski-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On 6/6/05, Gábor SEBESTYÉN <segabor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > a. If I fetch the same table twice will both results contain > > > identical record objects or they differ? > > > > Depends on whether the table has changed. There''s no magic caching > > in AR, so you''ll get what''s actually in the table > > > > > b. I have to monitor changes of certain tables and send only > > > different records to client side (Java applet). Is there a convenient > > > way to do or I have to do it manually? > > > > You could use modified_at and do a search like: > > > > Blah.find(:all, :conditions=>["modified_at > ?", @session[:last_query_time]]) > > @session[:last_query_time] = Time.now > > > > > > > Thanks, > > > > > > Gábor > > > > > > _______________________________________________ > > > Rails mailing list > > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > > -- > > Cheers > > > > Koz > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > -- > Tobi > http://www.snowdevil.ca - Snowboards that don''t suck > http://typo.leetsoft.com - Open source weblog engine > http://blog.leetsoft.com - Technical weblog >-- Cheers Koz
On 2005.06.05., at 22:59, Michael Koziarski wrote:> You could use modified_at and do a search like: > > Blah.find(:all, :conditions=>["modified_at > ?", @session > [:last_query_time]]) > @session[:last_query_time] = Time.now >It won''t include deleted and inserted objects only the changed ones but I need them all. I''m thinkink on a kind of snapshotting - storing an actual array as snapshot and next time I refech data compare it with the latest snapshot and send the difference. Gábor _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
On 6/5/05, Gábor SEBESTYÉN <segabor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Blah.find(:all, :conditions=>["modified_at > ?", > @session[:last_query_time]]) > > @session[:last_query_time] = Time.now > It won''t include deleted and inserted objects only the changed ones but I > need them all. I''m thinkink on a kind of snapshotting - storing an actual > array as snapshot and next time I refech data compare it with the latest > snapshot and send the difference. >Your best bet is going to be to setup a "changes" table on the database side and have a trigger that fires on any INSERT, UPDATE, or DELETES that populates this table with a copy of the data, along with an extra column to note when the change took place and possibly one to note what the change was (Insert/Update/Delete). Then just query this table at your interval and use that data. Once you pull out the data - just delete out the rows you no longer need from the "changes" table. -- John W Higgins wishdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
I''m not positive about ruby but in most languages the objects would have identical content but not be identical objects... i.e. if you test for object equality you''d fail but if you tested for content equality you''d pass -Kate (masukomi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org) On 6/6/05, John Higgins <wishdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 6/5/05, Gábor SEBESTYÉN <segabor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Blah.find(:all, :conditions=>["modified_at > ?", > > @session[:last_query_time]]) > > > > @session[:last_query_time] = Time.now > > It won''t include deleted and inserted objects only the changed ones but I > > need them all. I''m thinkink on a kind of snapshotting - storing an actual > > array as snapshot and next time I refech data compare it with the latest > > snapshot and send the difference. > > > > Your best bet is going to be to setup a "changes" table on the > database side and have a trigger that fires on any INSERT, UPDATE, or > DELETES that populates this table with a copy of the data, along with > an extra column to note when the change took place and possibly one to > note what the change was (Insert/Update/Delete). Then just query this > table at your interval and use that data. Once you pull out the data - > just delete out the rows you no longer need from the "changes" table. > > > -- > John W Higgins > wishdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >