On Thu, Jan 21, 2021 at 4:54 PM Mark Rubenstein <[email protected]>
wrote:

> Hello have a question about the pg_interval extension.
> Ran into issue when testing month records.
>
> STEPS:
> 1) Create ActiveSupport::Duration `ActiveSupport::Duration.parse('P1M')`
> This Duration has an internal value of 2629746
> Same as constant SECONDS_PER_MONTH
> https://api.rubyonrails.org/v6.0.3.4/classes/ActiveSupport/Duration.html
>
> 2) Value saved to db with pg_interval extension
>
> 3) Value retried from db with pg_interval extension
> The returned value has the correct parts [[:months, 1]] but the internal
> value is 2592000
> As set in pg_interval.rb
> line 78 `value += 2592000 * v`
> line 107 `ActiveSupport::Duration.new(value, parts)`
>
> This causes initial ActiveSupport::Duration to not be equal to returned
> ActiveSupport::Duration
>
> Is there something I may be doing incorrect or is this a valid issue?
> Would updating version of Activesupport or sequel help? From quick look at
> docs/code seems like may run into same issue?
>

We should change pg_interval to use the same value as
ActiveSupport::Duration.  Note that at the time the pg_interval extension
was created, the values matched what ActiveSupport::Duration used, and
ActiveSupport::Duration did not expose any constants.  Looks like the
ActiveSupport::Duration values changed and started supporting constants in
ActiveSupport 5.1.

I have a local fix for this.  I'll run it through a full round of tests
tomorrow, and if no problems show up, commit it to the master branch.

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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/CADGZSSeS5pPdnoZSWfdKNJss5OFOZkyTRLo9GvGOLSVkSHv%3DUg%40mail.gmail.com.

Reply via email to