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); } }; 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/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." ) 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; }