How to use SQL expression when inserting data #32715
-
await supabase.from(this.table).insert({
id,
type: 'oauth',
code,
expires_at: `NOW() + interval '${this.ttl} second'`,
}); However, I encountered an error. {
code: '22007',
details: null,
hint: null,
message: `invalid input syntax for type timestamp with time zone: "NOW() + interval '300 second'"`
} But the syntax seems valid in SQL editor, my best guess is that the expression was escaped (quoted) as a string. update mytable set expires_at = NOW() + interval '300 second' where id = '123456'; |
Beta Was this translation helpful? Give feedback.
Answered by
GaryAustin1
Jan 11, 2025
Replies: 1 comment 1 reply
-
You can't run SQL from the REST clients. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
razonyang
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can't run SQL from the REST clients.
https://docs.postgrest.org/en/latest/how-tos/working-with-postgresql-data-types.html#timestamps Mentions a few things that work in the string for a timestamp from this: https://www.postgresql.org/docs/current/datatype-datetime.html#DATATYPE-DATETIME-SPECIAL-TABLE