moved query macro generated class to namespace matador::query::meta
This commit is contained in:
+21
-18
@@ -3,6 +3,7 @@
|
||||
#include "matador/sql/query_macro.hpp"
|
||||
|
||||
#include "matador/query/criteria.hpp"
|
||||
#include "matador/query/query.hpp"
|
||||
|
||||
#include "matador/object/object_ptr.hpp"
|
||||
#include "matador/object/repository.hpp"
|
||||
@@ -143,20 +144,21 @@ struct matador::utils::data_type_traits<job::job_mode, void> {
|
||||
}
|
||||
};
|
||||
|
||||
QUERY_HELPER( authors, id, first_name, last_name, date_of_birth, year_of_birth, distinguished )
|
||||
QUERY_HELPER( authors, AUTHOR, id, first_name, last_name, date_of_birth, year_of_birth, distinguished )
|
||||
|
||||
QUERY_HELPER( books, id, author_id, title, published_in )
|
||||
QUERY_HELPER( books, BOOK, id, author_id, title, published_in )
|
||||
|
||||
QUERY_HELPER( job, id, payload, type, description, state, mode )
|
||||
QUERY_HELPER( job, JOB, id, payload, type, description, state, mode )
|
||||
|
||||
QUERY_HELPER( payload, id )
|
||||
QUERY_HELPER( payload, PAYLOAD, id )
|
||||
|
||||
QUERY_HELPER( temporary_table, id );
|
||||
QUERY_HELPER( temporary_table, TEMPORARY_TABLE, id );
|
||||
|
||||
int main() {
|
||||
using namespace matador::sql;
|
||||
using namespace matador::object;
|
||||
using namespace matador::utils;
|
||||
using namespace matador::query::meta;
|
||||
|
||||
const std::string env_var{"MATADOR_BACKENDS_PATH"};
|
||||
|
||||
@@ -233,19 +235,20 @@ int main() {
|
||||
// .values( {3, "Misery", mc.id, 1984} )
|
||||
// .execute();
|
||||
//
|
||||
// auto select_books_sql = c.query( s )
|
||||
// .select( qh::books.columns, {qh::authors.last_name} )
|
||||
// .from( qh::books )
|
||||
// .join_left( qh::authors )
|
||||
// .on( qh::books.author_id == qh::authors.id )
|
||||
// .where( qh::books.published_in < 2008 && qh::authors.last_name == "King" )
|
||||
// .group_by( qh::books.published_in )
|
||||
// .order_by( qh::books.title ).asc()
|
||||
// .limit( 5 )
|
||||
// .offset( 2 )
|
||||
// .fetch_all();
|
||||
//
|
||||
// for (const auto& r: select_books_sql) { std::cout << "R: " << r.at( qh::books.title ) << ", " << r.at( qh::authors.last_name ) << "\n"; }
|
||||
auto select_books_sql = matador::query::query::select( BOOK, {AUTHOR.last_name} )
|
||||
.from( BOOK )
|
||||
.join_left( AUTHOR )
|
||||
.on( BOOK.author_id == AUTHOR.id )
|
||||
.where( BOOK.published_in < 2008 && AUTHOR.last_name == "King" )
|
||||
.group_by( BOOK.published_in )
|
||||
.order_by( BOOK.title ).asc()
|
||||
.limit( 5 )
|
||||
.offset( 2 )
|
||||
.fetch_all(c);
|
||||
|
||||
for (const auto& r: *select_books_sql) {
|
||||
std::cout << "R: " << r.at( BOOK.title ) << ", " << r.at( AUTHOR.last_name ) << "\n";
|
||||
}
|
||||
// // SELECT book.title, book.id, book.author_id, book.published_in, author.name
|
||||
// // FROM book
|
||||
// // INNER JOIN author ON book.author_id = author.id
|
||||
|
||||
Reference in New Issue
Block a user