From 5e52a4da462bd18fac6a7515b9e159ac71855238 Mon Sep 17 00:00:00 2001 From: rbock Date: Sun, 25 Dec 2016 21:25:01 +0100 Subject: [PATCH 1/3] Added a few auto alias tests --- include/sqlpp11/not_in.h | 2 +- test_serializer/As.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/sqlpp11/not_in.h b/include/sqlpp11/not_in.h index 80676e64..eae91869 100644 --- a/include/sqlpp11/not_in.h +++ b/include/sqlpp11/not_in.h @@ -44,7 +44,7 @@ namespace sqlpp template struct _member_t { - T in; + T not_in; }; }; }; diff --git a/test_serializer/As.cpp b/test_serializer/As.cpp index 76c4dcfa..709148c1 100644 --- a/test_serializer/As.cpp +++ b/test_serializer/As.cpp @@ -44,5 +44,12 @@ int As(int, char* []) compare(__LINE__, (count(foo.omega) - bar.alpha).as(cheese), "(COUNT(tab_foo.omega)-tab_bar.alpha) AS cheese"); compare(__LINE__, (count(foo.omega) - uint32_t(17)).as(cheese), "(COUNT(tab_foo.omega)-17) AS cheese"); + // Auto alias + compare(__LINE__, select(max(bar.alpha)), "SELECT MAX(tab_bar.alpha) AS max_"); + compare(__LINE__, select(max(bar.alpha).as(cheese)), "SELECT MAX(tab_bar.alpha) AS cheese"); + compare(__LINE__, select(max(bar.alpha)).from(bar).unconditionally().as(cheese), + "(SELECT MAX(tab_bar.alpha) AS max_ FROM tab_bar) AS cheese"); + compare(__LINE__, select(max(bar.alpha)).from(bar).unconditionally().as(cheese).max, "cheese.max_"); + return 0; } From 3baa513a07d30e6ba33eb599646426c9cd1ff99b Mon Sep 17 00:00:00 2001 From: mlimber Date: Sat, 7 Jan 2017 00:16:50 -0500 Subject: [PATCH 2/3] Allow nested namespaces on the command line Allow the generator to handle nested namespaces like: ddl2cpp table.ddl table My::Nested::Namespaces --- scripts/ddl2cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/ddl2cpp b/scripts/ddl2cpp index c93ac643..208d3369 100755 --- a/scripts/ddl2cpp +++ b/scripts/ddl2cpp @@ -233,6 +233,7 @@ else: if warnOnParse: print(parseError + '. Continuing [-no-warn-on-parse]') +nsList = namespace.split('::') # PROCESS DDL tableCreations = ddl.parseFile(pathToDdl) @@ -246,8 +247,9 @@ print('#include <' + INCLUDE + '/table.h>', file=header) print('#include <' + INCLUDE + '/data_types.h>', file=header) print('#include <' + INCLUDE + '/char_sequence.h>', file=header) print('', file=header) -print('namespace ' + namespace, file=header) -print('{', file=header) +for ns in nsList: + print('namespace ' + ns, file=header) + print('{', file=header) DataTypeError = False for create in tableCreations: sqlTableName = create.tableName @@ -322,7 +324,8 @@ for create in tableCreations: print(' };', file=header) print(' };', file=header) -print('}', file=header) +for ns in nsList: + print('} // namespace ' + ns, file=header) print('#endif', file=header) if (DataTypeError): print("Error: unsupported datatypes." ) From 3d28a92a6d436c5ed1f26d170cdd49327e7095e1 Mon Sep 17 00:00:00 2001 From: rbock Date: Sat, 28 Jan 2017 11:28:54 +0100 Subject: [PATCH 3/3] Fixed detection of NULL in text results --- include/sqlpp11/data_types/text/result_field.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sqlpp11/data_types/text/result_field.h b/include/sqlpp11/data_types/text/result_field.h index 80f16632..0c0f0d0b 100644 --- a/include/sqlpp11/data_types/text/result_field.h +++ b/include/sqlpp11/data_types/text/result_field.h @@ -47,7 +47,7 @@ namespace sqlpp size_t len{}; target._bind_text_result(index, &text, &len); this->_value = {text, len}; - this->_is_null = (len == 0); + this->_is_null = (text == nullptr); } template @@ -57,7 +57,7 @@ namespace sqlpp size_t len{}; target._post_bind_text_result(index, &text, &len); this->_value = {text, len}; - this->_is_null = (len == 0); + this->_is_null = (text == nullptr); } };