You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2510485
Browse filesBrowse the repository at this point in the historyBrowse files
Attempt to fix precendence issue with datetime_add (#182)
SQLite binds `||` tighter than `+`, and `IS`, `IN`, and `=` tighter than
`NOT` and `AND`. The generated SQL for `datetime_add`, `is_nil`, `not`,
`in`, and update inc dropped parentheses around compound operands, so
counts like `a + b` became `NULL`.
Fixes: #181
assert~s{SELECT 1 FROM "schema" AS s0 WHERE (CAST (strftime('%Y-%m-%dT%H:%M:%f000Z',s0.\"foo\",(s0.\"x\" + s0.\"y\") || ' day') AS TEXT) > s0."bar")}==
assert~s{SELECT 1 FROM "schema" AS s0 WHERE (CAST (strftime('%Y-%m-%dT%H:%M:%f000Z',s0.\"foo\",((s0.\"x\" + s0.\"y\") * 7) || ' days') AS TEXT) > s0."bar")}==
assert~s{SELECT 1 FROM "schema" AS s0 WHERE (CAST (strftime('%Y-%m-%dT%H:%M:%f000Z',s0.\"foo\",((s0.\"x\" + s0.\"y\") / 1000.0) || ' seconds') AS TEXT) > s0."bar")}==
59
+
all(query)
60
+
end
61
+
62
+
test"date_add parenthesizes compound day count"do
63
+
query=
64
+
"schema"
65
+
|>where([s],date_add(s.foo,s.x+s.y,"day")>s.bar)
66
+
|>select([],true)
67
+
|>plan()
68
+
69
+
assert~s{SELECT 1 FROM "schema" AS s0 WHERE (CAST (strftime('%Y-%m-%d',s0.\"foo\",(s0.\"x\" + s0.\"y\") || ' day') AS TEXT) > s0."bar")}==
0 commit comments