I have a situation where I want to set values in a few columns of a bunch 
of related rows, and write those changes out.  I most cases, the data will 
remain unchanged, but I don't want to add a ton of extra logic to prevent 
writes.

As an extreme oversimplification, suppose I have an array of rows that I've 
updated a "location" column, and it may be the exact value it already has.  

For example,


*rows.each do |row|*
*  row.location = # some code to set location*
*end*

If I do this:

*rows.each { |row| row.save_changes }*

Its still sends an update statement to postgres, even if the location is 
the the same as when it was originally read.

I've used the dirty plugin to solve this by doing this

*rows.each { |row| row.save_changes if row.column_changes.any? }*

and that seems to work, but I am wondering if I'm missing something that's 
built in to Sequel.   We're currently using a 4.x version of Sequel.

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/d155253d-6630-4797-958c-caec9858cbb0n%40googlegroups.com.

Reply via email to