From e271e3e4fb86419c06dbe0d33dfc3aef2b23cc1a Mon Sep 17 00:00:00 2001 From: Roland Bock Date: Sun, 24 Apr 2016 17:36:36 +0200 Subject: [PATCH 01/12] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ed9c3a23..bf637473 100644 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ sqlpp11 requires a certain api in order to connect with the database, see databa * MySQL: https://github.com/rbock/sqlpp11-connector-mysql * Sqlite3: https://github.com/rbock/sqlpp11-connector-sqlite3 * PostgreSQL: https://github.com/matthijs/sqlpp11-connector-postgresql + * ODBC: https://github.com/Erroneous1/sqlpp11-connector-odbc (experimental) To demonstrate that sqlpp11 can work with other backends as well, here is an experimental backend for structs in standard containers: From f41770dbe23e9427b0eaef34868ef0477927ae61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20D=C3=A1vid?= Date: Sun, 1 May 2016 20:01:33 +0200 Subject: [PATCH 02/12] Added FindHinnatDate.cmake to prevent usage of preset paths Howard Hinnant's date and time library is found using a cmake Find-module. Commit 377fbc8958b26cb2c0151b3068bce07dff3811ec was reverted to ensure that the exported target has the correct properties. --- CMakeLists.txt | 23 +++----- cmake/Modules/FindHinnantDate.cmake | 83 +++++++++++++++++++++++++++++ cmake/Sqlpp11Config.cmake | 5 ++ 3 files changed, 95 insertions(+), 16 deletions(-) create mode 100644 cmake/Modules/FindHinnantDate.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a5924e4..d7767a8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ # Copyright (c) 2013-2016, Roland Bock +# Copyright (c) 2016 Christian Dávid # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, @@ -27,27 +28,18 @@ project(sqlpp11 VERSION 0.1 LANGUAGES CXX) enable_testing() +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/") +find_package(HinnantDate REQUIRED) + add_library(sqlpp11 INTERFACE) -set(DATE_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../date" CACHE FILEPATH "Path to Howard Hinnant's date library") - -if(NOT EXISTS ${DATE_INCLUDE_DIR}/date.h) - message(SEND_ERROR "Can't find file date.h and cannot compile date_test/date_test.cpp") - message("Can't find date.h in ${DATE_INCLUDE_DIR} ") - message("Please either") - message(" - git clone https://github.com/howardhinnant/date ${DATE_INCLUDE_DIR}") - message(" - download and unzip a current version from https://github.com/howardhinnant/date to ${DATE_INCLUDE_DIR}") - message(" - set DATE_INCLUDE_DIR to point to the dir containing date.h from the date library") - message("") -endif() +target_link_libraries(sqlpp11 INTERFACE HinnantDate::Date) target_include_directories(sqlpp11 INTERFACE - $ $ $ ) -if (NOT DEFINED MSVC) target_compile_features(sqlpp11 INTERFACE cxx_alias_templates cxx_auto_type @@ -69,7 +61,6 @@ target_compile_features(sqlpp11 INTERFACE cxx_template_template_parameters cxx_variadic_templates ) -endif () install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/sqlpp11" DESTINATION include @@ -106,13 +97,13 @@ install(EXPORT Sqlpp11Targets install( FILES - cmake/Sqlpp11Config.cmake + "cmake/Sqlpp11Config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake/Sqlpp11ConfigVersion.cmake" + "cmake/Modules/FindHinnantDate.cmake" DESTINATION ${ConfigPackageLocation} ) - add_subdirectory(tests) add_subdirectory(test_types) add_subdirectory(test_serializer) diff --git a/cmake/Modules/FindHinnantDate.cmake b/cmake/Modules/FindHinnantDate.cmake new file mode 100644 index 00000000..0d44df51 --- /dev/null +++ b/cmake/Modules/FindHinnantDate.cmake @@ -0,0 +1,83 @@ +#.rst: +# FindHinnantDate +# --------------- +# +# This module finds Howard Hinnant's date and time library for C++11 and beyond +# See https://github.com/HowardHinnant/date for details. +# +# This will define the following variables:: +# +# HinnantDate_FOUND - True if the system has the library +# HinnantDate_INCLUDE_DIR - The directory which includes the header +# +# and the following imported targets:: +# +# HinnantDate::Date - The target to use date.h +# +# The target will enable the required C++11 standard in your compiler. You can +# use any later standard but you have to enable them explicitly. + +# Copyright (c) 2016 Christian Dávid +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +cmake_minimum_required(VERSION 3.1) + +find_file(HinnantDate_INCLUDE_FILE + date.h + HINTS ${HinnantDate_INCLUDE_DIR} +) + +if (HinnantDate_INCLUDE_FILE) + # Validate that correct file is found + file(STRINGS ${HinnantDate_INCLUDE_FILE} check_result + LIMIT_COUNT 1 + REGEX "^ *// Copyright [(]c[)] 2015.* Howard Hinnant *$" + ) + + if("${check_result}" STREQUAL "") + message(STATUS "FindHinnantDate: Rejecting found '${HinnantDate_INCLUDE_FILE}', it seems to be a name twin.") + unset(HinnantDate_INCLUDE_FILE) + else() + # Check succeeded, create target + get_filename_component(HinnantDate_INCLUDE_DIR "${HinnantDate_INCLUDE_FILE}" DIRECTORY CACHE) + if(NOT TARGET HinnantDate::Date) + add_library(HinnantDate::Date INTERFACE IMPORTED) + set_target_properties(HinnantDate::Date PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${HinnantDate_INCLUDE_DIR}" + INTERFACE_COMPILE_FEATURES "cxx_auto_type;cxx_static_assert;cxx_decltype;cxx_alias_templates;cxx_strong_enums" +# Due to cmake restrictions the standard cannot be set directly to interface imported targets. Instead required compile +# features are set (list maybe incomplete). Please note that this list shall be a minimal set of required features. +# CXX_STANDARD 11 +# CXX_STANDARD_REQUIRED true + ) + endif() + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(HinnantDate + REQUIRED_VARS + HinnantDate_INCLUDE_DIR +) diff --git a/cmake/Sqlpp11Config.cmake b/cmake/Sqlpp11Config.cmake index 033d7f4b..015ab4b6 100644 --- a/cmake/Sqlpp11Config.cmake +++ b/cmake/Sqlpp11Config.cmake @@ -23,4 +23,9 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + +include(CMakeFindDependencyMacro) +find_dependency(HinnantDate REQUIRED) + include("${CMAKE_CURRENT_LIST_DIR}/Sqlpp11Targets.cmake") From f32dd7a65c6e1da6a5e50784cb78e964724ebb56 Mon Sep 17 00:00:00 2001 From: strangeqargo <“strangeqargo@gmail.com”> Date: Tue, 3 May 2016 15:42:02 +0300 Subject: [PATCH 03/12] -m --- scripts/ddl2cpp | 79 ++++++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/scripts/ddl2cpp b/scripts/ddl2cpp index c4d41584..87fccc4f 100755 --- a/scripts/ddl2cpp +++ b/scripts/ddl2cpp @@ -34,10 +34,12 @@ import pprint from pyparsing import CaselessLiteral, Literal, SkipTo, restOfLine, oneOf, ZeroOrMore, Optional, Combine, Suppress, \ WordStart, WordEnd, Word, alphas, alphanums, nums, QuotedString, nestedExpr, MatchFirst, OneOrMore, delimitedList, Or, Group -def usage(): - print('Usage: ddl2cpp [-no-timestamp-warning] ') -if len(sys.argv) not in (4,5): +def usage(): + print('Usage: ddl2cpp [-no-timestamp-warning] \ + ') + +if len(sys.argv) not in (4, 5): usage() sys.exit(1) @@ -63,16 +65,19 @@ def get_include_guard_name(namespace, inputfile): val = re.sub("[^A-Za-z]+", "_", namespace + '_' + os.path.basename(inputfile)) return val.upper() + def repl_func(m): - if (m.group(1) == '_'): + if m.group(1) == '_': return m.group(2).upper() else: return m.group(1) + m.group(2).upper() -def toClassName(s): + +def to_class_name(s): return re.sub("(^|\s|[_0-9])(\S)", repl_func, s) -def toMemberName(s): + +def to_member_name(s): return re.sub("(\s|_|[0-9])(\S)", repl_func, s) @@ -80,16 +85,19 @@ def toMemberName(s): def ddlWord(string): return WordStart(alphanums + "_") + CaselessLiteral(string) + WordEnd(alphanums + "_") -ddlString = Or([QuotedString("'"), QuotedString("\"", escQuote='""'), QuotedString("`")]) +def ddlFunctionWord(string): + return CaselessLiteral(string) + OneOrMore("(") + ZeroOrMore(" ") + OneOrMore(")") + +ddlString = Or([QuotedString("'"), QuotedString("\"", escQuote='""'), QuotedString("`")]) negativeSign = Literal('-') -ddlNum = Combine(Optional(negativeSign) + Word(nums + ".")) -ddlTerm = Word(alphas, alphanums + "_$") -ddlName = Or([ddlTerm, ddlString]) +ddlNum = Combine(Optional(negativeSign) + Word(nums + ".")) +ddlTerm = Word(alphas, alphanums + "_$") +ddlName = Or([ddlTerm, ddlString]) ddlArguments = "(" + delimitedList(Or([ddlString, ddlTerm, ddlNum])) + ")" ddlNotNull = Group(ddlWord("NOT") + ddlWord("NULL")).setResultsName("notNull") -ddlDefaultValue = ddlWord("DEFAULT").setResultsName("hasDefaultValue"); -ddlAutoValue = ddlWord("AUTO_INCREMENT").setResultsName("hasAutoValue"); -ddlColumnComment = Group(ddlWord("COMMENT") + ddlString).setResultsName("comment") +ddlDefaultValue = ddlWord("DEFAULT").setResultsName("hasDefaultValue") +ddlAutoValue = ddlWord("AUTO_INCREMENT").setResultsName("hasAutoValue") +ddlColumnComment = Group(ddlWord("COMMENT") + ddlString).setResultsName("comment") ddlConstraint = Or([ ddlWord("CONSTRAINT"), ddlWord("PRIMARY"), @@ -98,7 +106,9 @@ ddlConstraint = Or([ ddlWord("INDEX"), ddlWord("UNIQUE"), ]) -ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst([ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlTerm, ddlNum, ddlColumnComment, ddlString, ddlArguments]))) +ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst( + [ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlFunctionWord("NOW"), ddlTerm, ddlNum, ddlColumnComment, ddlString, + ddlArguments]))) createTable = Group(ddlWord("CREATE") + ddlWord("TABLE") + ddlName.setResultsName("tableName") + "(" + Group(delimitedList(ddlColumn)).setResultsName("columns") + ")").setResultsName("create") @@ -125,12 +135,12 @@ types = { 'boolean': 'boolean', 'double': 'floating_point', 'float': 'floating_point', - 'date' : 'day_point', - 'datetime' : 'time_point', - 'timestamp' : 'time_point', - 'enum' : 'text', # MYSQL - 'set' : 'text', # MYSQL - } + 'date': 'day_point', + 'datetime': 'time_point', + 'timestamp': 'time_point', + 'enum': 'text', # MYSQL + 'set': 'text', # MYSQL +} # PROCESS DDL @@ -147,11 +157,11 @@ print('#include <' + INCLUDE + '/char_sequence.h>', file=header) print('', file=header) print('namespace ' + namespace, file=header) print('{', file=header) -DataTypeError = False; +DataTypeError = False for create in tableCreations: sqlTableName = create.tableName - tableClass = toClassName(sqlTableName) - tableMember = toMemberName(sqlTableName) + tableClass = to_class_name(sqlTableName) + tableMember = to_member_name(sqlTableName) tableNamespace = tableClass + '_' tableTemplateParameters = tableClass print(' namespace ' + tableNamespace, file=header) @@ -160,9 +170,9 @@ for create in tableCreations: if column.isConstraint: continue sqlColumnName = column[0] - columnClass = toClassName(sqlColumnName) + columnClass = to_class_name(sqlColumnName) tableTemplateParameters += ',\n ' + tableNamespace + '::' + columnClass - columnMember = toMemberName(sqlColumnName) + columnMember = to_member_name(sqlColumnName) sqlColumnType = column[1].lower() if sqlColumnType == 'timestamp' and timestampWarning: print("Warning: timestamp is mapped to sqlpp::time_point like datetime") @@ -184,22 +194,22 @@ for create in tableCreations: print(' };', file=header) print(' };', file=header) try: - traitslist = [NAMESPACE + '::' + types[sqlColumnType]]; + traitslist = [NAMESPACE + '::' + types[sqlColumnType]] except KeyError as e: print ('Error: datatype "' + sqlColumnType + '"" is not supported.') DataTypeError = True requireInsert = True if column.hasAutoValue: - traitslist.append(NAMESPACE + '::tag::must_not_insert'); - traitslist.append(NAMESPACE + '::tag::must_not_update'); + traitslist.append(NAMESPACE + '::tag::must_not_insert') + traitslist.append(NAMESPACE + '::tag::must_not_update') requireInsert = False if not column.notNull: - traitslist.append(NAMESPACE + '::tag::can_be_null'); + traitslist.append(NAMESPACE + '::tag::can_be_null') requireInsert = False if column.hasDefaultValue: requireInsert = False if requireInsert: - traitslist.append(NAMESPACE + '::tag::require_insert'); + traitslist.append(NAMESPACE + '::tag::require_insert') print(' using _traits = ' + NAMESPACE + '::make_traits<' + ', '.join(traitslist) + '>;', file=header) print(' };', file=header) print(' }', file=header) @@ -223,10 +233,11 @@ for create in tableCreations: print('}', file=header) print('#endif', file=header) -if (DataTypeError): +if DataTypeError: print("Error: unsupported datatypes." ) print("Possible solutions:") - print("A) Implement this datatype (examples: sqlpp11/data_types)" ) - print("B) Extend/upgrade ddl2cpp (edit types map)" ) + print("A) Implement this datatype (examples: sqlpp11/data_types)") + print("B) Extend/upgrade ddl2cpp (edit types map)") print("C) Raise an issue on github" ) - sys.exit(10) #return non-zero error code, we might need it for automation + sys.exit(10) # return non-zero error code, we might need it for automation + From 94945cc9502599f7896a1701666c1d8601207a92 Mon Sep 17 00:00:00 2001 From: strangeqargo <“strangeqargo@gmail.com”> Date: Tue, 3 May 2016 15:42:02 +0300 Subject: [PATCH 04/12] ddl2cpp mysql now() support, minor PEP-8 edits --- scripts/ddl2cpp | 79 ++++++++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/scripts/ddl2cpp b/scripts/ddl2cpp index c4d41584..87fccc4f 100755 --- a/scripts/ddl2cpp +++ b/scripts/ddl2cpp @@ -34,10 +34,12 @@ import pprint from pyparsing import CaselessLiteral, Literal, SkipTo, restOfLine, oneOf, ZeroOrMore, Optional, Combine, Suppress, \ WordStart, WordEnd, Word, alphas, alphanums, nums, QuotedString, nestedExpr, MatchFirst, OneOrMore, delimitedList, Or, Group -def usage(): - print('Usage: ddl2cpp [-no-timestamp-warning] ') -if len(sys.argv) not in (4,5): +def usage(): + print('Usage: ddl2cpp [-no-timestamp-warning] \ + ') + +if len(sys.argv) not in (4, 5): usage() sys.exit(1) @@ -63,16 +65,19 @@ def get_include_guard_name(namespace, inputfile): val = re.sub("[^A-Za-z]+", "_", namespace + '_' + os.path.basename(inputfile)) return val.upper() + def repl_func(m): - if (m.group(1) == '_'): + if m.group(1) == '_': return m.group(2).upper() else: return m.group(1) + m.group(2).upper() -def toClassName(s): + +def to_class_name(s): return re.sub("(^|\s|[_0-9])(\S)", repl_func, s) -def toMemberName(s): + +def to_member_name(s): return re.sub("(\s|_|[0-9])(\S)", repl_func, s) @@ -80,16 +85,19 @@ def toMemberName(s): def ddlWord(string): return WordStart(alphanums + "_") + CaselessLiteral(string) + WordEnd(alphanums + "_") -ddlString = Or([QuotedString("'"), QuotedString("\"", escQuote='""'), QuotedString("`")]) +def ddlFunctionWord(string): + return CaselessLiteral(string) + OneOrMore("(") + ZeroOrMore(" ") + OneOrMore(")") + +ddlString = Or([QuotedString("'"), QuotedString("\"", escQuote='""'), QuotedString("`")]) negativeSign = Literal('-') -ddlNum = Combine(Optional(negativeSign) + Word(nums + ".")) -ddlTerm = Word(alphas, alphanums + "_$") -ddlName = Or([ddlTerm, ddlString]) +ddlNum = Combine(Optional(negativeSign) + Word(nums + ".")) +ddlTerm = Word(alphas, alphanums + "_$") +ddlName = Or([ddlTerm, ddlString]) ddlArguments = "(" + delimitedList(Or([ddlString, ddlTerm, ddlNum])) + ")" ddlNotNull = Group(ddlWord("NOT") + ddlWord("NULL")).setResultsName("notNull") -ddlDefaultValue = ddlWord("DEFAULT").setResultsName("hasDefaultValue"); -ddlAutoValue = ddlWord("AUTO_INCREMENT").setResultsName("hasAutoValue"); -ddlColumnComment = Group(ddlWord("COMMENT") + ddlString).setResultsName("comment") +ddlDefaultValue = ddlWord("DEFAULT").setResultsName("hasDefaultValue") +ddlAutoValue = ddlWord("AUTO_INCREMENT").setResultsName("hasAutoValue") +ddlColumnComment = Group(ddlWord("COMMENT") + ddlString).setResultsName("comment") ddlConstraint = Or([ ddlWord("CONSTRAINT"), ddlWord("PRIMARY"), @@ -98,7 +106,9 @@ ddlConstraint = Or([ ddlWord("INDEX"), ddlWord("UNIQUE"), ]) -ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst([ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlTerm, ddlNum, ddlColumnComment, ddlString, ddlArguments]))) +ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst( + [ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlFunctionWord("NOW"), ddlTerm, ddlNum, ddlColumnComment, ddlString, + ddlArguments]))) createTable = Group(ddlWord("CREATE") + ddlWord("TABLE") + ddlName.setResultsName("tableName") + "(" + Group(delimitedList(ddlColumn)).setResultsName("columns") + ")").setResultsName("create") @@ -125,12 +135,12 @@ types = { 'boolean': 'boolean', 'double': 'floating_point', 'float': 'floating_point', - 'date' : 'day_point', - 'datetime' : 'time_point', - 'timestamp' : 'time_point', - 'enum' : 'text', # MYSQL - 'set' : 'text', # MYSQL - } + 'date': 'day_point', + 'datetime': 'time_point', + 'timestamp': 'time_point', + 'enum': 'text', # MYSQL + 'set': 'text', # MYSQL +} # PROCESS DDL @@ -147,11 +157,11 @@ print('#include <' + INCLUDE + '/char_sequence.h>', file=header) print('', file=header) print('namespace ' + namespace, file=header) print('{', file=header) -DataTypeError = False; +DataTypeError = False for create in tableCreations: sqlTableName = create.tableName - tableClass = toClassName(sqlTableName) - tableMember = toMemberName(sqlTableName) + tableClass = to_class_name(sqlTableName) + tableMember = to_member_name(sqlTableName) tableNamespace = tableClass + '_' tableTemplateParameters = tableClass print(' namespace ' + tableNamespace, file=header) @@ -160,9 +170,9 @@ for create in tableCreations: if column.isConstraint: continue sqlColumnName = column[0] - columnClass = toClassName(sqlColumnName) + columnClass = to_class_name(sqlColumnName) tableTemplateParameters += ',\n ' + tableNamespace + '::' + columnClass - columnMember = toMemberName(sqlColumnName) + columnMember = to_member_name(sqlColumnName) sqlColumnType = column[1].lower() if sqlColumnType == 'timestamp' and timestampWarning: print("Warning: timestamp is mapped to sqlpp::time_point like datetime") @@ -184,22 +194,22 @@ for create in tableCreations: print(' };', file=header) print(' };', file=header) try: - traitslist = [NAMESPACE + '::' + types[sqlColumnType]]; + traitslist = [NAMESPACE + '::' + types[sqlColumnType]] except KeyError as e: print ('Error: datatype "' + sqlColumnType + '"" is not supported.') DataTypeError = True requireInsert = True if column.hasAutoValue: - traitslist.append(NAMESPACE + '::tag::must_not_insert'); - traitslist.append(NAMESPACE + '::tag::must_not_update'); + traitslist.append(NAMESPACE + '::tag::must_not_insert') + traitslist.append(NAMESPACE + '::tag::must_not_update') requireInsert = False if not column.notNull: - traitslist.append(NAMESPACE + '::tag::can_be_null'); + traitslist.append(NAMESPACE + '::tag::can_be_null') requireInsert = False if column.hasDefaultValue: requireInsert = False if requireInsert: - traitslist.append(NAMESPACE + '::tag::require_insert'); + traitslist.append(NAMESPACE + '::tag::require_insert') print(' using _traits = ' + NAMESPACE + '::make_traits<' + ', '.join(traitslist) + '>;', file=header) print(' };', file=header) print(' }', file=header) @@ -223,10 +233,11 @@ for create in tableCreations: print('}', file=header) print('#endif', file=header) -if (DataTypeError): +if DataTypeError: print("Error: unsupported datatypes." ) print("Possible solutions:") - print("A) Implement this datatype (examples: sqlpp11/data_types)" ) - print("B) Extend/upgrade ddl2cpp (edit types map)" ) + print("A) Implement this datatype (examples: sqlpp11/data_types)") + print("B) Extend/upgrade ddl2cpp (edit types map)") print("C) Raise an issue on github" ) - sys.exit(10) #return non-zero error code, we might need it for automation + sys.exit(10) # return non-zero error code, we might need it for automation + From f0d2bf6189bea5f96262a8ce9ba2b616e1cff363 Mon Sep 17 00:00:00 2001 From: strangeqargo <“strangeqargo@gmail.com”> Date: Tue, 3 May 2016 15:49:42 +0300 Subject: [PATCH 05/12] ddl2cpp mysql now(). Too many commits. --- scripts/ddl2cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/ddl2cpp b/scripts/ddl2cpp index c4d41584..c0f973dc 100755 --- a/scripts/ddl2cpp +++ b/scripts/ddl2cpp @@ -80,6 +80,9 @@ def toMemberName(s): def ddlWord(string): return WordStart(alphanums + "_") + CaselessLiteral(string) + WordEnd(alphanums + "_") +def ddlFunctionWord(string): + return CaselessLiteral(string) + OneOrMore("(") + ZeroOrMore(" ") + OneOrMore(")") + ddlString = Or([QuotedString("'"), QuotedString("\"", escQuote='""'), QuotedString("`")]) negativeSign = Literal('-') ddlNum = Combine(Optional(negativeSign) + Word(nums + ".")) @@ -98,7 +101,7 @@ ddlConstraint = Or([ ddlWord("INDEX"), ddlWord("UNIQUE"), ]) -ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst([ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlTerm, ddlNum, ddlColumnComment, ddlString, ddlArguments]))) +ddlColumn = Group(Optional(ddlConstraint).setResultsName("isConstraint") + OneOrMore(MatchFirst([ddlNotNull, ddlAutoValue, ddlDefaultValue, ddlFunctionWord("NOW"), ddlTerm, ddlNum, ddlColumnComment, ddlString, ddlArguments]))) createTable = Group(ddlWord("CREATE") + ddlWord("TABLE") + ddlName.setResultsName("tableName") + "(" + Group(delimitedList(ddlColumn)).setResultsName("columns") + ")").setResultsName("create") From 101a02e9e8df68044997416ca335821674ac2c1f Mon Sep 17 00:00:00 2001 From: strangeqargo <“strangeqargo@gmail.com”> Date: Wed, 4 May 2016 23:13:17 +0300 Subject: [PATCH 06/12] adding comment --- scripts/ddl2cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/ddl2cpp b/scripts/ddl2cpp index c0f973dc..7810fa70 100755 --- a/scripts/ddl2cpp +++ b/scripts/ddl2cpp @@ -80,6 +80,8 @@ def toMemberName(s): def ddlWord(string): return WordStart(alphanums + "_") + CaselessLiteral(string) + WordEnd(alphanums + "_") +# This function should be refactored if we find some database function which needs parameters +# Right now it works only for something like NOW() in MySQL default field value def ddlFunctionWord(string): return CaselessLiteral(string) + OneOrMore("(") + ZeroOrMore(" ") + OneOrMore(")") From 7097d4a32558d47bafab08dbd85887cbc7c61d9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20D=C3=A1vid?= Date: Thu, 5 May 2016 10:09:04 +0200 Subject: [PATCH 07/12] Approved error messages of FindHinnantDate.cmake Also added a documented variable to give hints. --- cmake/Modules/FindHinnantDate.cmake | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/cmake/Modules/FindHinnantDate.cmake b/cmake/Modules/FindHinnantDate.cmake index 0d44df51..7ae59c96 100644 --- a/cmake/Modules/FindHinnantDate.cmake +++ b/cmake/Modules/FindHinnantDate.cmake @@ -9,11 +9,14 @@ # # HinnantDate_FOUND - True if the system has the library # HinnantDate_INCLUDE_DIR - The directory which includes the header +# HinnantDate_ROOT_DIR - The base directory of the library # # and the following imported targets:: # # HinnantDate::Date - The target to use date.h # +# You can set HinnantDate_ROOT_DIR as hint to the location of the library. +# # The target will enable the required C++11 standard in your compiler. You can # use any later standard but you have to enable them explicitly. @@ -44,10 +47,16 @@ cmake_minimum_required(VERSION 3.1) +# ensure cache entry +set(HinnantDate_ROOT_DIR "${HinnantDate_ROOT_DIR}" CACHE PATH "Root directory of Howard Hinnant's date library") +set(HinnantDate_NOT_FOUND_MESSAGE "Could NOT find HinnantDate. +Maybe you need to adjust the search paths or HinnantDate_ROOT_DIR.") + find_file(HinnantDate_INCLUDE_FILE date.h - HINTS ${HinnantDate_INCLUDE_DIR} + HINTS ${HinnantDate_ROOT_DIR} ) +mark_as_advanced(HinnantDate_INCLUDE_FILE) if (HinnantDate_INCLUDE_FILE) # Validate that correct file is found @@ -57,11 +66,15 @@ if (HinnantDate_INCLUDE_FILE) ) if("${check_result}" STREQUAL "") - message(STATUS "FindHinnantDate: Rejecting found '${HinnantDate_INCLUDE_FILE}', it seems to be a name twin.") - unset(HinnantDate_INCLUDE_FILE) + string(APPEND HinnantDate_NOT_FOUND_MESSAGE "\nRejecting found '${HinnantDate_INCLUDE_FILE}', it seems to be a name twin.") + unset(HinnantDate_INCLUDE_FILE CACHE) else() # Check succeeded, create target get_filename_component(HinnantDate_INCLUDE_DIR "${HinnantDate_INCLUDE_FILE}" DIRECTORY CACHE) + mark_as_advanced(HinnantDate_INCLUDE_DIR) + set(HinnantDate_ROOT_DIR "${HinnantDate_INCLUDE_DIR}") + unset(HinnantDate_NOT_FOUND_MESSAGE) + if(NOT TARGET HinnantDate::Date) add_library(HinnantDate::Date INTERFACE IMPORTED) set_target_properties(HinnantDate::Date PROPERTIES @@ -78,6 +91,6 @@ endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(HinnantDate - REQUIRED_VARS - HinnantDate_INCLUDE_DIR + REQUIRED_VARS HinnantDate_ROOT_DIR HinnantDate_INCLUDE_DIR + FAIL_MESSAGE ${HinnantDate_NOT_FOUND_MESSAGE} ) From bcc3eea988bba695ea723b6ac32b56ae18729e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20D=C3=A1vid?= Date: Thu, 5 May 2016 10:15:26 +0200 Subject: [PATCH 08/12] Updated travis build config It sets the path to the date library correctly now. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ce830dcb..f2ccad57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,7 @@ before_script: - mkdir build - cd build - if [[ "$CXX" = "g++" && "$CONFIG" = "Debug" && "$TRAVIS_OS_NAME" = "linux" ]]; then export CXXFLAGS="--coverage"; fi - - cmake .. -DCMAKE_BUILD_TYPE=$CONFIG -DDATE_INCLUDE_DIR=$PWD/../date + - cmake .. -DCMAKE_BUILD_TYPE=$CONFIG -DCMAKE_PREFIX_PATH=$PWD/../date script: - cmake --build . --config $CONFIG From 21ea63c050519cbc6be3796ddd8774308d1ad1ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20D=C3=A1vid?= Date: Thu, 5 May 2016 10:31:58 +0200 Subject: [PATCH 09/12] Adopted .appveyor.yml to find the date library --- .appveyor.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 6a32db7b..2574b0b0 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -14,14 +14,13 @@ build_script: - CD - cd .. - CD - - git clone https://github.com/HowardHinnant/date + - git clone --branch v1.0.0 --depth 1 https://github.com/HowardHinnant/date - cd sqlpp11 - CD - echo %configuration% - mkdir build - cd build - cmake --version - - cmake .. -DCMAKE_CXX_FLAGS="/EHsc /wd4503" + - cmake .. -DCMAKE_CXX_FLAGS="/EHsc /wd4503" -DCMAKE_PREFIX_PATH=../../date - cmake --build . --config %configuration% - ctest . --build-config %configuration% - From bd22cdbb6155ae57342683b6fea34d44955c1a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20D=C3=A1vid?= Date: Thu, 5 May 2016 16:58:19 +0200 Subject: [PATCH 10/12] Corrected path to date in .appveyor.yml --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 2574b0b0..950a3f86 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -21,6 +21,6 @@ build_script: - mkdir build - cd build - cmake --version - - cmake .. -DCMAKE_CXX_FLAGS="/EHsc /wd4503" -DCMAKE_PREFIX_PATH=../../date + - cmake .. -DCMAKE_CXX_FLAGS="/EHsc /wd4503" -DCMAKE_PREFIX_PATH=../../../date - cmake --build . --config %configuration% - ctest . --build-config %configuration% From 5bd96147542807017b453098e54b3d9a3a1950c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20D=C3=A1vid?= Date: Thu, 5 May 2016 20:31:28 +0200 Subject: [PATCH 11/12] Corrected path to date in .appveyor.yml (again) --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 950a3f86..10ab73ce 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -21,6 +21,6 @@ build_script: - mkdir build - cd build - cmake --version - - cmake .. -DCMAKE_CXX_FLAGS="/EHsc /wd4503" -DCMAKE_PREFIX_PATH=../../../date + - cmake .. -DCMAKE_CXX_FLAGS="/EHsc /wd4503" -DCMAKE_PREFIX_PATH="..\..\date" - cmake --build . --config %configuration% - ctest . --build-config %configuration% From eed1b89f2ed7adfa187a34af23ff2fae9cbae967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20D=C3=A1vid?= Date: Fri, 6 May 2016 19:52:00 +0200 Subject: [PATCH 12/12] Corrected path to date in .appveyor.yml (again) --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 10ab73ce..ba2387cf 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -21,6 +21,6 @@ build_script: - mkdir build - cd build - cmake --version - - cmake .. -DCMAKE_CXX_FLAGS="/EHsc /wd4503" -DCMAKE_PREFIX_PATH="..\..\date" + - cmake .. -DCMAKE_CXX_FLAGS="/EHsc /wd4503" -DCMAKE_PREFIX_PATH="C:\projects\date" - cmake --build . --config %configuration% - ctest . --build-config %configuration%