Skip to content

feat(orm): add explicit repository upsert support #497

Description

@GaspardKirira

Summary

Add insert-or-update support with backend-specific SQL generation.

Upsert behavior must remain explicit because SQLite, MySQL, and PostgreSQL use different syntax.

Current behavior

Repositories expose separate create and update operations.

Applications must manually detect conflicts or write backend-specific SQL.

Expected behavior

The ORM must expose a portable upsert request and delegate SQL generation to a dialect-aware implementation.

Conflict targets must be explicit.

Scope

  • Define an upsert request.
  • Define conflict columns.
  • Define update fields.
  • Add SQLite generation.
  • Add MySQL generation.
  • Add PostgreSQL generation when the DB driver is available.
  • Validate identifiers.
  • Bind all values safely.
  • Define generated-ID behavior.
  • Add integration tests.
  • Preserve existing repository operations.

Suggested files

  • modules/orm/include/vix/orm/Upsert.hpp
  • modules/orm/include/vix/orm/Repository.hpp
  • modules/orm/src/...
  • modules/orm/tests/repository_upsert_test.cpp

Acceptance criteria

  • SQLite conflict handling works.
  • MySQL duplicate-key handling works.
  • Conflict columns are explicit.
  • Update fields are explicit.
  • Values remain parameterized.
  • Unsupported dialects fail clearly.
  • Existing create and update operations remain unchanged.

Non-goals

This issue does not include:

  • automatic conflict-column discovery;
  • merge of relationships;
  • bulk upsert;
  • retrying transaction conflicts.

Suggested labels

  • scope:orm
  • type:feature
  • tests
  • help wanted
  • status:accepted

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions