2

モデルタスクがあります

t.string   "name"
t.hstore   "actions"

例:

#<Task id: 1, name: "first", actions: {"today"=>"9"}, 
#<Task id: 2, name: "second", actions: {"yesterday"=>"1"}, 
#<Task id: 3, name: "third", actions: nil,
#<Task id: 4, name: "four", actions: {"today"=>"11"},

アクション: nil、:today<10、キー:today が存在しないすべてのレコードを検索する必要があります。1,2,3タスクです。

Task.where("actions -> 'today' < '10'") - it return only first task.
Task.where("actions -> 'today' < '10' OR actions IS NULL")  - it return 1 and 3 records.

キーを持たないすべてのレコードを見つけるにはどうすればよいですか :today in action?

4

1 に答える 1