我使用的是Ecto 3.0,我不确定Ecto如何在查询中使用时区。基本上,我有两个日期作为输入用作查询范围:
from(u in User)
|> where([u], u.created_at >= type(^date_begin, :date))
|> where([u], u.created_at <= type(^date_end, :date))
|> Repo.all
我的架构被定义为utc_datetime,但我有一个时区需要考虑。因此,根据本地时区,查询应返回正确的结果。
示例:
date_begin: 2018-02-16
created_at: 2018-02-16 01:00:00
没有时区,created_at&gt; = date_begin应为true。
但是,使用timezone -02:00:
date_begin: 2018-02-16
created_at: 2018-02-15 23:00:00 -02:00
比较返回false。
我想要查询最后一个行为,但我不知道Ecto在这种情况下做了什么。
有人知道在这种情况下会发生什么? Ecto只考虑查询中的utc格式?