Ok, this was just me being an idiot. I had picked the wrong column to group 
by which meant the array data was coming in randomly (and unrelated), so it 
looks like everything is indeed working. My apologies!  And once again my 
extreme gratitude for what you've created with Sequel.

On Monday, October 19, 2020 at 4:34:29 PM UTC-4 Jeremy Evans wrote:

> On Mon, Oct 19, 2020 at 1:25 PM jaso...@gmail.com <jaso...@gmail.com> 
> wrote:
>
>>
>> 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.
>>
>
> Sequel does check to see if the value is the same before adding the column 
> to changed_columns:
>
>   if new? || !vals.include?(column) || v != (c = vals[column]) || v.class 
> != c.class
>     change_column_value(column, v)
>   end
>
> That code hasn't changed since 2012.  Not sure why that isn't handling 
> your case.  Is the class different?
>
> If you could provide a minimal, self contained example showing the problem 
> with the current version of Sequel, I may be able to provide more help.
>
> Thanks,
> Jeremy
>

-- 
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 sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/8b30c3e5-8ac4-4bc0-8718-0b0ff430a127n%40googlegroups.com.

Reply via email to