Skip to content

fix(db): preserve unsigned 64-bit values during parameter binding #449

Description

@GaspardKirira

Summary

Fix unsigned 64-bit parameter binding so values greater than INT64_MAX are not silently converted to negative signed values.

The public overload accepting std::uint64_t must remain available.

Current behavior

Statement::bind(std::size_t, std::uint64_t) converts the value to std::int64_t before forwarding it.

DbValue already contains a std::uint64_t alternative, but the current driver implementations do not consistently handle it.

Expected behavior

Unsigned 64-bit values must either:

  • be bound losslessly when supported by the backend; or
  • fail clearly when a backend cannot represent the value safely.

Silent narrowing must not occur.

Scope

  • Stop unconditional signed narrowing in the convenience overload.
  • Add explicit std::uint64_t handling to SQLite.
  • Add explicit std::uint64_t handling to MySQL.
  • Define backend behavior for values above the signed 64-bit range.
  • Add boundary-value tests.
  • Preserve the existing public DB API.

Suggested files

  • modules/db/include/vix/db/core/Drivers.hpp
  • modules/db/src/sqlite/SQLiteDriver.cpp
  • modules/db/src/mysql/MySQLDriver.cpp
  • modules/db/tests/sqlite_driver_test.cpp
  • modules/db/tests/mysql_driver_test.cpp

Acceptance criteria

  • 0, INT64_MAX, INT64_MAX + 1, and UINT64_MAX are tested.
  • No unsigned value is silently converted to a negative value.
  • Supported values round-trip correctly.
  • Unsupported values produce a clear DBError.
  • Existing public overloads remain source-compatible.

Non-goals

This issue does not include:

  • arbitrary-precision integers;
  • decimal numeric types;
  • schema type changes;
  • ORM numeric conversion.

Suggested labels

  • scope:db
  • type:bug
  • tests
  • help wanted
  • status:ready

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededscope:dbDatabase driversstatus:readyIssue is fully specified and ready for implementationtestsTests, CI coverage and validationtype:bugIncorrect behavior, crash, or regression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions