Skip to content

Commit

Permalink
simplified the code
Browse files Browse the repository at this point in the history
  • Loading branch information
fnc12 committed Oct 12, 2023
1 parent cee7582 commit 01805b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
11 changes: 5 additions & 6 deletions dev/serializing_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,12 +372,11 @@ namespace sqlite_orm {
ss << sep[std::exchange(first, false)];
ss << serialize(constraint, context);
});
using ConstraintsTuple = decltype(column.constraints);
constexpr bool constraintsHaveNullConstraint =
mpl::invoke_t<check_if_tuple_has_type<null_t>, ConstraintsTuple>::value;
constexpr bool constraintsHaveNotNullConstraint =
mpl::invoke_t<check_if_tuple_has_type<not_null_t>, ConstraintsTuple>::value;
if(!constraintsHaveNullConstraint && !constraintsHaveNotNullConstraint) {
using constraints_tuple = decltype(column.constraints);
constexpr bool hasExplicitNullableConstraint =
mpl::invoke_t<mpl::disjunction<check_if_tuple_has_type<null_t>, check_if_tuple_has_type<not_null_t>>,
constraints_tuple>::value;
if(!hasExplicitNullableConstraint) {
ss << sep[std::exchange(first, false)];
if(isNotNull) {
ss << "NOT NULL";
Expand Down
11 changes: 5 additions & 6 deletions include/sqlite_orm/sqlite_orm.h
Original file line number Diff line number Diff line change
Expand Up @@ -13682,12 +13682,11 @@ namespace sqlite_orm {
ss << sep[std::exchange(first, false)];
ss << serialize(constraint, context);
});
using ConstraintsTuple = decltype(column.constraints);
constexpr bool constraintsHaveNullConstraint =
mpl::invoke_t<check_if_tuple_has_type<null_t>, ConstraintsTuple>::value;
constexpr bool constraintsHaveNotNullConstraint =
mpl::invoke_t<check_if_tuple_has_type<not_null_t>, ConstraintsTuple>::value;
if(!constraintsHaveNullConstraint && !constraintsHaveNotNullConstraint) {
using constraints_tuple = decltype(column.constraints);
constexpr bool hasExplicitNullableConstraint =
mpl::invoke_t<mpl::disjunction<check_if_tuple_has_type<null_t>, check_if_tuple_has_type<not_null_t>>,
constraints_tuple>::value;
if(!hasExplicitNullableConstraint) {
ss << sep[std::exchange(first, false)];
if(isNotNull) {
ss << "NOT NULL";
Expand Down

0 comments on commit 01805b8

Please sign in to comment.