Skip to content

Commit

Permalink
Merge pull request #1339 from fnc12/dbstat_table_reference
Browse files Browse the repository at this point in the history
Provide a table reference for the "dbstat" eponymous virtual table
  • Loading branch information
trueqbit authored Jul 23, 2024
2 parents 8c15e4b + fcf86d1 commit 37c2ac6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions dev/eponymous_vtabs/dbstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "../schema/column.h"
#include "../schema/table.h"
#include "../column_pointer.h"

namespace sqlite_orm {
#ifdef SQLITE_ENABLE_DBSTAT_VTAB
Expand Down Expand Up @@ -35,5 +36,9 @@ namespace sqlite_orm {
make_column("pgoffset", &dbstat::pgoffset),
make_column("pgsize", &dbstat::pgsize));
}

#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
inline constexpr orm_table_reference auto dbstat_table = c<dbstat>();
#endif
#endif // SQLITE_ENABLE_DBSTAT_VTAB
}
6 changes: 6 additions & 0 deletions include/sqlite_orm/sqlite_orm.h
Original file line number Diff line number Diff line change
Expand Up @@ -23768,6 +23768,8 @@ namespace sqlite_orm {

// #include "../schema/table.h"

// #include "../column_pointer.h"

namespace sqlite_orm {
#ifdef SQLITE_ENABLE_DBSTAT_VTAB
struct dbstat {
Expand Down Expand Up @@ -23796,6 +23798,10 @@ namespace sqlite_orm {
make_column("pgoffset", &dbstat::pgoffset),
make_column("pgsize", &dbstat::pgsize));
}

#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
inline constexpr orm_table_reference auto dbstat_table = c<dbstat>();
#endif
#endif // SQLITE_ENABLE_DBSTAT_VTAB
}

Expand Down
4 changes: 4 additions & 0 deletions tests/builtin_tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ TEST_CASE("builtin tables") {

auto dbstatRows = storage.get_all<dbstat>();
std::ignore = dbstatRows;

#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
dbstatRows = storage.get_all<dbstat_table>();
#endif
}
#endif // SQLITE_ENABLE_DBSTAT_VTAB
}
4 changes: 2 additions & 2 deletions tests/prepared_statement_tests/get_all.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ TEST_CASE("Prepared get all") {
}
#ifdef SQLITE_ORM_WITH_CPP20_ALIASES
SECTION("from table reference") {
constexpr auto schema = c<sqlite_master>();
auto statement = storage.prepare(get_all<schema>(where(schema->*&sqlite_master::type == "table")));
auto statement =
storage.prepare(get_all<sqlite_master_table>(where(sqlite_master_table->*&sqlite_master::type == "table")));
auto str = storage.dump(statement);
testSerializing(statement);
}
Expand Down

0 comments on commit 37c2ac6

Please sign in to comment.