Skip to content

test(orm): add std::any to DbValue conversion tests #475

Description

@GaspardKirira

Summary

Add comprehensive tests for any_to_dbvalue_or_throw() and related field-binding helpers.

Mapper values cross the ORM boundary through std::any, so conversion behavior must remain predictable and portable.

Current behavior

The ORM compatibility layer supports conversion from:

  • empty std::any;
  • std::nullptr_t;
  • vix::db::DbValue;
  • signed and unsigned integer types;
  • bool;
  • float;
  • double;
  • std::string;
  • std::string_view;
  • C strings;
  • vix::db::Blob.

Unsupported types produce DBError.

These conversions are not covered by automated tests.

Expected behavior

Every documented input type must convert to the expected DbValue alternative without silent narrowing or lifetime errors.

Unsupported types must fail with a clear ORM diagnostic.

Scope

  • Test empty std::any.
  • Test std::nullptr_t.
  • Test direct DbValue.
  • Test signed integer types.
  • Test unsigned integer types.
  • Test bool.
  • Test float and double.
  • Test std::string.
  • Test std::string_view.
  • Test const char* and char*.
  • Test null C-string pointers.
  • Test Blob.
  • Test unsupported types.
  • Test field_to_dbvalue_or_throw().
  • Test bind_field_values().

Suggested files

  • modules/orm/tests/dbvalue_conversion_test.cpp
  • modules/orm/include/vix/orm/db_compat.hpp

Acceptance criteria

  • Every documented conversion has test coverage.
  • Signed values preserve their sign.
  • Unsigned values do not silently become negative.
  • String-view data is copied safely.
  • Null C-string pointers produce empty strings according to current behavior.
  • Binary values preserve embedded zero bytes.
  • Unsupported types throw vix::db::DBError.
  • Existing public APIs remain unchanged.

Non-goals

This issue does not include:

  • replacing std::any;
  • adding date and time conversions;
  • adding enum conversions;
  • changing DbValue.

Suggested labels

  • scope:orm
  • type:ci
  • tests
  • good first issue
  • status:ready

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomersscope:ormORM layerstatus:readyIssue is fully specified and ready for implementationtestsTests, CI coverage and validationtype:ciCI, tests, or tooling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions