【发布时间】:2020-08-16 19:16:29
【问题描述】:
我有一个查询,我想在未来获取所有记录。
def get_scheduled_notification_pushes_from_date(date\\DateTime.utc_now()) do
query = from s in ScheduledPush,
where: s.status not in ["completed", "cancelled"] and s.utc_schedule_time >= ^date
Repo.all(query)
end
我认为这可能会被转换或转换为 postgres - 但它一定在做一些奇怪的事情。
我也尝试比较 ~U[] 对象.. 但这是个坏主意...
iex(37)> ~U[2020-08-15 20:39:00.000000Z] >= ~U[2020-08-15 20:36:10.367654Z]
warning: invalid comparison with struct literal ~U"2020-08-15 20:39:00.000000Z". Comparison operators (>, <, >=, <=) perform structural and not semantic comparison. Comparing with a struct literal is unlikely to give a meaningful result. Modules typically define a compare/2 function that can be used for semantic comparison
false
如何使用 Ecto 查找基于 DateTime.utc_now() 之前的值的记录?
utc_schedule_time 的类型是 utc_datetime_usec
【问题讨论】:
标签: postgresql elixir ecto