Skip to content

Commit

Permalink
Merge pull request #910 from fnc12/dev
Browse files Browse the repository at this point in the history
1.8
  • Loading branch information
fnc12 authored Dec 9, 2022
2 parents fdcc1da + feb237d commit 4861e40
Show file tree
Hide file tree
Showing 279 changed files with 24,797 additions and 15,927 deletions.
2 changes: 2 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
StatementMacros:
- __pragma
- _Pragma
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
Expand Down
47 changes: 28 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@ cmake_minimum_required (VERSION 3.14.0)
# PACKAGE_VERSION is used by cpack scripts currently
# Both sqlite_orm_VERSION and PACKAGE_VERSION should be the same for now

set(sqlite_orm_VERSION "1.6.0")
set(sqlite_orm_VERSION "1.8.0")
set(PACKAGE_VERSION ${sqlite_orm_VERSION})

project("sqlite_orm" VERSION ${PACKAGE_VERSION})

# Handling C++ standard version to use
option(SQLITE_ORM_ENABLE_CXX_20 "Enable C++ 20" OFF)
option(SQLITE_ORM_ENABLE_CXX_17 "Enable C++ 17" OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(SQLITE_ORM_ENABLE_CXX_17)
set(CMAKE_CXX_STANDARD 17)
message(STATUS "SQLITE_ORM: Build with C++17 features")
if(SQLITE_ORM_ENABLE_CXX_20)
set(CMAKE_CXX_STANDARD 20)
message(STATUS "SQLITE_ORM: Build with C++20 features")
elseif(SQLITE_ORM_ENABLE_CXX_17)
set(CMAKE_CXX_STANDARD 17)
message(STATUS "SQLITE_ORM: Build with C++17 features")
else()
# fallback to C++14 if there is no special instruction
set(CMAKE_CXX_STANDARD 14)
message(STATUS "SQLITE_ORM: Build with C++14 features")
# fallback to C++14 if there is no special instruction
set(CMAKE_CXX_STANDARD 14)
message(STATUS "SQLITE_ORM: Build with C++14 features")
endif()
set(CMAKE_CXX_EXTENSIONS OFF)

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

if (MSVC)
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
add_compile_options(/EHsc)
add_compile_options(/Zc:__cplusplus)
add_compile_options(/MP) # Allow multi parrallel build

if ("${CMAKE_GENERATOR}" MATCHES "(Win64|x64)")
message(STATUS "Add /bigobj flag to compiler")
add_compile_options(/bigobj)
endif()
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
add_compile_options(/EHsc)
if (MSVC_VERSION GREATER_EQUAL 1914)
add_compile_options(/Zc:__cplusplus)
endif()
add_compile_options(/MP) # multi-processor compilation
if (CMAKE_CXX_STANDARD GREATER 14)
add_compile_definitions(_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING)
endif()

if ("${CMAKE_GENERATOR}" MATCHES "(Win64|x64)")
message(STATUS "Add /bigobj flag to compiler")
add_compile_options(/bigobj)
endif()
endif()

ucm_print_flags()
Expand All @@ -71,7 +80,7 @@ endif()

option(BUILD_EXAMPLES ON)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_EXAMPLES)
add_subdirectory(examples)
add_subdirectory(examples)
endif()

### Packaging
Expand Down
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
<img src="https://github.com/fnc12/sqlite_orm/blob/master/logo.png" alt="Sublime's custom image" width="557"/>
</p>

[![Donate using PayPal](https://img.shields.io/badge/donate-PayPal-brightgreen.svg)](https://paypal.me/fnc12)
[![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)

[![C++](https://img.shields.io/badge/c++-%2300599C.svg?style=for-the-badge&logo=c%2B%2B&logoColor=white)](https://en.cppreference.com/w/)
[![SQLite](https://img.shields.io/badge/sqlite-%2307405e.svg?style=for-the-badge&logo=sqlite&logoColor=white)](https://www.sqlite.org/index.html)
[![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)
[![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)
[![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)
[![PayPal](https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white)](https://paypal.me/fnc12)
[![Twitter](https://img.shields.io/badge/sqlite_orm-%231DA1F2.svg?style=for-the-badge&logo=Twitter&logoColor=white)](https://twitter.com/sqlite_orm)
[![Patreon](https://img.shields.io/badge/Patreon-F96854?style=for-the-badge&logo=patreon&logoColor=white)](https://patreon.com/fnc12)

# SQLite ORM
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 fnc12@me.com)).
Expand Down Expand Up @@ -79,18 +84,18 @@ Now we tell `sqlite_orm` library about our schema and provide database filename.
using namespace sqlite_orm;
auto storage = make_storage("db.sqlite",
make_table("users",
make_column("id", &User::id, autoincrement(), primary_key()),
make_column("id", &User::id, primary_key().autoincrement()),
make_column("first_name", &User::firstName),
make_column("last_name", &User::lastName),
make_column("birth_date", &User::birthDate),
make_column("image_url", &User::imageUrl),
make_column("type_id", &User::typeId)),
make_table("user_types",
make_column("id", &UserType::id, autoincrement(), primary_key()),
make_column("id", &UserType::id, primary_key().autoincrement()),
make_column("name", &UserType::name, default_value("name_placeholder"))));
```

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).
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).

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

Expand Down
9 changes: 5 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@
* `ATTACH`
* blob incremental I/O https://sqlite.org/c3ref/blob_open.html
* CREATE VIEW and other view operations https://sqlite.org/lang_createview.html
* triggers
* query static check for correct order (e.g. `GROUP BY` after `WHERE`)
* `WINDOW`
* `UPSERT` https://www.sqlite.org/lang_UPSERT.html
* `SAVEPOINT` https://www.sqlite.org/lang_savepoint.html
* 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)
* generated columns https://www.sqlite.org/gencol.html
* named constraints: constraint can have name `CREATE TABLE heroes(id INTEGER CONSTRAINT pk PRIMARY KEY)`
* `FILTER` clause https://sqlite.org/lang_aggfunc.html#aggfilter
* scalar math functions https://sqlite.org/lang_mathfunc.html
* improve DROP COLUMN in `sync_schema` https://sqlite.org/lang_altertable.html#altertabdropcol
* `UPDATE FROM` support https://sqlite.org/lang_update.html#upfrom
* `iif()` function https://sqlite.org/lang_corefunc.html#iif
* add strong typed collate syntax (more info [here](https://github.com/fnc12/sqlite_orm/issues/767#issuecomment-887689672))
* 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());`
* strict tables https://sqlite.org/stricttables.html
* static assert when UPDATE is called with no PKs
* `json_each` and `json_tree` functions for JSON1 extension
* update hook
* `RAISE`

Please feel free to add any feature that isn't listed here and not implemented yet.
219 changes: 161 additions & 58 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,161 @@
# build format
version: "{build}"

skip_branch_with_pr: true
skip_commits:
files:
- .git*
- .travis.yml
- _config.yml
- LICENSE
- '*.md'
- '*.png'
- '*.sh'

image:
- Visual Studio 2017

# configurations to add to build matrix
# TODO: MinGW Makefiles and MSYS Makefiles
configuration:
- Debug
- Release

platform:
- x86
- x64

environment:
matrix:
# using c++14
- SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_14=ON"

# using C++17 (for std::optional support)
- SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_17=ON"

init:
- echo %APPVEYOR_BUILD_WORKER_IMAGE% - %configuration% - %PLATFORM%
- if "%PLATFORM%"=="x64" (set architecture=-A x64)
- if "%PLATFORM%"=="x86" (set architecture=-A Win32)
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" (set generator="Visual Studio 16 2019" %architecture%)
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" (set generator="Visual Studio 15 2017" %architecture%)
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" (set generator="Visual Studio 14 2015" %architecture%)
- if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2013" (set generator="Visual Studio 12 2013" %architecture%)

install:
- C:\Tools\vcpkg\vcpkg integrate install
- vcpkg install sqlite3:%PLATFORM%-windows

# scripts to run before build
before_build:
- mkdir compile
- cd compile
- cmake %SQLITE_ORM_CXX_STANDARD% -DSqliteOrm_BuildTests=ON .. -G %generator% -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake

# build examples, and run tests (ie make & make test)
build_script:
- cmake --build . --config %configuration%
- ctest --verbose --output-on-failure --build-config %configuration%
# build format
version: "{build}"

skip_branch_with_pr: true
skip_commits:
files:
- .git*
- .travis.yml
- _config.yml
- LICENSE
- '*.md'
- '*.png'
- '*.sh'

# configurations to add to build matrix
configuration:
#- Debug
- Release

environment:
appveyor_yml_disable_ps_linux: true
matrix:
- job_name: clang, C++14
appveyor_build_worker_image: Ubuntu
CC: clang
CXX: clang++
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_14=ON"

- job_name: gcc, C++14
appveyor_build_worker_image: Ubuntu
CC: gcc
CXX: g++
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_14=ON"

# Representative for C++14
- job_name: Visual Studio 2015 Update 3, x64, C++14
appveyor_build_worker_image: Visual Studio 2015
platform: x64
SQLITE_ORM_CXX_STANDARD: ""

- job_name: clang, C++17
appveyor_build_worker_image: Ubuntu
CC: clang
CXX: clang++
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_17=ON"

- job_name: clang, C++20
appveyor_build_worker_image: Ubuntu
CC: clang
CXX: clang++
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_20=ON"

- job_name: gcc, C++17
appveyor_build_worker_image: Ubuntu
CC: gcc
CXX: g++
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_17=ON"

- job_name: gcc, C++20
appveyor_build_worker_image: Ubuntu
CC: gcc
CXX: g++
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_20=ON"

- job_name: Visual Studio 2022, x64, C++17
appveyor_build_worker_image: Visual Studio 2022
platform: x64
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_17=ON"

- job_name: Visual Studio 2022, x64, C++20
appveyor_build_worker_image: Visual Studio 2022
platform: x64
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_20=ON"

- job_name: Visual Studio 2022, x86, C++20
appveyor_build_worker_image: Visual Studio 2022
platform: x86
SQLITE_ORM_CXX_STANDARD: "-DSQLITE_ORM_ENABLE_CXX_20=ON"

matrix:
fast_finish: true

for:
-
# Windows
matrix:
only:
- appveyor_build_worker_image: Visual Studio 2015
- appveyor_build_worker_image: Visual Studio 2022
init:
- |-
echo %appveyor_build_worker_image% - %platform% - %configuration%
if "%platform%"=="x64" (set architecture=-A x64)
if "%platform%"=="x86" (set architecture=-A Win32)
if "%appveyor_build_worker_image%"=="Visual Studio 2022" (set generator="Visual Studio 17 2022" %architecture%)
if "%appveyor_build_worker_image%"=="Visual Studio 2015" (set generator="Visual Studio 14 2015" %architecture%)
install:
- |-
C:\Tools\vcpkg\vcpkg integrate install
vcpkg install sqlite3:%platform%-windows
before_build:
- |-
mkdir compile
cd compile
cmake %SQLITE_ORM_CXX_STANDARD% -DSqliteOrm_BuildTests=ON .. -G %generator% -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake
# build examples, and run tests (ie make & make test)
build_script:
- |-
cmake --build . --config %configuration%
ctest --verbose --output-on-failure --build-config %configuration%
-
# Linux
matrix:
only:
- appveyor_build_worker_image: Ubuntu
init:
- |-
echo $appveyor_build_worker_image
$CXX --version
# using custom vcpkg triplets for building and linking dynamic dependent libraries
install:
- |-
$HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets
vcpkg install sqlite3 --overlay-triplets=vcpkg/triplets
before_build:
- |-
mkdir compile
cd compile
cmake $SQLITE_ORM_CXX_STANDARD -DSqliteOrm_BuildTests=ON .. -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake
# build examples, and run tests (ie make & make test)
build_script:
- |-
cmake --build .
ctest --verbose --output-on-failure
-
# macOS
matrix:
only:
- appveyor_build_worker_image: macOS
init:
- |-
echo $appveyor_build_worker_image
$CXX --version
# using custom vcpkg triplets for building and linking dynamic dependent libraries
install:
- |-
git clone --depth 1 --branch 2022.05.10 https://github.com/microsoft/vcpkg.git $HOME/vcpkg
$HOME/vcpkg/booststrap.sh
$HOME/vcpkg/vcpkg integrate install --overlay-triplets=vcpkg/triplets
vcpkg install sqlite3 --overlay-triplets=vcpkg/triplets
before_build:
- |-
mkdir compile
cd compile
cmake $SQLITE_ORM_CXX_STANDARD -DSqliteOrm_BuildTests=ON .. -DCMAKE_TOOLCHAIN_FILE=$HOME/vcpkg/scripts/buildsystems/vcpkg.cmake
# build examples, and run tests (ie make & make test)
build_script:
- |-
cmake --build .
ctest --verbose --output-on-failure
Loading

0 comments on commit 4861e40

Please sign in to comment.