Skip to content

When using PGArray and Dirty, array fields are marked as changed even when set to same array #586

Closed
dlee opened this Issue Nov 16, 2012 · 3 comments

2 participants

@dlee
dlee commented Nov 16, 2012

When using PGArray and Dirty, array fields are marked as changed even when set to same array value.

Although the incoming Array is equal to the initial PGArray (using ==), there's an explicit check against the classes that still makes it dirty: https://github.com/jeremyevans/sequel/blob/master/lib/sequel/model/base.rb#L928

@dlee
dlee commented Nov 16, 2012

My current workaround is to override the setter and explicitly cast to to PGArray before passing to super:

  def my_array_field=(array)
    super array.pg_array
  end
@jeremyevans
Owner

Weird, v.class and c.class should be the same, since typecast_value should return a PGArray, and the existing value should also be a PGArray. I tried something similar in one of my apps and I can't reproduce this, can you submit a failing spec? Are you loading the pg_array extension into the Database object before loading your models? If not, do that and see if it fixes the problem.

@jeremyevans
Owner

I assume this problem is caused by not loading the pg_array extension into the Database object before loading the models. If you are already doing that and you still believe this is an issue, please submit a pull request with a failing spec and I'll look into the issue again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.