-
Notifications
You must be signed in to change notification settings - Fork 503
Open
Description
Hi,
I'm having an issue with using where expr with parametrized INTERVAL.
Code:
d := 3
builder := r.StatementBuilderType.
Delete("test").
Where(squirrel.Expr("expiry <= now()::timestamptz - INTERVAL '? DAYS'", d))
query, args, err = builder.ToSql()
logrus.Infof("query: %s, args: %+v", query, args)
// db execute
I'm getting the following error:
ERROR: could not parse "$1 DAYS" as type interval: interval: missing number at position 0: "$1 DAYS" (SQLSTATE 22007)
Generated query and args:
query: DELETE FROM test WHERE expiry \u003c= now()::timestamptz - INTERVAL '$1 DAYS'
args: [3]
Expected SQL:
delete from test where expiry <= now()::timestamptz - INTERVAL '3 days';
Is this a bug? Is there any other way this can be achieved?
Thanks!
Metadata
Metadata
Assignees
Labels
No labels