You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I ran into an issue in my application after adding the oj gem. I tracked it down to oj turning some numeric values into BigDecimal objects when parsing them. Without oj, they are read as a Float object.
It sounds like the :bigdecimal_load option is not set to :float. It gets a bit tricky with a mixture of rails and json. The calls that start with JSON. are from the json gem yet rails changes some of the defaults and setting of the json gem. Can you try setting :bigdecimal_load before calling JSON.load and see if that makes a difference?
Thank you. Running Oj.default_options = { bigdecimal_load: :float } did fix the issue.
Is this something that should be done automatically by Oj.optimize_rails ?
If there's a concern of breaking compatibility with existing deployments, could the rails page recommend setting this option?
There might be. I'll dig into it a bit more tonight. I'm not sure what the default is for rails and json. Does your environment change any defaults that might effect the processing and if so that would they be called?
I ran into an issue in my application after adding the
oj
gem. I tracked it down tooj
turning some numeric values intoBigDecimal
objects when parsing them. Withoutoj
, they are read as aFloat
object.Rails version: 6.1.7.6
Ruby version: 3.0
The particular issue I'm seeing happens when using
JSON
as the encoder forActiveRecord::Store
: https://api.rubyonrails.org/v6.1/classes/ActiveRecord/Store.htmlThe text was updated successfully, but these errors were encountered: