I have a type json column in one of my PostgreSQL tables. Following the docs
<http://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/pg_json_rb.html>
i
added the pg_json extension and also loaded the pg_typecast_on_load plugin
for my model, but i'm always getting a string and not the actual json. The
code looks like this:
class User < Sequel::Model
plugin :pg_typecast_on_load, :tokens
def generate_token!
self.tokens = Sequel.pg_json({
token: token_hash,
expiry: TOKEN_EXPIRY,
updated_at: Time.now
})
save(raise_on_failure: true)
end
end
When i do:
user.tokens
I get somethink like:
"{\"token\":\"$2a$10$ABzWzLDx2C9Q/uLSSoErbO2CxkzKYuzpH0daR/WcD1buPV4QUBK3i\",\"expiry\":\"2016-02-28T21:25:37.789+02:00\",\"updated_at\":\"2016-02-21T21:25:38.138+02:00\"}"
I`m pretty new to Sequel( i find it really fun and easy to work with) and
maybe i missed something along the way, but i just don`t know what exactly.
I tried using strings, instead of symbols for keys, removing the
pg_typecase_on_load plugin, but nothing helped. What am i doing wrong?
Should be something pretty straightforward.
--
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.