I have following query:
select * from shifts where date(shifts.starts_at + interval ‘7200 seconds’) > ‘2019-09-17’
7200 and date part are dynamic values calculated before query is executed. What I tried to do is to use fragment in the following way:
offset = #some calculation here from s in Shift, where: fragment("date(? + interval '? seconds') >= ?", s.starts_at, ^offset, ^Date.utc_today())
but I got error that type of parameter $2 cannot be determined. I’ve tried to use
type(offset, :integer) as well as
type(Integer.to_string(offset), :string) but none of them works. I’m obviously missing something but I cannot find a way to create such query through Ecto. Is something like this possible in Ecto?