Skip to content

feat(orm): add a small explicit SQL query DSL #511

Description

@GaspardKirira

Summary

Extend QueryBuilder with common structured SQL operations while preserving raw SQL access.

The builder should remain lightweight and close to SQL rather than becoming a reflection-based ORM language.

Current behavior

QueryBuilder provides only raw fragment accumulation and parameter storage.

Users manually manage spaces, clauses, identifiers, and placeholders.

Expected behavior

The builder should support structured construction of common SQL statements using validated identifiers and bound values.

Scope

  • Add SELECT column construction.
  • Add FROM construction.
  • Add WHERE filters.
  • Add ORDER BY.
  • Add LIMIT and OFFSET.
  • Add INSERT construction.
  • Add UPDATE construction.
  • Add DELETE construction.
  • Reuse identifier validation.
  • Preserve raw().
  • Add unit and integration tests.
  • Keep generated SQL deterministic.

Suggested files

  • modules/orm/include/vix/orm/QueryBuilder.hpp
  • modules/orm/src/QueryBuilder.cpp
  • modules/orm/tests/query_builder_dsl_test.cpp

Acceptance criteria

  • Existing raw builder usage remains compatible.
  • Structured SELECT generation works.
  • Structured INSERT generation works.
  • Structured UPDATE generation works.
  • Structured DELETE generation works.
  • Values remain separate from SQL.
  • Invalid identifiers are rejected.
  • SQL output is deterministic.

Non-goals

This issue does not include:

  • runtime model reflection;
  • automatic joins from entity definitions;
  • SQL parsing;
  • replacing direct SQL usage.

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