Syntax error at or near "$1" at "Query parameters"
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 8.7k
- Forks
- 374
- Avg merge
- 11d 16h
- Merged PRs (30d)
- 1
Description
Hello. I'm trying to make a dynamic request. I try to do it as closely as possible to the documentation, but I still get syntax error at or near "$1"
Can you tell me what I'm doing wrong?
const days = 1
const result = await sql`
select *
from ${sql(table)}
where
timestamp >= current_timestamp - interval ${days} day
`
When i use timestamp >= current_timestamp - interval '1' day all works correctly
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Query parameters documentation and reproduce the JavaScript snippet against PostgreSQL, comparing the interpolated table and interval expressions with the working literal form. Done means determining whether this is a usage error or a client defect and documenting the correct behavior or a focused repository change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, postgresql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100