我想提取所有与json列start_date
中request
字段匹配的记录,以便在星期六或星期日。
尝试了这个
Foo.where("extract(dow from request->>'start_date') ?| array[5.0, 6.0]")
收到错误ERROR: function pg_catalog.date_part(unknown, text) does not exist
答案 0 :(得分:1)
您应CAST
之前DATE
EXTRACT
的价值{/ 1}}:
Foo.where("extract(dow from CAST(request->>'start_date' AS DATE)) IN(5.0, 6.0)")