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
{{ message }}
This repository has been archived by the owner on Sep 21, 2020. It is now read-only.
I have Alert and AlertSub. AlertSub has_many :alerts.
[56]pry(main)> Alert.first.dataAlertLoad(0.6ms)SELECT"alerts".* FROM"alerts"LIMIT1=>{"toto"=>"tata"}# type hash, ok
[57]pry(main)> Alert.select('data').all.first.dataAlertLoad(0.4ms)SELECTdataFROM"alerts"=>{"toto"=>"tata"}# type hash, ok
[58]pry(main)> Alert.select('data as d').all.first.dAlertLoad(0.5ms)SELECTdataasdFROM"alerts"=>"\"toto\"=>\"tata\""# string, not ok# .class says String
[61]pry(main)> AlertSub.joins(:alerts).# :alerts is just a has_many :alerts in class AlertSub[61]pry(main)* select('alerts.id, alerts.data').[61]pry(main)* where('alert_subs.user_id = 1').all.first.dataAlertSubLoad(0.7ms)SELECTalerts.id,alerts.created_at,alerts.param,alerts.data::hstoreFROM"alert_subs"INNERJOIN"alerts"ON"alerts"."alert_sub_id"="alert_subs"."id"WHERE(alert_subs.user_id=1)=>"\"toto\"=>\"tata\""# string, not ok
It looks like when I use the method .select with has, or with a join, I get back a string instead of a hash for the hstore value.
In my model, I do have the line: serialize :data, ActiveRecord::Coders::Hstore
How can I get back a hash, event when I use a .select ?
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have Alert and AlertSub. AlertSub has_many :alerts.
It looks like when I use the method
.select
with has, or with a join, I get back a string instead of a hash for the hstore value.In my model, I do have the line:
serialize :data, ActiveRecord::Coders::Hstore
How can I get back a hash, event when I use a .select ?
The text was updated successfully, but these errors were encountered: