Skip to content

error: invalid input syntax for integer: "123.456" #996

@summer4096

Description

@summer4096

numeric arguments in prepared statements are sent to postgres as strings. I'm not sure why this is important, but it causes the following case to fail:

client.query('SELECT * FROM numbers WHERE n > $1', [123.456])

where numbers.n is of type int, bigint, etc. Since 123.456 is sent as a string, postgres interprets this like WHERE n > '123.456'::int which fails with the following error:

error: invalid input syntax for integer: "123.456"

Preparing the query manually, as follows, works without a hitch:

client.query('SELECT * FROM numbers WHERE n > 123.456')

A test case is incoming.

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