Skip to content

bind message supplies 2 parameters, but prepared statement \"\" requires 1 #2816

@DaliborTrampota

Description

@DaliborTrampota

Hi, I have this piece of code and for some reason it wont replace the $2 with the proper variable

code is varchar(10)
expiryDate is date

let imageID = 'ABCDEFG'
let lifetime = 604800000
await this.pg.query("INSERT INTO media(code, expiryDate) VALUES($1, CURRENT_DATE + INTERVAL '$2 ms')", [imageID, lifetime])

it says it requires only one parameter but I have two in there.

I have to make my query like this
await this.pg.query(INSERT INTO media(code, expiryDate) VALUES($1, CURRENT_DATE + INTERVAL '${lifetime} ms'), [imageID])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions