removed class query and moved their static methods to simple functions

This commit is contained in:
2026-03-26 09:34:32 +01:00
parent 3fc08fb7ff
commit fedce38270
23 changed files with 283 additions and 286 deletions
+9 -9
View File
@@ -190,7 +190,7 @@ int main() {
mc.date_of_birth = "19.8.1954";
mc.year_of_birth = 1954;
mc.distinguished = true;
auto insert_authors_sql = query::insert()
auto insert_authors_sql = insert()
.into(AUTHOR)
.values(mc)
.execute(*c);
@@ -201,7 +201,7 @@ int main() {
return 0;
}
auto authors_result = query::select(AUTHOR)
auto authors_result = select(AUTHOR)
.from(AUTHOR)
.fetch_all(*c);
@@ -243,8 +243,8 @@ int main() {
// .values( {3, "Misery", mc.id, 1984} )
// .execute();
//
// auto select_books_sql = query::select( BOOK, {AUTHOR.last_name} )
auto select_books_sql = query::select({BOOK.id, BOOK.title, BOOK.author_id, BOOK.published_in, AUTHOR.last_name})
// auto select_books_sql = select( BOOK, {AUTHOR.last_name} )
auto select_books_sql = select({BOOK.id, BOOK.title, BOOK.author_id, BOOK.published_in, AUTHOR.last_name})
.from(BOOK)
.join_left(AUTHOR)
.on(BOOK.author_id == AUTHOR.id)
@@ -288,17 +288,17 @@ int main() {
//
// std::cout << "SQL: " << drop_authors_sql << "\n";
//
auto res = query::select({PAYLOAD.id})
auto res = select({PAYLOAD.id})
.from(PAYLOAD)
.join_left(JOB)
.on(JOB.payload == PAYLOAD.id)
.where(
in(PAYLOAD.id, query::select({JOB.state})
in(PAYLOAD.id, select({JOB.state})
.from(JOB)
.where(JOB.state == job::job_state::Running).compile(c->dialect())
.where(JOB.state == job::job_state::Running)
) &&
in(PAYLOAD.id, query::select({TEMPORARY_TABLE.id})
.from(TEMPORARY_TABLE).compile(c->dialect())
in(PAYLOAD.id, select({TEMPORARY_TABLE.id})
.from(TEMPORARY_TABLE)
)
).compile(c->dialect());
// // .fetch_value<unsigned long>();
+11 -11
View File
@@ -126,7 +126,7 @@ const auto statement = QString( "SELECT %5.%6, %1.%2 FROM %3 %1, %4 %5 WHERE %1.
const auto payloads = PAYLOAD.as( "payloads" );
const auto tasks = TASK.as( "tasks" );
const auto stmt1 = query:: query::select( { tasks.payload, payloads.id } )
const auto stmt1 = query::select( { tasks.payload, payloads.id } )
.from( tasks, payloads )
.where ( payloads.id == tasks.payload )
.str( conn->dialect() );
@@ -159,12 +159,12 @@ const auto statement = QString( "SELECT %5.%6, %1.%2 FROM %3 %1, %4 %5 WHERE %1.
const auto iPT = ID_PAYLOAD.as("iPT");
const auto pT = PAYLOAD.as("pT");
const auto stmt2 = query::query::select({ iPT.payload_id })
const auto stmt2 = query::select({ iPT.payload_id })
.from( iPT )
.join_left( pT ).on( iPT.id == pT.id )
.where(
in( pT.id, query::query::select({ JOB.payload }).from( JOB ).where( JOB.state == _) ) &&
in( iPT.payload_id, query::query::select({ temp_id_col }).from( temporary ) )
in( pT.id, query::select({ JOB.payload }).from( JOB ).where( JOB.state == _) ) &&
in( iPT.payload_id, query::select({ temp_id_col }).from( temporary ) )
)
.str( conn->dialect() );
@@ -178,13 +178,13 @@ const auto statement = QString( "SELECT %5.%6, %1.%2 FROM %3 %1, %4 %5 WHERE %1.
// .arg( LoginHistory::staticSqlMetaInfo().columnName( LoginHistory::Attributes::failReasonSqlAttributeId() ) )
// .arg( LoginHistory::staticSqlMetaInfo().columnName( LoginHistory::Attributes::idAttributeId() ) );
const auto q = query::query::select({LOGIN_HISTORY.client, query::maximum(LOGIN_HISTORY.login_time).as( "lastSuccessfulLogin" ) } )
const auto q = query::select({LOGIN_HISTORY.client, query::maximum(LOGIN_HISTORY.login_time).as( "lastSuccessfulLogin" ) } )
.from( LOGIN_HISTORY )
.where( LOGIN_HISTORY.fail_reason == _ )
.group_by( LOGIN_HISTORY.client );
// .as_table("ll");
const auto stmt3 = query::query::select({ LOGIN_HISTORY.client })
const auto stmt3 = query::select({ LOGIN_HISTORY.client })
.from( LOGIN_HISTORY )
.join_left(q/*, "ll"*/ )
.on( LOGIN_HISTORY.client == "ll.client" )
@@ -288,11 +288,11 @@ const auto statement = QString( "SELECT %5.%6, %1.%2 FROM %3 %1, %4 %5 WHERE %1.
// )
// )
const auto stmt4 = query::query::select({JOB.id})
const auto stmt4 = query::select({JOB.id})
.from(JOB)
.where( JOB.id > _ && JOB.name == _ && in( JOB.payload, query::query::select({PAYLOAD.id}).from(PAYLOAD).where(
in( PAYLOAD.id, query::query::select({ID_PAYLOAD.id}).from(ID_PAYLOAD).where(
in( ID_PAYLOAD.id, query::query::select({temp_id_col}).from(temporary))
.where( JOB.id > _ && JOB.name == _ && in( JOB.payload, query::select({PAYLOAD.id}).from(PAYLOAD).where(
in( PAYLOAD.id, query::select({ID_PAYLOAD.id}).from(ID_PAYLOAD).where(
in( ID_PAYLOAD.id, query::select({temp_id_col}).from(temporary))
) ) ) ) )
.str( conn->dialect() );
@@ -307,7 +307,7 @@ const auto statement = QString( "SELECT %5.%6, %1.%2 FROM %3 %1, %4 %5 WHERE %1.
// WHERE nj.ID > ?
// AND nj.TYPE = ?;
const auto stmt5 = query::query::select({JOB.id})
const auto stmt5 = query::select({JOB.id})
.from(JOB)
.join_left(PAYLOAD).on(JOB.payload == PAYLOAD.id)
.join_left(ID_PAYLOAD).on(PAYLOAD.id == ID_PAYLOAD.id)