byroot / activerecord-typedstore

ActiveRecord::Store but with type definition
MIT License
441 stars 57 forks source link

Rails 7, Can't find element with where in jsonb field #99

Closed mario-amazing closed 1 year ago

mario-amazing commented 1 year ago

I can't find any element with where condition User.where('settings @> ?', '{"notify_new_appointment":true}').first Because with typed_store field saves in format: "---\nnotify_new_appointment: true\n" #PG jsonb field Expected format(without typed_store): {"notify_new_appointment": true} # works as expected with jsonb where queries

My simple typed_store configuraiton:

  typed_store :settings  do |s|
    s.boolean :notify_new_appointment
  end

Rails 7 activerecord-typedstore (1.5.1)

byroot commented 1 year ago

The default seraiizer is YAML. You have to specify a different one if you wish to use JSONB.