Skip to content

enhance(db): standardize result-set state and column validation #458

Description

@GaspardKirira

Summary

Standardize result-set safety across drivers.

Invalid row access and invalid column indexes should produce consistent DBError diagnostics instead of backend-specific behavior or undefined access.

Current behavior

SQLite tracks whether next() produced a row and rejects row() before a successful call.

The MySQL result wrapper does not currently enforce the same state check.

Column access methods rely mostly on native backend behavior and do not provide consistent bounds validation.

Expected behavior

All drivers must follow the same result-set contract:

  • row() is valid only after next() returns true;
  • row access becomes invalid after next() returns false;
  • column indexes must be within 0..cols()-1;
  • invalid access must produce a clear DBError.

Scope

  • Standardize current-row state tracking.
  • Add column bounds checks.
  • Apply the same behavior to SQLite and MySQL.
  • Add low-level and integration tests.
  • Document result-row lifetime rules.
  • Preserve existing interfaces.

Suggested files

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

Acceptance criteria

  • row() before the first successful next() throws DBError.
  • row() after result exhaustion throws DBError.
  • Accessing column index equal to cols() throws DBError.
  • SQLite and MySQL expose consistent behavior.
  • Valid query iteration remains unchanged.
  • Existing public APIs remain source-compatible.

Non-goals

This issue does not include:

  • column lookup by name;
  • typed optional getters;
  • random-access result sets;
  • ORM row mapping.

Suggested labels

  • scope:db
  • type:enhancement
  • tests
  • help wanted
  • status:accepted

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededscope:dbDatabase driversstatus:acceptedApproved, plannedtestsTests, CI coverage and validationtype:enhancementImprove existing behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions