Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid input for query argument (value out of int32 range) #817

Closed
stefanitsky opened this issue Aug 25, 2021 · 2 comments
Closed

Invalid input for query argument (value out of int32 range) #817

stefanitsky opened this issue Aug 25, 2021 · 2 comments

Comments

@stefanitsky
Copy link

  • asyncpg version: 0.24.0
  • PostgreSQL version: 12.8
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : no
  • Python version: 3.8
  • Platform: OS X
  • Do you use pgbouncer?: no
  • Did you install asyncpg with pip?: yes (poetry)
  • If you built asyncpg locally, which version of Cython did you use?: -
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : yes

Hello!

I have a problem with bigint cast.

I'm using sqlalchemy with asyncpg, when i trying to cast value i get this:

sqlalchemy.exc.DBAPIError: (sqlalchemy.dialects.postgresql.asyncpg.Error) <class 'asyncpg.exceptions.DataError'>: invalid input for query argument $1: 880194977773281290 (value out of int32 range)
[SQL: UPDATE plugin_welcomer SET roles=array_remove(plugin_welcomer.roles, CAST(%s AS BIGINT)) WHERE plugin_welcomer.guild_id = %s]

Column:
image

DataGrip works perfectly:
image

I don't know what to do, and i don't want to change db types to varchar, but it looks like it will be...

@elprans
Copy link
Member

elprans commented Aug 25, 2021

You seem to be missing a bigint cast in the where clause.

@stefanitsky
Copy link
Author

No, it's the second argument, error caued by first.

Well, i switched to raw sql and it works even without cast:

INFO:sqlalchemy.engine.Engine:
            UPDATE plugin_welcomer
            SET roles=array_remove(plugin_welcomer.roles, 880206199588371433)
            WHERE plugin_welcomer.guild_id = 873336491304329227;

It looks like this is not an asyncpg issue, sorry for wasting time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants