Skip to content

WHERE IN throws TypeError: str.replace is not a function #701

Open
@Nepherpitou

Description

@Nepherpitou

Queries with WHERE IN ${sql()} fails with error starting from version 3.4.0

await sql`
  select
    *
  from users
  where age in ${ sql([68, 75, 23]) }
`

Error:

TypeError: str.replace is not a function
    at escape (...\node_modules\postgres\cjs\src\types.js:217:20)
    at ...\node_modules\postgres\cjs\src\types.js:213:22
    at Array.map (<anonymous>)
    at escapeIdentifiers (...\node_modules\postgres\cjs\src\types.js:213:13)
    at Object.select [as fn] (...\node_modules\postgres\cjs\src\types.js:139:12)
    at Builder.build (...\node_modules\postgres\cjs\src\types.js:71:17)
    at stringifyValue (...\node_modules\postgres\cjs\src\types.js:109:38)
    at stringify (...\node_modules\postgres\cjs\src\types.js:100:16)
    at build (...\node_modules\postgres\cjs\src\connection.js:223:20)
    at Object.execute (...\node_modules\postgres\cjs\src\connection.js:167:7)
    at go (...\node_modules\postgres\cjs\src\index.js:341:14)
    at Query.handler (...\node_modules\postgres\cjs\src\index.js:330:14)
    at Query.handle (...\node_modules\postgres\cjs\src\query.js:140:65)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at new Query (...\node_modules\postgres\cjs\src\query.js:35:9)
    at Object.sql (...\node_modules\postgres\cjs\src\index.js:112:11)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions