Skip to content

Commit 4861e40

Browse files
authored
Merge pull request #910 from fnc12/dev
1.8
2 parents fdcc1da + feb237d commit 4861e40

File tree

279 files changed

+24797
-15927
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

279 files changed

+24797
-15927
lines changed

.clang-format

+2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ SpacesInParentheses: false
114114
SpacesInSquareBrackets: false
115115
Standard: Cpp11
116116
StatementMacros:
117+
- __pragma
118+
- _Pragma
117119
- Q_UNUSED
118120
- QT_REQUIRE_VERSION
119121
TabWidth: 8

CMakeLists.txt

+28-19
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@ cmake_minimum_required (VERSION 3.14.0)
33
# PACKAGE_VERSION is used by cpack scripts currently
44
# Both sqlite_orm_VERSION and PACKAGE_VERSION should be the same for now
55

6-
set(sqlite_orm_VERSION "1.6.0")
6+
set(sqlite_orm_VERSION "1.8.0")
77
set(PACKAGE_VERSION ${sqlite_orm_VERSION})
88

99
project("sqlite_orm" VERSION ${PACKAGE_VERSION})
1010

1111
# Handling C++ standard version to use
12+
option(SQLITE_ORM_ENABLE_CXX_20 "Enable C++ 20" OFF)
1213
option(SQLITE_ORM_ENABLE_CXX_17 "Enable C++ 17" OFF)
1314
set(CMAKE_CXX_STANDARD_REQUIRED ON)
14-
if(SQLITE_ORM_ENABLE_CXX_17)
15-
set(CMAKE_CXX_STANDARD 17)
16-
message(STATUS "SQLITE_ORM: Build with C++17 features")
15+
if(SQLITE_ORM_ENABLE_CXX_20)
16+
set(CMAKE_CXX_STANDARD 20)
17+
message(STATUS "SQLITE_ORM: Build with C++20 features")
18+
elseif(SQLITE_ORM_ENABLE_CXX_17)
19+
set(CMAKE_CXX_STANDARD 17)
20+
message(STATUS "SQLITE_ORM: Build with C++17 features")
1721
else()
18-
# fallback to C++14 if there is no special instruction
19-
set(CMAKE_CXX_STANDARD 14)
20-
message(STATUS "SQLITE_ORM: Build with C++14 features")
22+
# fallback to C++14 if there is no special instruction
23+
set(CMAKE_CXX_STANDARD 14)
24+
message(STATUS "SQLITE_ORM: Build with C++14 features")
2125
endif()
2226
set(CMAKE_CXX_EXTENSIONS OFF)
2327

@@ -48,17 +52,22 @@ target_include_directories(sqlite_orm INTERFACE $<BUILD_INTERFACE:${PROJECT_SOUR
4852
include(ucm)
4953

5054
if (MSVC)
51-
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
52-
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
53-
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
54-
add_compile_options(/EHsc)
55-
add_compile_options(/Zc:__cplusplus)
56-
add_compile_options(/MP) # Allow multi parrallel build
57-
58-
if ("${CMAKE_GENERATOR}" MATCHES "(Win64|x64)")
59-
message(STATUS "Add /bigobj flag to compiler")
60-
add_compile_options(/bigobj)
61-
endif()
55+
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
56+
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
57+
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
58+
add_compile_options(/EHsc)
59+
if (MSVC_VERSION GREATER_EQUAL 1914)
60+
add_compile_options(/Zc:__cplusplus)
61+
endif()
62+
add_compile_options(/MP) # multi-processor compilation
63+
if (CMAKE_CXX_STANDARD GREATER 14)
64+
add_compile_definitions(_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
65+
endif()
66+
67+
if ("${CMAKE_GENERATOR}" MATCHES "(Win64|x64)")
68+
message(STATUS "Add /bigobj flag to compiler")
69+
add_compile_options(/bigobj)
70+
endif()
6271
endif()
6372

6473
ucm_print_flags()
@@ -71,7 +80,7 @@ endif()
7180

7281
option(BUILD_EXAMPLES ON)
7382
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_EXAMPLES)
74-
add_subdirectory(examples)
83+
add_subdirectory(examples)
7584
endif()
7685

7786
### Packaging

README.md

+11-6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
<img src="https://github.com/fnc12/sqlite_orm/blob/master/logo.png" alt="Sublime's custom image" width="557"/>
33
</p>
44

5-
[![Donate using PayPal](https://img.shields.io/badge/donate-PayPal-brightgreen.svg)](https://paypal.me/fnc12)
6-
[![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/fold_left.svg?style=social&label=Follow%20%40sqlite_orm)](https://twitter.com/sqlite_orm)
7-
5+
[![C++](https://img.shields.io/badge/c++-%2300599C.svg?style=for-the-badge&logo=c%2B%2B&logoColor=white)](https://en.cppreference.com/w/)
6+
[![SQLite](https://img.shields.io/badge/sqlite-%2307405e.svg?style=for-the-badge&logo=sqlite&logoColor=white)](https://www.sqlite.org/index.html)
7+
[![GitHub Actions](https://img.shields.io/badge/githubactions-%232671E5.svg?style=for-the-badge&logo=githubactions&logoColor=white)](https://github.com/fnc12/sqlite_orm/actions)
8+
[![CMake](https://img.shields.io/badge/CMake-%23008FBA.svg?style=for-the-badge&logo=cmake&logoColor=white)](https://github.com/fnc12/sqlite_orm/blob/dev/CMakeLists.txt)
9+
[![Stack Overflow](https://img.shields.io/badge/-Stackoverflow-FE7A16?style=for-the-badge&logo=stack-overflow&logoColor=white)](https://stackoverflow.com/search?q=sqlite_orm)
10+
[![PayPal](https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white)](https://paypal.me/fnc12)
11+
[![Twitter](https://img.shields.io/badge/sqlite_orm-%231DA1F2.svg?style=for-the-badge&logo=Twitter&logoColor=white)](https://twitter.com/sqlite_orm)
12+
[![Patreon](https://img.shields.io/badge/Patreon-F96854?style=for-the-badge&logo=patreon&logoColor=white)](https://patreon.com/fnc12)
813

914
# SQLite ORM
1015
SQLite ORM light header only library for modern C++. Please read the license precisely. The project has AGPL license for open source project and MIT license after purchasing it for 50$ (using [PayPal](https://paypal.me/fnc12) or any different way (contact using email [email protected])).
@@ -79,18 +84,18 @@ Now we tell `sqlite_orm` library about our schema and provide database filename.
7984
using namespace sqlite_orm;
8085
auto storage = make_storage("db.sqlite",
8186
make_table("users",
82-
make_column("id", &User::id, autoincrement(), primary_key()),
87+
make_column("id", &User::id, primary_key().autoincrement()),
8388
make_column("first_name", &User::firstName),
8489
make_column("last_name", &User::lastName),
8590
make_column("birth_date", &User::birthDate),
8691
make_column("image_url", &User::imageUrl),
8792
make_column("type_id", &User::typeId)),
8893
make_table("user_types",
89-
make_column("id", &UserType::id, autoincrement(), primary_key()),
94+
make_column("id", &UserType::id, primary_key().autoincrement()),
9095
make_column("name", &UserType::name, default_value("name_placeholder"))));
9196
```
9297

93-
Too easy isn't it? You do not have to specify mapped type explicitly - it is deduced from your member pointers you pass during making a column (for example: `&User::id`). To create a column you have to pass two arguments at least: its name in the table and your mapped class member pointer. You can also add extra arguments to tell your storage about column's constraints like `primary_key`, `autoincrement`, `default_value` or `unique`(order isn't important; `not_null` is deduced from type automatically).
98+
Too easy isn't it? You do not have to specify mapped type explicitly - it is deduced from your member pointers you pass during making a column (for example: `&User::id`). To create a column you have to pass two arguments at least: its name in the table and your mapped class member pointer. You can also add extra arguments to tell your storage about column's constraints like `primary_key`, `autoincrement`, `default_value`, `unique` or `generated_always_as` (order isn't important; `not_null` is deduced from type automatically).
9499

95100
More details about making storage can be found in [tutorial](https://github.com/fnc12/sqlite_orm/wiki/Making-a-storage).
96101

TODO.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@
77
* `ATTACH`
88
* blob incremental I/O https://sqlite.org/c3ref/blob_open.html
99
* CREATE VIEW and other view operations https://sqlite.org/lang_createview.html
10-
* triggers
1110
* query static check for correct order (e.g. `GROUP BY` after `WHERE`)
1211
* `WINDOW`
13-
* `UPSERT` https://www.sqlite.org/lang_UPSERT.html
1412
* `SAVEPOINT` https://www.sqlite.org/lang_savepoint.html
1513
* add `static_assert` in crud `get*` functions in case user passes `where_t` instead of id to make compilation error more clear (example https://github.com/fnc12/sqlite_orm/issues/485)
16-
* generated columns https://www.sqlite.org/gencol.html
1714
* named constraints: constraint can have name `CREATE TABLE heroes(id INTEGER CONSTRAINT pk PRIMARY KEY)`
1815
* `FILTER` clause https://sqlite.org/lang_aggfunc.html#aggfilter
1916
* scalar math functions https://sqlite.org/lang_mathfunc.html
2017
* improve DROP COLUMN in `sync_schema` https://sqlite.org/lang_altertable.html#altertabdropcol
2118
* `UPDATE FROM` support https://sqlite.org/lang_update.html#upfrom
2219
* `iif()` function https://sqlite.org/lang_corefunc.html#iif
2320
* add strong typed collate syntax (more info [here](https://github.com/fnc12/sqlite_orm/issues/767#issuecomment-887689672))
24-
* raw `INSERT`: `storage.insert_into<User>(&User::id, values(5));` or `storage.insert_into<User>(columns(&User::id, &User::name), values(5, "Puff Diddy"));` or `storage.insert_into<User>(columns(), default_values());`
21+
* strict tables https://sqlite.org/stricttables.html
22+
* static assert when UPDATE is called with no PKs
23+
* `json_each` and `json_tree` functions for JSON1 extension
24+
* update hook
25+
* `RAISE`
2526

2627
Please feel free to add any feature that isn't listed here and not implemented yet.

appveyor.yml

+161-58
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,161 @@
1-
# build format
2-
version: "{build}"
3-
4-
skip_branch_with_pr: true
5-
skip_commits:
6-
files:
7-
- .git*
8-
- .travis.yml
9-
- _config.yml
10-
- LICENSE
11-
- '*.md'
12-
- '*.png'
13-
- '*.sh'
14-
15-
image:
16-
- Visual Studio 2017
17-
18-
# configurations to add to build matrix
19-
# TODO: MinGW Makefiles and MSYS Makefiles
20-
configuration:
21-
- Debug
22-
- Release
23-
24-
platform:
25-
- x86
26-
- x64
27-
28-
environment:
29-
matrix:
30-
# using c++14
31-
- SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_14=ON"
32-
33-
# using C++17 (for std::optional support)
34-
- SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_17=ON"
35-
36-
init:
37-
- echo %APPVEYOR_BUILD_WORKER_IMAGE% - %configuration% - %PLATFORM%
38-
- if "%PLATFORM%"=="x64" (set architecture=-A x64)
39-
- if "%PLATFORM%"=="x86" (set architecture=-A Win32)
40-
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" (set generator="Visual Studio 16 2019" %architecture%)
41-
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" (set generator="Visual Studio 15 2017" %architecture%)
42-
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" (set generator="Visual Studio 14 2015" %architecture%)
43-
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2013" (set generator="Visual Studio 12 2013" %architecture%)
44-
45-
install:
46-
- C:\Tools\vcpkg\vcpkg integrate install
47-
- vcpkg install sqlite3:%PLATFORM%-windows
48-
49-
# scripts to run before build
50-
before_build:
51-
- mkdir compile
52-
- cd compile
53-
- cmake %SQLITE_ORM_CXX_STANDARD% -DSqliteOrm_BuildTests=ON .. -G %generator% -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake
54-
55-
# build examples, and run tests (ie make & make test)
56-
build_script:
57-
- cmake --build . --config %configuration%
58-
- ctest --verbose --output-on-failure --build-config %configuration%
1+
# build format
2+
version: "{build}"
3+
4+
skip_branch_with_pr: true
5+
skip_commits:
6+
files:
7+
- .git*
8+
- .travis.yml
9+
- _config.yml
10+
- LICENSE
11+
- '*.md'
12+
- '*.png'
13+
- '*.sh'
14+
15+
# configurations to add to build matrix
16+
configuration:
17+
#- Debug
18+
- Release
19+
20+
environment:
21+
appveyor_yml_disable_ps_linux: true
22+
matrix:
23+
- job_name: clang, C++14
24+
appveyor_build_worker_image: Ubuntu
25+
CC: clang
26+
CXX: clang++
27+
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_14=ON"
28+
29+
- job_name: gcc, C++14
30+
appveyor_build_worker_image: Ubuntu
31+
CC: gcc
32+
CXX: g++
33+
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_14=ON"
34+
35+
# Representative for C++14
36+
- job_name: Visual Studio 2015 Update 3, x64, C++14
37+
appveyor_build_worker_image: Visual Studio 2015
38+
platform: x64
39+
SQLITE_ORM_CXX_STANDARD: ""
40+
41+
- job_name: clang, C++17
42+
appveyor_build_worker_image: Ubuntu
43+
CC: clang
44+
CXX: clang++
45+
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_17=ON"
46+
47+
- job_name: clang, C++20
48+
appveyor_build_worker_image: Ubuntu
49+
CC: clang
50+
CXX: clang++
51+
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_20=ON"
52+
53+
- job_name: gcc, C++17
54+
appveyor_build_worker_image: Ubuntu
55+
CC: gcc
56+
CXX: g++
57+
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_17=ON"
58+
59+
- job_name: gcc, C++20
60+
appveyor_build_worker_image: Ubuntu
61+
CC: gcc
62+
CXX: g++
63+
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_20=ON"
64+
65+
- job_name: Visual Studio 2022, x64, C++17
66+
appveyor_build_worker_image: Visual Studio 2022
67+
platform: x64
68+
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_17=ON"
69+
70+
- job_name: Visual Studio 2022, x64, C++20
71+
appveyor_build_worker_image: Visual Studio 2022
72+
platform: x64
73+
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_20=ON"
74+
75+
- job_name: Visual Studio 2022, x86, C++20
76+
appveyor_build_worker_image: Visual Studio 2022
77+
platform: x86
78+
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_20=ON"
79+
80+
matrix:
81+
fast_finish: true
82+
83+
for:
84+
-
85+
# Windows
86+
matrix:
87+
only:
88+
- appveyor_build_worker_image: Visual Studio 2015
89+
- appveyor_build_worker_image: Visual Studio 2022
90+
init:
91+
- |-
92+
echo %appveyor_build_worker_image% - %platform% - %configuration%
93+
if "%platform%"=="x64" (set architecture=-A x64)
94+
if "%platform%"=="x86" (set architecture=-A Win32)
95+
if "%appveyor_build_worker_image%"=="Visual Studio 2022" (set generator="Visual Studio 17 2022" %architecture%)
96+
if "%appveyor_build_worker_image%"=="Visual Studio 2015" (set generator="Visual Studio 14 2015" %architecture%)
97+
install:
98+
- |-
99+
C:\Tools\vcpkg\vcpkg integrate install
100+
vcpkg install sqlite3:%platform%-windows
101+
before_build:
102+
- |-
103+
mkdir compile
104+
cd compile
105+
cmake %SQLITE_ORM_CXX_STANDARD% -DSqliteOrm_BuildTests=ON .. -G %generator% -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake
106+
# build examples, and run tests (ie make & make test)
107+
build_script:
108+
- |-
109+
cmake --build . --config %configuration%
110+
ctest --verbose --output-on-failure --build-config %configuration%
111+
112+
-
113+
# Linux
114+
matrix:
115+
only:
116+
- appveyor_build_worker_image: Ubuntu
117+
init:
118+
- |-
119+
echo $appveyor_build_worker_image
120+
$CXX --version
121+
# using custom vcpkg triplets for building and linking dynamic dependent libraries
122+
install:
123+
- |-
124+
$HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets
125+
vcpkg install sqlite3 --overlay-triplets=vcpkg/triplets
126+
before_build:
127+
- |-
128+
mkdir compile
129+
cd compile
130+
cmake $SQLITE_ORM_CXX_STANDARD -DSqliteOrm_BuildTests=ON .. -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake
131+
# build examples, and run tests (ie make & make test)
132+
build_script:
133+
- |-
134+
cmake --build .
135+
ctest --verbose --output-on-failure
136+
-
137+
# macOS
138+
matrix:
139+
only:
140+
- appveyor_build_worker_image: macOS
141+
init:
142+
- |-
143+
echo $appveyor_build_worker_image
144+
$CXX --version
145+
# using custom vcpkg triplets for building and linking dynamic dependent libraries
146+
install:
147+
- |-
148+
git clone --depth 1 --branch 2022.05.10 https://github.com/microsoft/vcpkg.git $HOME/vcpkg
149+
$HOME/vcpkg/booststrap.sh
150+
$HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets
151+
vcpkg install sqlite3 --overlay-triplets=vcpkg/triplets
152+
before_build:
153+
- |-
154+
mkdir compile
155+
cd compile
156+
cmake $SQLITE_ORM_CXX_STANDARD -DSqliteOrm_BuildTests=ON .. -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake
157+
# build examples, and run tests (ie make & make test)
158+
build_script:
159+
- |-
160+
cmake --build .
161+
ctest --verbose --output-on-failure

0 commit comments

Comments
 (0)