【发布时间】:2013-07-15 00:56:59
【问题描述】:
我有一个模型任务
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
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?
【问题讨论】:
-
您的意思是您想要任务 2,3 而不是 1,2,3 任务作为回报吗?我看到今天出现在任务 1 中。
-
我需要返回 1,2,3 个任务。
-
你的行为中是否存在“前天”之类的东西?有哪些可能性,只是
today和yesterday还是还有更多? -
更多。 Task.where("actions -> 'today'
标签: ruby-on-rails postgresql-9.1 hstore