Skip to content

Errors with parameters  #975

@ponomar

Description

@ponomar
  • asyncpg version: 0.26.0
  • PostgreSQL version: 13.2
  • Python version: 3.10.5
  • Platform: Ubuntu
  • Do you use pgbouncer?: no
  • Did you install asyncpg with pip?: yes

Case 1

await fetch('SELECT $1', 1)

asyncpg.exceptions.DataError: invalid input for query argument $1: 1 (expected str, got int)

While 2 similar work fine:

await fetch('SELECT $1::int', 1)
await fetch('SELECT $1', '1')

It can not handle integers automatically?

Case 2

await fetch('select case when true then $1 end', 1)

Fails with the same error as above, while next query works fine (when parameter in Else statement):

await fetch('select case when true then 1 else $1 end', 1) 

Case 3

await fetch('select val is $1 from unnest(array[1,null]) as x(val)', None)

asyncpg.exceptions.PostgresSyntaxError: syntax error at or near "$1"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions