Skip to content

bigint (int64) insert attempt throws "value out of int32 range" exception #391

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

Closed
diraven opened this issue Dec 9, 2018 · 4 comments
Closed

Comments

@diraven
Copy link

diraven commented Dec 9, 2018

  • asyncpg version: asyncpg==0.18.2
  • PostgreSQL version: PostgreSQL 11.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.2.1 20180831, 64-bit
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : Don't use, reproduced locally.
  • Python version: Python 3.7.1
  • Platform:Linux archlinux 4.19.4-arch1-1-ARCH Other examples? #1 SMP PREEMPT Fri Nov 23 09:06:58 UTC 2018 x86_64 GNU/Linux
  • Do you use pgbouncer?: no
  • Did you install asyncpg with pip?: yes
  • If you built asyncpg locally, which version of Cython did you use?: no, n/a
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : n/a
create table mydiscord_guild
(
  id serial not null
    constraint mydiscord_guild_pkey
      primary key,
  discord_id text not null
    constraint mydiscord_guild_uid_key
      unique,
  name text not null
    constraint mydiscord_guild_name_key
      unique,
  trigger varchar(1) not null
);

On insert attempt I get this error even though the field is bigint and I guess should have been processed by the int8_encode instead:

asyncpg.exceptions.DataError: invalid input for query argument $1: 435075722181083147 (value out of int32 range)

Possibly related to #316 , but in this case it's not a custom datatype.

Possibly related to #279, but it's not negative.

@elprans
Copy link
Member

elprans commented Dec 9, 2018

Please provide a code snippet.

@diraven
Copy link
Author

diraven commented Dec 9, 2018

        return await conn.execute(
            '''INSERT INTO mydiscord_guild VALUES ($1, $2, $3);''',
            discord_id,
            name,
            trigger,
        )

@diraven
Copy link
Author

diraven commented Dec 9, 2018

Wait a sec, let me check something. I think I might be trying to put discord_Id into id field.

@diraven
Copy link
Author

diraven commented Dec 9, 2018

Yep, that's exactly what's happening. I need to sleep.

Sorry for taking your time... =|

@diraven diraven closed this as completed Dec 9, 2018
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