доступ к полю json для продолжения ruby

У меня есть следующая схема:

 Column  |            Type             |       Modifiers        
---------+-----------------------------+------------------------
 id      | text                        | not null
 data    | json                        | not null
 created | timestamp without time zone | not null default now()

Если я открою psql, я смогу запустить запрос.

select id, data->'amount' as amount from plans;

Но рубиновый sequel драгоценный камень все портит.

puts $db.run("select id, data->'amount' as amount from plans")

Что случилось?


person AJcodez    schedule 01.04.2015    source источник


Ответы (1)


Нужен #literal метод.

$db.run("select id, data -> #{ $db.literal('amount') } as amount from plans")
person AJcodez    schedule 01.04.2015