Skip to content

SQL Query Views#1481

Draft
trueqbit wants to merge 46 commits intodevfrom
experimental/sql-view
Draft

SQL Query Views#1481
trueqbit wants to merge 46 commits intodevfrom
experimental/sql-view

Conversation

@trueqbit
Copy link
Copy Markdown
Collaborator

@trueqbit trueqbit commented Apr 26, 2026

Views in SQL are virtual tables based on the result-set of a SELECT statement, also known as query views.

With sqlite_orm, views are defined using make_view() which leverages C++ reflection to automatically map columns from the SELECT statement to struct fields.

SQL views created with make_view() don't require explicit column definitions - the columns are automatically determined from the view's object type through reflection.

struct HighEarner {
    int64 id;
    std::string name;
    double salary;
};

make_view<HighEarner>(
    "high_earners",
    select(columns(&Employee::id, &Employee::name, &Employee::salary), where(c(&Employee::salary) > 0.0)))

Resolves the following discussions and tickets:

Note: There are no tests executed yet as no github action platform (Linux Ubuntu) provides gcc-16 binaries. However I tested the "view" example and unit tests in a local Windows Subsystem for Linux (WSL) environment.

trueqbit added 30 commits June 7, 2024 19:51
`c_str()` expresses the intent better than `data()`
Note: C++ reflection-based approach isn't implemented yet.
* Removed `serializer_context_builder`, which is now entirely replaced by `obtain_db_objects()`.
* Renamed serializer context flag variables.
* Factored out common functionality into common base classes and mixins.
* Renamed structures.
* Split CTE table class into its own structure, effectively decoupling it from a table DBO.
It is better to include configuration header files of third-party libraries (including SQLite) in the library's configuration header than in the umbrella header.
clang/gcc use an intrinsic compiler builtin [`__builtin_offsetof`], which doesn't work the way we need.
@trueqbit trueqbit linked an issue Apr 28, 2026 that may be closed by this pull request
@trueqbit trueqbit marked this pull request as ready for review April 28, 2026 19:38
@trueqbit trueqbit requested a review from fnc12 April 28, 2026 19:38
@trueqbit trueqbit marked this pull request as draft April 30, 2026 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using views

1 participant