Skip to content
Merged

v1.6 #564

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
200 commits
Select commit Hold shift + click to select a range
028d1b0
added hex core function
Jan 1, 2020
01ac941
added a comment
Jan 1, 2020
a8af06c
fixed tab for the comment
Jan 1, 2020
1d6e34a
Merge pull request #438 from fnc12/hex
fnc12 Jan 2, 2020
124120b
added main header to code format check
Jan 2, 2020
d3234fd
formatted main header
Jan 2, 2020
333c7ba
Merge pull request #439 from fnc12/add-main-header-to-code-format-check
fnc12 Jan 2, 2020
4a87844
added quote function
Jan 2, 2020
eaa29f9
Merge pull request #440 from fnc12/quote
fnc12 Jan 3, 2020
c56f0e5
added randomblob func
Jan 4, 2020
b409788
code format
Jan 4, 2020
a094f8f
Merge pull request #441 from fnc12/randomblob
fnc12 Jan 5, 2020
a7f1bd0
added instr core function
Jan 6, 2020
61c3a8a
Merge pull request #444 from fnc12/instr
fnc12 Jan 6, 2020
5517d99
added time function
Jan 7, 2020
9cd70c2
fixed cmake
Jan 7, 2020
cc819f3
fixed collate example compilation
Jan 7, 2020
f4dade3
Merge pull request #445 from fnc12/time
fnc12 Jan 8, 2020
561da29
added replace core func
Jan 8, 2020
58b2e3d
Merge pull request #446 from fnc12/replace-func
fnc12 Jan 8, 2020
bfa3e07
added round core function
Jan 9, 2020
d2c4d68
Merge pull request #448 from fnc12/round
fnc12 Jan 10, 2020
23290de
added UNSIGNED INT(6) support
Jan 15, 2020
ee90607
Merge pull request #453 from fnc12/unsigned-int-size-support
fnc12 Jan 16, 2020
252db48
added two or more spaces support
Jan 23, 2020
045dabe
Merge pull request #455 from fnc12/parsing-improvement
fnc12 Jan 23, 2020
ad7dba3
added check constraint
Feb 2, 2020
46c732a
removed comments
Feb 2, 2020
9074ff7
code format
Feb 2, 2020
96ce6b6
Merge pull request #456 from fnc12/check-constraint2
fnc12 Feb 2, 2020
d29fd4b
added soundex func
Feb 2, 2020
215ed12
Merge pull request #457 from fnc12/soundex
fnc12 Feb 3, 2020
6bfdd57
added strftime func
Feb 4, 2020
378278a
Merge pull request #458 from fnc12/strftime
fnc12 Feb 4, 2020
39ce92a
started serialization refactoring
Feb 7, 2020
105d214
removed aggredate functions file and refactored aggregate functions w…
Feb 12, 2020
46f9cb6
Merge pull request #461 from fnc12/aggregate-functions-refactoring
fnc12 Feb 12, 2020
f896237
removed most overrides of storage_t::parse_table_name
Feb 13, 2020
c440fec
Avoid foreign and/or references to be understand as SQLite command
Feb 14, 2020
a1121e4
update tests
Feb 17, 2020
d3725ce
Merge pull request #464 from indoubtchoose12/dev
fnc12 Feb 17, 2020
161475f
refactored parsing table names in raw select
Feb 18, 2020
d4c5b65
Merge branch 'dev' into parse-table-name-refactoring
Feb 18, 2020
631eed5
format fixed
Feb 18, 2020
67f3375
removed a comment
Feb 18, 2020
24359b0
fixed alias column
Feb 19, 2020
92d1c08
moved not operator test to a dedicted file
Feb 20, 2020
519fb72
code format
Feb 20, 2020
4d8cfa0
removed dup from cmake
Feb 20, 2020
d29bc7a
split tests4 into two files
Feb 20, 2020
7835e95
fixed tests5 compilation on windows
Feb 21, 2020
72c69ba
Merge pull request #460 from fnc12/parse-table-name-refactoring
fnc12 Feb 21, 2020
27d5dde
started fix
Feb 24, 2020
64e848f
added default ctor to core function
Feb 25, 2020
85b8eef
Merge pull request #468 from fnc12/case-fix
fnc12 Feb 26, 2020
6fc3c4f
reactored tuple creation
Feb 27, 2020
3c2eee5
Merge pull request #471 from fnc12/case-fix
fnc12 Feb 27, 2020
0e4b52c
Merge branch 'dev' into custom-containers-fix
Mar 2, 2020
50c5a7a
fixed get_all with custom containers
Mar 2, 2020
d4cb805
added static tests for return types in tests
Mar 2, 2020
7c4d566
Merge pull request #472 from fnc12/custom-containers-fix
fnc12 Mar 3, 2020
971057e
fixed shadowing local vars warnings in tests target
Mar 3, 2020
c514814
Merge pull request #473 from fnc12/fix-warnings
fnc12 Mar 3, 2020
1116f69
fixed unused arguments warning
Mar 3, 2020
f2fb2d7
Merge pull request #474 from fnc12/fix-warnings
fnc12 Mar 4, 2020
fc5e701
added <<, >>, & and | bitwise operators
Mar 9, 2020
f591f62
Merge pull request #477 from fnc12/bitwise-binary-operators
fnc12 Mar 9, 2020
e0bc852
refactored operator not and added bitwise_not function
Mar 9, 2020
b896a06
Merge pull request #478 from fnc12/bitwise-binary-operators
fnc12 Mar 10, 2020
26f9138
added quotes in fk serizlization
Mar 11, 2020
bb0f260
Merge pull request #480 from fnc12/order-named-table-with-fk
fnc12 Mar 11, 2020
c8ea84b
Merge branch 'dev' into serialization-refactoring
Mar 15, 2020
378fddb
added more ztatement serializator specializations
Mar 18, 2020
5442e4a
added column names getter
Mar 21, 2020
48e68f3
renamed process_single_condition to string_from_expression
Mar 21, 2020
de88524
Merge pull request #484 from fnc12/process-single-condition-refactor
fnc12 Mar 22, 2020
7b47d62
Merge branch 'dev' into serialization-refactoring
Mar 22, 2020
7be2ca2
Update TODO.md
fnc12 Mar 22, 2020
2242a30
Update TODO.md
fnc12 Mar 23, 2020
d127458
added order by serializator
Mar 26, 2020
b37730c
refactored dynamic order by with context
Mar 26, 2020
2f36dd9
removed a comment
Mar 26, 2020
af4aace
Merge pull request #487 from fnc12/refactoring-dynamic-order-by
fnc12 Mar 27, 2020
57475c1
Merge pull request #491 from fnc12/master
fnc12 Apr 7, 2020
44ab697
Update TODO.md
fnc12 Apr 12, 2020
55e64c2
Update TODO.md
fnc12 Apr 14, 2020
2509362
Merge pull request #496 from fnc12/master
fnc12 Apr 18, 2020
916f36a
marged dev and fixed all tests except one
Apr 26, 2020
bc1f6a2
added use_parentheses field
Apr 26, 2020
9d28a50
removed commented code
Apr 26, 2020
0ffb85d
added statement serializator for using
Apr 27, 2020
45a7948
code format
Apr 27, 2020
c46bcb7
removed process join constraint func
Apr 27, 2020
3fa9c5c
Merge pull request #502 from fnc12/serialization-refactoring
fnc12 Apr 27, 2020
42dad52
added statement serializator for insert range
Apr 27, 2020
142e5dc
Merge pull request #504 from fnc12/serialization-refactoring
fnc12 Apr 28, 2020
7ad4dab
removed string_from_expression for remote_v
May 11, 2020
83f8165
removed string_from_expression for insert_t
May 11, 2020
25df9c6
removed string_from_expression for remove_all_t
May 11, 2020
abf63c6
removed string_from_expression for update_all_t
May 12, 2020
a908ac4
removed string_from_expression for update_t
May 12, 2020
2c85dae
remove string_from_expression for insert_explicit_t
May 12, 2020
8b8a544
removed string_from_expression for replace_t
May 12, 2020
25a5df5
remove string_from_expression for replace_range_t
May 12, 2020
77752cd
removved string_from_expression for get_all_t
May 12, 2020
d421526
added the second template arg to get_all_t
May 12, 2020
e4f8b9b
Merge pull request #510 from fnc12/serialization-refactoring
fnc12 May 13, 2020
06158ff
added custom container support for get_all_pointer
May 13, 2020
9d7787a
code format
May 13, 2020
ba8da89
Merge pull request #513 from fnc12/custom-containers-for-everyone
fnc12 May 14, 2020
6aaa595
fixed comments
May 14, 2020
cbe300a
Merge branch 'dev' into custom-containers-for-everyone
May 14, 2020
627eacf
added custom container support for get_all_optional
May 14, 2020
93c5ee4
fixed get all optional unit tests
May 14, 2020
ed97a9e
Merge pull request #514 from fnc12/custom-containers-for-everyone
fnc12 May 15, 2020
265bd41
removed string_from_expression for get_all*
May 15, 2020
94a36b4
removed string_from_expression for get*
May 15, 2020
b59b635
Merge pull request #515 from fnc12/serialization-refactoring
fnc12 May 16, 2020
a791d7d
added object_t, refactored extract lambda and created mapped row extr…
May 24, 2020
8aef1b4
Merge pull request #520 from fnc12/feature-select-object
fnc12 May 24, 2020
10e3c94
added unique for several columns
May 26, 2020
eb3c515
Merge pull request #522 from fnc12/feature/unique-multi-column
fnc12 May 27, 2020
87f5484
fixed sync_schema
May 30, 2020
7895f10
removed a comment
May 30, 2020
76f830f
Merge pull request #524 from fnc12/sync-schema-fix
fnc12 May 30, 2020
888695d
added new unique case
Jun 4, 2020
8048d9e
Merge pull request #526 from fnc12/issue525
fnc12 Jun 9, 2020
c2bf0c8
adde rename_table with unit tests
Jun 9, 2020
a69a163
added rename_table with a template parameter
Jun 14, 2020
187621e
Merge pull request #529 from fnc12/feature/rename-table
fnc12 Jun 14, 2020
636d706
added values and unit tests
Jun 27, 2020
ae9a21e
Merge pull request #534 from fnc12/feature/in-with-row
fnc12 Jun 27, 2020
559cfdb
fixed backup bug
Jul 3, 2020
3be4831
changed order of non-static members in backup_t
Jul 4, 2020
6e477cf
refactored make_backup_from
Jul 4, 2020
57c3b21
added unique filename
Jul 5, 2020
2dbdcad
Merge pull request #542 from fnc12/bugfix/backup
fnc12 Jul 5, 2020
ff9a8c8
updated sqlite source link
Jul 8, 2020
e8a0abf
fixed hash
Jul 8, 2020
f26fe5b
commented out hash check
Jul 8, 2020
c3f6798
commented out osx in travis config
Jul 9, 2020
6e79580
removed comments
Jul 9, 2020
a3e07c9
Merge pull request #549 from fnc12/apple-ci-fix
fnc12 Jul 9, 2020
c9eb911
added empty callable static function
Jul 9, 2020
3efc98c
Merge pull request #553 from fnc12/vs-warning-remove
fnc12 Jul 10, 2020
ecc625c
added dynamic_values_t
Jul 10, 2020
55a6a7e
Merge pull request #555 from fnc12/values-dynamic
fnc12 Jul 11, 2020
c682d31
Merge branch 'master' into dev
Jul 20, 2020
258ae5e
added dump for prepared statements
Jul 20, 2020
df36222
removed commented lines
Jul 20, 2020
f83d71f
Merge pull request #560 from fnc12/feature/prepared-statement-dump
fnc12 Jul 21, 2020
41cedd1
added template keyword
Jul 25, 2020
1053a6f
Merge pull request #565 from fnc12/bugfix/562
fnc12 Jul 25, 2020
ffda7dc
rm compile folder
air-h-128k-il Jul 25, 2020
2f1a026
Merge branch 'dev' of github.com:air-h-128k-il/sqlite_orm into dev
air-h-128k-il Jul 28, 2020
dda2746
Merge pull request #568 from air-h-128k-il/dev
fnc12 Jul 28, 2020
3a543f0
removed sqlite type and its comparison
Jul 31, 2020
7ead019
fixed include
Aug 1, 2020
1699a0b
fixed headers again
Aug 1, 2020
a8a42a9
Merge pull request #570 from fnc12/sync-schema-type-erasing
fnc12 Aug 1, 2020
9561744
Add sqlite3 and catch2 dependencies
Leon0402 Aug 1, 2020
57e0f6a
Add example
Leon0402 Aug 1, 2020
2e0e142
find_package support
Leon0402 Aug 1, 2020
7bf19a0
Undo version bump
Leon0402 Aug 1, 2020
a510304
Fix pipeline
Leon0402 Aug 1, 2020
1dc2edf
Merge pull request #572 from Leon0402/feature/dependencyManagment
fnc12 Aug 1, 2020
9082ad1
Update README.md
fnc12 Aug 2, 2020
6621511
Update docs, bump cmake version
Leon0402 Aug 3, 2020
7e0d2f3
Address issue
Leon0402 Aug 3, 2020
344fd88
Change to Cmake 3.12.4, the lastest one supported by travis
Leon0402 Aug 3, 2020
fc0310b
Use old fetch method
Leon0402 Aug 3, 2020
2d0268c
Quick test, if ubuntu 20.04 is available
Leon0402 Aug 3, 2020
e51561f
Test
Leon0402 Aug 3, 2020
179e91f
Add cmake ppa
Leon0402 Aug 3, 2020
d97eedf
Merge pull request #575 from Leon0402/feature/dependencyManagment
fnc12 Aug 3, 2020
2fabcc8
added indexed_column function
Aug 6, 2020
65bd71d
added a comment
Aug 6, 2020
661cc1d
Merge pull request #577 from fnc12/feature/index-detailed-columns
fnc12 Aug 7, 2020
5ba0dab
added delete_with_two_fields to cmake
fnc12 Aug 16, 2020
9d94ea2
changed scope value to type
fnc12 Aug 16, 2020
8d3b9d7
Merge pull request #580 from fnc12/bugfix/add-delete_with_two_fields.…
fnc12 Aug 16, 2020
96c70b0
added ast iterator for values and dynamic values
fnc12 Aug 17, 2020
5e7b504
Merge pull request #581 from fnc12/bugfix/values-ast-iterator
fnc12 Aug 18, 2020
4a4a5e0
Update README.md
fnc12 Aug 25, 2020
250ce1c
added ast_iterator specialization for collate_t
fnc12 Sep 6, 2020
886602d
Merge pull request #589 from fnc12/fix-collate-ast-iteration
fnc12 Sep 6, 2020
5e4fe20
Fix GCC compile error regarding insufficient braces
undisputed-seraphim Sep 12, 2020
0fef00c
Silence shadowed variable warnings and re-run amalgamation scripts.
undisputed-seraphim Sep 14, 2020
2757ed1
Merge pull request #593 from undisputed-seraphim/silence_warnings
fnc12 Sep 14, 2020
cffcf32
added is_opened function and fixed transaction connection
fnc12 Sep 24, 2020
d8def5c
removed comments
fnc12 Sep 24, 2020
3a962a4
Merge pull request #596 from fnc12/bugfix/transaction-connection
fnc12 Sep 24, 2020
0e22589
added busy handler function
fnc12 Sep 28, 2020
35e7298
Merge pull request #600 from fnc12/busy-timeout
fnc12 Sep 28, 2020
97b87e5
Merge branch 'master' into update-readme2
fnc12 Sep 29, 2020
2ce815f
Update README.md
fnc12 Sep 29, 2020
a484917
Merge pull request #601 from fnc12/update-readme2
fnc12 Sep 29, 2020
5443933
Update TODO.md
fnc12 Oct 4, 2020
a4ae9f1
Update documentation on CMake
undisputed-seraphim Oct 6, 2020
76f4d7c
Merge pull request #605 from undisputed-seraphim/readme-fix
fnc12 Oct 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added <<, >>, & and | bitwise operators
  • Loading branch information
fnc12 committed Mar 9, 2020
commit fc5e7018ed9eb6bdff029a39b2d7df1c24d08a2b
20 changes: 20 additions & 0 deletions dev/column_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,26 @@ namespace sqlite_orm {
using type = double;
};

template<class St, class L, class R>
struct column_result_t<St, bitwise_shift_left_t<L, R>, void> {
using type = int;
};

template<class St, class L, class R>
struct column_result_t<St, bitwise_shift_right_t<L, R>, void> {
using type = int;
};

template<class St, class L, class R>
struct column_result_t<St, bitwise_and_t<L, R>, void> {
using type = int;
};

template<class St, class L, class R>
struct column_result_t<St, bitwise_or_t<L, R>, void> {
using type = int;
};

template<class St>
struct column_result_t<St, rowid_t, void> {
using type = int64;
Expand Down
69 changes: 68 additions & 1 deletion dev/operators.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,59 @@ namespace sqlite_orm {
template<class L, class R>
using mod_t = binary_operator<L, R, mod_string, arithmetic_t>;

struct bitwise_shift_left_string {
operator std::string() const {
return "<<";
}
};

/**
* Result of bitwise shift left << operator
*/
template<class L, class R>
using bitwise_shift_left_t = binary_operator<L, R, bitwise_shift_left_string, arithmetic_t>;

struct bitwise_shift_right_string {
operator std::string() const {
return ">>";
}
};

/**
* Result of bitwise shift right >> operator
*/
template<class L, class R>
using bitwise_shift_right_t = binary_operator<L, R, bitwise_shift_right_string, arithmetic_t>;

struct bitwise_and_string {
operator std::string() const {
return "&";
}
};

/**
* Result of bitwise and & operator
*/
template<class L, class R>
using bitwise_and_t = binary_operator<L, R, bitwise_and_string, arithmetic_t>;

struct bitwise_or_string {
operator std::string() const {
return "|";
}
};

/**
* Result of bitwise or | operator
*/
template<class L, class R>
using bitwise_or_t = binary_operator<L, R, bitwise_or_string, arithmetic_t>;

struct assign_string {
operator std::string() const {
return "=";
}
};

/**
* Result of assign = operator
*/
Expand Down Expand Up @@ -188,6 +235,26 @@ namespace sqlite_orm {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::bitwise_shift_left_t<L, R> bitwise_shift_left(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::bitwise_shift_right_t<L, R> bitwise_shift_right(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::bitwise_and_t<L, R> bitwise_and(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::bitwise_or_t<L, R> bitwise_or(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::assign_t<L, R> assign(L l, R r) {
return {std::move(l), std::move(r)};
Expand Down
89 changes: 88 additions & 1 deletion include/sqlite_orm/sqlite_orm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1143,12 +1143,59 @@ namespace sqlite_orm {
template<class L, class R>
using mod_t = binary_operator<L, R, mod_string, arithmetic_t>;

struct bitwise_shift_left_string {
operator std::string() const {
return "<<";
}
};

/**
* Result of bitwise shift left << operator
*/
template<class L, class R>
using bitwise_shift_left_t = binary_operator<L, R, bitwise_shift_left_string, arithmetic_t>;

struct bitwise_shift_right_string {
operator std::string() const {
return ">>";
}
};

/**
* Result of bitwise shift right >> operator
*/
template<class L, class R>
using bitwise_shift_right_t = binary_operator<L, R, bitwise_shift_right_string, arithmetic_t>;

struct bitwise_and_string {
operator std::string() const {
return "&";
}
};

/**
* Result of bitwise and & operator
*/
template<class L, class R>
using bitwise_and_t = binary_operator<L, R, bitwise_and_string, arithmetic_t>;

struct bitwise_or_string {
operator std::string() const {
return "|";
}
};

/**
* Result of bitwise or | operator
*/
template<class L, class R>
using bitwise_or_t = binary_operator<L, R, bitwise_or_string, arithmetic_t>;

struct assign_string {
operator std::string() const {
return "=";
}
};

/**
* Result of assign = operator
*/
Expand Down Expand Up @@ -1237,6 +1284,26 @@ namespace sqlite_orm {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::bitwise_shift_left_t<L, R> bitwise_shift_left(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::bitwise_shift_right_t<L, R> bitwise_shift_right(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::bitwise_and_t<L, R> bitwise_and(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::bitwise_or_t<L, R> bitwise_or(L l, R r) {
return {std::move(l), std::move(r)};
}

template<class L, class R>
internal::assign_t<L, R> assign(L l, R r) {
return {std::move(l), std::move(r)};
Expand Down Expand Up @@ -5684,6 +5751,26 @@ namespace sqlite_orm {
using type = double;
};

template<class St, class L, class R>
struct column_result_t<St, bitwise_shift_left_t<L, R>, void> {
using type = int;
};

template<class St, class L, class R>
struct column_result_t<St, bitwise_shift_right_t<L, R>, void> {
using type = int;
};

template<class St, class L, class R>
struct column_result_t<St, bitwise_and_t<L, R>, void> {
using type = int;
};

template<class St, class L, class R>
struct column_result_t<St, bitwise_or_t<L, R>, void> {
using type = int;
};

template<class St>
struct column_result_t<St, rowid_t, void> {
using type = int64;
Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ else()
add_subdirectory(third_party/sqlite)
endif()

add_executable(unit_tests tests.cpp tests2.cpp tests3.cpp tests4.cpp tests5.cpp private_getters_tests.cpp pragma_tests.cpp explicit_columns.cpp core_functions_tests.cpp constraints/composite_key.cpp static_tests.cpp operators/arithmetic_operators.cpp operators/like.cpp operators/glob.cpp operators/in.cpp operators/cast.cpp operators/is_null.cpp operators/not_operator.cpp dynamic_order_by.cpp prepared_statement_tests/select.cpp prepared_statement_tests/get_all.cpp prepared_statement_tests/get_all_pointer.cpp prepared_statement_tests/get_all_optional.cpp prepared_statement_tests/update_all.cpp prepared_statement_tests/remove_all.cpp prepared_statement_tests/get.cpp prepared_statement_tests/get_pointer.cpp prepared_statement_tests/get_optional.cpp prepared_statement_tests/update.cpp prepared_statement_tests/remove.cpp prepared_statement_tests/insert.cpp prepared_statement_tests/replace.cpp prepared_statement_tests/insert_range.cpp prepared_statement_tests/replace_range.cpp prepared_statement_tests/insert_explicit.cpp pragma_tests.cpp simple_query.cpp static_tests/is_bindable.cpp static_tests/arithmetic_operators_result_type.cpp static_tests/tuple_conc.cpp static_tests/node_tuple.cpp static_tests/bindable_filter.cpp static_tests/count_tuple.cpp static_tests/member_traits_tests.cpp static_tests/select_return_type.cpp constraints/default.cpp constraints/foreign_key.cpp constraints/check.cpp table_tests.cpp statement_serializator_tests/primary_key.cpp statement_serializator_tests/column_names.cpp statement_serializator_tests/autoincrement.cpp statement_serializator_tests/arithmetic_operators.cpp statement_serializator_tests/core_functions.cpp statement_serializator_tests/comparison_operators.cpp statement_serializator_tests/unique.cpp statement_serializator_tests/foreign_key.cpp statement_serializator_tests/collate.cpp statement_serializator_tests/check.cpp unique_cases/get_all_with_two_tables.cpp unique_cases/prepare_get_all_with_case.cpp)
add_executable(unit_tests tests.cpp tests2.cpp tests3.cpp tests4.cpp tests5.cpp private_getters_tests.cpp pragma_tests.cpp explicit_columns.cpp core_functions_tests.cpp constraints/composite_key.cpp static_tests.cpp operators/arithmetic_operators.cpp operators/like.cpp operators/glob.cpp operators/in.cpp operators/cast.cpp operators/is_null.cpp operators/not_operator.cpp operators/bitwise.cpp dynamic_order_by.cpp prepared_statement_tests/select.cpp prepared_statement_tests/get_all.cpp prepared_statement_tests/get_all_pointer.cpp prepared_statement_tests/get_all_optional.cpp prepared_statement_tests/update_all.cpp prepared_statement_tests/remove_all.cpp prepared_statement_tests/get.cpp prepared_statement_tests/get_pointer.cpp prepared_statement_tests/get_optional.cpp prepared_statement_tests/update.cpp prepared_statement_tests/remove.cpp prepared_statement_tests/insert.cpp prepared_statement_tests/replace.cpp prepared_statement_tests/insert_range.cpp prepared_statement_tests/replace_range.cpp prepared_statement_tests/insert_explicit.cpp pragma_tests.cpp simple_query.cpp static_tests/is_bindable.cpp static_tests/arithmetic_operators_result_type.cpp static_tests/tuple_conc.cpp static_tests/node_tuple.cpp static_tests/bindable_filter.cpp static_tests/count_tuple.cpp static_tests/member_traits_tests.cpp static_tests/select_return_type.cpp constraints/default.cpp constraints/foreign_key.cpp constraints/check.cpp table_tests.cpp statement_serializator_tests/primary_key.cpp statement_serializator_tests/column_names.cpp statement_serializator_tests/autoincrement.cpp statement_serializator_tests/arithmetic_operators.cpp statement_serializator_tests/core_functions.cpp statement_serializator_tests/comparison_operators.cpp statement_serializator_tests/unique.cpp statement_serializator_tests/foreign_key.cpp statement_serializator_tests/collate.cpp statement_serializator_tests/check.cpp unique_cases/get_all_with_two_tables.cpp unique_cases/prepare_get_all_with_case.cpp)


if(SQLITE_ORM_OMITS_CODECVT)
Expand Down
50 changes: 50 additions & 0 deletions tests/operators/bitwise.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <sqlite_orm/sqlite_orm.h>
#include <catch2/catch.hpp>

using namespace sqlite_orm;

TEST_CASE("bitwise operators") {
struct Entry {
int lhs = 0;
int rhs = 0;
};
auto storage =
make_storage({}, make_table("entries", make_column("lhs", &Entry::lhs), make_column("rhs", &Entry::rhs)));
storage.sync_schema();

{
auto rows = storage.select(bitwise_or(60, 13));
REQUIRE(rows == std::vector<int>{61});
}
{
auto rows = storage.select(bitwise_and(60, 13));
REQUIRE(rows == std::vector<int>{12});
}
{
auto rows = storage.select(bitwise_shift_left(60, 2));
REQUIRE(rows == std::vector<int>{240});
}
{
auto rows = storage.select(bitwise_shift_right(60, 2));
REQUIRE(rows == std::vector<int>{15});
}
storage.insert(Entry{60, 13});
{
auto rows = storage.select(bitwise_or(&Entry::lhs, &Entry::rhs));
REQUIRE(rows == std::vector<int>{61});
}
{
auto rows = storage.select(bitwise_and(&Entry::lhs, &Entry::rhs));
REQUIRE(rows == std::vector<int>{12});
}
storage.remove_all<Entry>();
storage.insert(Entry{60, 2});
{
auto rows = storage.select(bitwise_shift_left(&Entry::lhs, &Entry::rhs));
REQUIRE(rows == std::vector<int>{240});
}
{
auto rows = storage.select(bitwise_shift_right(&Entry::lhs, &Entry::rhs));
REQUIRE(rows == std::vector<int>{15});
}
}