Skip to content

Pack fail with big number with argument out of range #27

Open

Description

@EDRossi

trying to use a Numeric(11) the package fail when trying to pack

sqlanydb.py line 430

        size = param.value.buffer_size
        buffer = create_string_buffer(value)
    else:
        buffer = **create_string_buffer(pack(fmt, value))**
        size = length = calcsize(fmt)
    param.value.buffer = cast(buffer, POINTER(c_char))

image

i am using flask and sqlalchemy

Activity

  1. EDRossi commented on Sep 23, 2022

    @EDRossi
    Author

    i tryed to use bigint ending with the same result

  2. hynek commented on Feb 12, 2024

    @hynek

    This is btw not just some ORM problem. I've just run into the same problem with raw SQL and had to transform the numbers into strings first:

      File "/Users/hynek/Work/mailbox-usage-svc/src/mailbox_usage_svc/adapters/repositories.py", line 70, in update_mailbox
        self.cursor.execute(
      File "/Users/hynek/Work/mailbox-usage-svc/.venv/lib/python3.12/site-packages/sqlanydb.py", line 840, in execute
        self.executemany(operation, [parameters])
      File "/Users/hynek/Work/mailbox-usage-svc/.venv/lib/python3.12/site-packages/sqlanydb.py", line 814, in executemany
        parms = [bind(k, col)
                 ^^^^^^^^^^^^
      File "/Users/hynek/Work/mailbox-usage-svc/.venv/lib/python3.12/site-packages/sqlanydb.py", line 803, in bind
        (self.assign)(param, col)
      File "/Users/hynek/Work/mailbox-usage-svc/.venv/lib/python3.12/site-packages/sqlanydb.py", line 437, in assign
        buffer = create_string_buffer(pack(fmt, value))
                                      ^^^^^^^^^^^^^^^^^
    struct.error: 'i' format requires -2147483648 <= number <= 2147483647
    

    The type of the field is bigint.

    @DanCummins-SAP any chance of this being addressed? Not being able to insert big numbers into a database is kinda big deal.

  3. DanCummins-SAP commented on Feb 15, 2024

    @DanCummins-SAP
    Collaborator

    @DanCummins-SAP any chance of this being addressed? Not being able to insert big numbers into a database is kinda big deal.

    Hi Hynek,
    Thanks for the report, we have added it to our backlog.
    Dan

  4. hynek commented on Mar 12, 2024

    @hynek

    This is fixed in 1.0.14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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