mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 04:47:18 +08:00
Merge branch 'develop' of https://github.com/rbock/sqlpp11 into develop
This commit is contained in:
commit
db3d71e09c
@ -14,14 +14,13 @@ build_script:
|
|||||||
- CD
|
- CD
|
||||||
- cd ..
|
- 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 sqlpp11
|
||||||
- CD
|
- CD
|
||||||
- echo %configuration%
|
- echo %configuration%
|
||||||
- mkdir build
|
- mkdir build
|
||||||
- cd build
|
- cd build
|
||||||
- cmake --version
|
- cmake --version
|
||||||
- cmake .. -DCMAKE_CXX_FLAGS="/EHsc /wd4503"
|
- cmake .. -DCMAKE_CXX_FLAGS="/EHsc /wd4503" -DCMAKE_PREFIX_PATH="C:\projects\date"
|
||||||
- cmake --build . --config %configuration%
|
- cmake --build . --config %configuration%
|
||||||
- ctest . --build-config %configuration%
|
- ctest . --build-config %configuration%
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ before_script:
|
|||||||
- mkdir build
|
- mkdir build
|
||||||
- cd build
|
- cd build
|
||||||
- if [[ "$CXX" = "g++" && "$CONFIG" = "Debug" && "$TRAVIS_OS_NAME" = "linux" ]]; then export CXXFLAGS="--coverage"; fi
|
- 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:
|
script:
|
||||||
- cmake --build . --config $CONFIG
|
- cmake --build . --config $CONFIG
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
# Copyright (c) 2013-2016, Roland Bock
|
# Copyright (c) 2013-2016, Roland Bock
|
||||||
|
# Copyright (c) 2016 Christian Dávid
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without modification,
|
# 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()
|
enable_testing()
|
||||||
|
|
||||||
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
|
||||||
|
find_package(HinnantDate REQUIRED)
|
||||||
|
|
||||||
add_library(sqlpp11 INTERFACE)
|
add_library(sqlpp11 INTERFACE)
|
||||||
|
|
||||||
set(DATE_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../date" CACHE FILEPATH "Path to Howard Hinnant's date library")
|
target_link_libraries(sqlpp11 INTERFACE HinnantDate::Date)
|
||||||
|
|
||||||
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_include_directories(sqlpp11 INTERFACE
|
target_include_directories(sqlpp11 INTERFACE
|
||||||
$<BUILD_INTERFACE:${DATE_INCLUDE_DIR}>
|
|
||||||
$<BUILD_INTERFACE:${sqlpp11_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${sqlpp11_SOURCE_DIR}/include>
|
||||||
$<INSTALL_INTERFACE:include>
|
$<INSTALL_INTERFACE:include>
|
||||||
)
|
)
|
||||||
|
|
||||||
if (NOT DEFINED MSVC)
|
|
||||||
target_compile_features(sqlpp11 INTERFACE
|
target_compile_features(sqlpp11 INTERFACE
|
||||||
cxx_alias_templates
|
cxx_alias_templates
|
||||||
cxx_auto_type
|
cxx_auto_type
|
||||||
@ -69,7 +61,6 @@ target_compile_features(sqlpp11 INTERFACE
|
|||||||
cxx_template_template_parameters
|
cxx_template_template_parameters
|
||||||
cxx_variadic_templates
|
cxx_variadic_templates
|
||||||
)
|
)
|
||||||
endif ()
|
|
||||||
|
|
||||||
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/sqlpp11"
|
install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/sqlpp11"
|
||||||
DESTINATION include
|
DESTINATION include
|
||||||
@ -106,13 +97,13 @@ install(EXPORT Sqlpp11Targets
|
|||||||
|
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
cmake/Sqlpp11Config.cmake
|
"cmake/Sqlpp11Config.cmake"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/Sqlpp11ConfigVersion.cmake"
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake/Sqlpp11ConfigVersion.cmake"
|
||||||
|
"cmake/Modules/FindHinnantDate.cmake"
|
||||||
DESTINATION
|
DESTINATION
|
||||||
${ConfigPackageLocation}
|
${ConfigPackageLocation}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
add_subdirectory(test_types)
|
add_subdirectory(test_types)
|
||||||
add_subdirectory(test_serializer)
|
add_subdirectory(test_serializer)
|
||||||
|
@ -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
|
* MySQL: https://github.com/rbock/sqlpp11-connector-mysql
|
||||||
* Sqlite3: https://github.com/rbock/sqlpp11-connector-sqlite3
|
* Sqlite3: https://github.com/rbock/sqlpp11-connector-sqlite3
|
||||||
* PostgreSQL: https://github.com/matthijs/sqlpp11-connector-postgresql
|
* 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:
|
To demonstrate that sqlpp11 can work with other backends as well, here is an experimental backend for structs in standard containers:
|
||||||
|
|
||||||
|
96
cmake/Modules/FindHinnantDate.cmake
Normal file
96
cmake/Modules/FindHinnantDate.cmake
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
#.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
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
# 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_ROOT_DIR}
|
||||||
|
)
|
||||||
|
mark_as_advanced(HinnantDate_INCLUDE_FILE)
|
||||||
|
|
||||||
|
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 "")
|
||||||
|
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
|
||||||
|
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_ROOT_DIR HinnantDate_INCLUDE_DIR
|
||||||
|
FAIL_MESSAGE ${HinnantDate_NOT_FOUND_MESSAGE}
|
||||||
|
)
|
@ -23,4 +23,9 @@
|
|||||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# 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")
|
include("${CMAKE_CURRENT_LIST_DIR}/Sqlpp11Targets.cmake")
|
||||||
|
@ -80,6 +80,11 @@ def toMemberName(s):
|
|||||||
def ddlWord(string):
|
def ddlWord(string):
|
||||||
return WordStart(alphanums + "_") + CaselessLiteral(string) + WordEnd(alphanums + "_")
|
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(")")
|
||||||
|
|
||||||
ddlString = Or([QuotedString("'"), QuotedString("\"", escQuote='""'), QuotedString("`")])
|
ddlString = Or([QuotedString("'"), QuotedString("\"", escQuote='""'), QuotedString("`")])
|
||||||
negativeSign = Literal('-')
|
negativeSign = Literal('-')
|
||||||
ddlNum = Combine(Optional(negativeSign) + Word(nums + "."))
|
ddlNum = Combine(Optional(negativeSign) + Word(nums + "."))
|
||||||
@ -98,7 +103,7 @@ ddlConstraint = Or([
|
|||||||
ddlWord("INDEX"),
|
ddlWord("INDEX"),
|
||||||
ddlWord("UNIQUE"),
|
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")
|
createTable = Group(ddlWord("CREATE") + ddlWord("TABLE") + ddlName.setResultsName("tableName") + "(" + Group(delimitedList(ddlColumn)).setResultsName("columns") + ")").setResultsName("create")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user