MagicStack / MagicStack/asyncpg

passing a list\set as an argument failing

Open
#511 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.1k
Forks
468
PR merge metrics
No merged PRs in 30d

Description

  • asyncpg version:19.0
  • PostgreSQL version:12
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    :N\A
  • Python version:3.7.5
  • Platform:Windows
  • Do you use pgbouncer?:No
  • Did you install asyncpg with pip?:Yes
  • If you built asyncpg locally, which version of Cython did you use?:N\A
  • Can the issue be reproduced under both asyncio and
    uvloop?
    :

Similar to issue #94

I am trying to set up a query using ($1) and passing an argument. I am running into an issue when trying to pass a list of sets. Is there a way to format this query like the last example?

query = [(0,0), (1,1), (2,2)]

works:    await conn.fetch('SELECT * FROM table WHERE (a, b) IN ((0,0), (1,1), (2,2))')

works:    await conn.fetch('SELECT * FROM table WHERE (a, b) IN ' + str(tuple(query)))

fails:    await conn.fetch('SELECT * FROM table WHERE (a, b) IN ($1)', '((0,0), (1,1), (2,2))')

fails:    await conn.fetch('SELECT * FROM table WHERE (a, b) IN ($1)', str(tuple(query)))

works:    await conn.fetch('INSERT INTO table (a, b, c, d) VALUES ($1, $2, $3, $4)', a, b, c, d)

Thank you

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction examples in this issue and compare them with issue #94, focusing on how asyncpg handles a parameter used in a PostgreSQL row-value IN expression. Reproduce the working and failing queries on the stated Python, PostgreSQL, and Windows setup; done means the supported behavior and required argument form are established or documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.