15#include <boost/preprocessor/stringize.hpp>
16#include <boost/preprocessor/tuple.hpp>
35#ifndef ORAL_ADAPT_STRUCT
37#define ORAL_STRING_FIELD(_, index, tuple) \
38 if constexpr (Idx == index) \
39 return CtString { BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(index, tuple)) };
41#define ORAL_GET_FIELD(_, index, tuple) \
42 if constexpr (Idx == index) \
43 return s.BOOST_PP_TUPLE_ELEM(index, tuple);
45#define ORAL_GET_FIELD_INDEX_IMPL(index, sname, field) \
47 constexpr size_t FieldIndexAccess<sname>::FieldIndex<&sname::field> () { return index; }
49#define ORAL_GET_FIELD_INDEX(_, index, args) \
50 ORAL_GET_FIELD_INDEX_IMPL(index, BOOST_PP_TUPLE_ELEM(0, args), BOOST_PP_TUPLE_ELEM(index, BOOST_PP_TUPLE_ELEM(1, args)))
52#define ORAL_ADAPT_STRUCT(sname, ...) \
53namespace LC::Util::oral \
56 constexpr auto SeqSize<sname> = BOOST_PP_TUPLE_SIZE((__VA_ARGS__)); \
59 struct MemberNames<sname> \
61 template<size_t Idx> \
62 constexpr static auto Get () \
64 BOOST_PP_REPEAT(BOOST_PP_TUPLE_SIZE((__VA_ARGS__)), ORAL_STRING_FIELD, (__VA_ARGS__)) \
69 struct FieldAccess<sname> \
71 template<size_t Idx> \
72 constexpr static const auto& Get (const sname& s) \
74 BOOST_PP_REPEAT(BOOST_PP_TUPLE_SIZE((__VA_ARGS__)), ORAL_GET_FIELD, (__VA_ARGS__)) \
77 template<size_t Idx> \
78 constexpr static auto& Get (sname& s) \
80 BOOST_PP_REPEAT(BOOST_PP_TUPLE_SIZE((__VA_ARGS__)), ORAL_GET_FIELD, (__VA_ARGS__)) \
85 struct FieldIndexAccess<sname> \
88 constexpr static size_t FieldIndex (); \
91 BOOST_PP_REPEAT(BOOST_PP_TUPLE_SIZE((__VA_ARGS__)), ORAL_GET_FIELD_INDEX, (sname, (__VA_ARGS__))) \
103 using std::runtime_error::runtime_error;
122 template<
size_t Idx,
typename Seq>
123 constexpr decltype (
auto)
Get (
const Seq& seq)
128 template<
size_t Idx,
typename Seq>
129 constexpr decltype (
auto)
Get (Seq& seq)
134 template<
typename T, CtString str>
137 if constexpr (
requires { T::template FieldNameMorpher<str> (); })
138 return T::template FieldNameMorpher<str> ();
139 else if constexpr (str.EndsWith (
'_'))
140 return str.template Chop<1> ();
145 template<
typename Seq,
int Idx>
153 constexpr auto SeqIndices = std::make_index_sequence<SeqSize<S>> {};
156 constexpr auto FieldNames = []<
size_t... Ix> (std::index_sequence<Ix...>)
constexpr
162 constexpr auto BoundFieldNames = []<
size_t... Ix> (std::index_sequence<Ix...>)
constexpr
201 template<
typename ImplFactory,
typename T,
typename =
void>
204 constexpr auto operator() () const noexcept
208 else if constexpr (std::is_same_v<T, double>)
210 else if constexpr (std::is_same_v<T, QString> || std::is_same_v<T, QDateTime> || std::is_same_v<T, QUrl>)
212 else if constexpr (std::is_same_v<T, QByteArray>)
213 return ImplFactory::TypeLits::Binary;
219 static_assert (std::is_same_v<T, struct Dummy>,
"Unsupported type");
223 template<
typename ImplFactory,
typename T>
229 template<
typename ImplFactory,
typename T>
235 template<
typename ImplFactory,
typename T,
typename...
Tags>
241 template<
typename ImplFactory,
typename...
Tags>
244 constexpr auto operator() () const noexcept {
return ImplFactory::TypeLits::IntAutoincrement; }
247 template<
typename ImplFactory, auto Ptr>
250 constexpr auto operator() () const noexcept
258 template<
typename T,
typename =
void>
261 QVariant operator() (
const T& t)
const noexcept
263 if constexpr (std::is_same_v<T, QDateTime>)
264 return t.toString (Qt::ISODate);
265 else if constexpr (std::is_enum_v<T>)
266 return static_cast<qint64
> (t);
270 return t.ToVariant ();
278 template<
typename T,
typename =
void>
281 T operator() (
const QVariant& var)
const noexcept
283 if constexpr (std::is_same_v<T, QDateTime>)
284 return QDateTime::fromString (var.toString (), Qt::ISODate);
285 else if constexpr (std::is_enum_v<T>)
286 return static_cast<T
> (var.value<qint64> ());
290 return T::FromVariant (var);
294 return var.value<T> ();
300 template<
typename Seq,
int Idx>
301 using ValueAtC_t = std::decay_t<decltype (Get<Idx> (std::declval<Seq> ()))>;
306 template<
typename U,
typename...
Tags>
315 template<
size_t Ix,
typename Seq>
316 void BindAtIndex (
const Seq& seq, QSqlQuery& query,
bool bindPrimaryKey)
322 template<
typename Seq>
323 auto DoInsert (
const Seq& seq, QSqlQuery& insertQuery,
bool bindPrimaryKey)
325 [&]<
size_t... Ix> (std::index_sequence<Ix...>)
330 if (!insertQuery.exec ())
332 qCritical () <<
"insert query execution failed";
338 template<
typename Seq>
341 auto run = []<
size_t... Idxes> (std::index_sequence<Idxes...>)
350 template<
typename Seq>
354 static_assert (idx >= 0);
358 template<
typename Seq>
361 template<
typename Seq>
364 template<
typename Seq>
373 template<
typename Seq>
379 template<
typename Seq,
auto... Ptrs>
382 return std::tuple { std::get<FieldIndex<Ptrs> ()> (
FieldNames<Seq>)... };
385 template<
typename Seq>
388 const QSqlDatabase DB_;
396 template<
typename Action = InsertAction::DefaultTag>
397 auto operator() (Seq& t, Action action = {})
const
399 return Run<SQLite::ImplFactory> (t, action);
402 template<
typename ImplFactory>
403 auto operator() (ImplFactory, Seq& t,
auto action)
const
405 return Run<ImplFactory> (t, action);
408 template<
typename Action = InsertAction::DefaultTag>
409 auto operator() (
const Seq& t, Action action = {})
const
411 return Run<SQLite::ImplFactory> (t, action);
414 template<
typename ImplFactory>
415 auto operator() (ImplFactory,
const Seq& t,
auto action)
const
417 return Run<ImplFactory> (t, action);
420 template<
typename ImplFactory,
typename Action>
421 constexpr static auto MakeInsertSuffix (Action action)
423 if constexpr (std::is_same_v<Action, InsertAction::DefaultTag> || std::is_same_v<Action, InsertAction::IgnoreTag>)
424 return ImplFactory::GetInsertSuffix (action);
427 ExtractConflictingFields<Seq> (action),
431 template<
typename ImplFactory>
432 constexpr static auto MakeQueryForAction (
auto action)
434 return ImplFactory::GetInsertPrefix (action) +
435 " INTO " + Seq::ClassName +
436 " (" +
JoinTup (FieldNames<Seq>,
", ") +
") " +
437 "VALUES (" +
JoinTup (BoundFieldNames<Seq>,
", ") +
") " +
438 MakeInsertSuffix<ImplFactory> (action);
441 template<
typename ImplFactory,
typename T>
442 auto Run (T& t,
auto action)
const
444 QSqlQuery query { DB_ };
445 constexpr auto queryText = MakeQueryForAction<ImplFactory> (action);
446 query.prepare (ToString<queryText> ());
448 DoInsert (t, query, !HasAutogen_);
450 if constexpr (HasAutogen_)
452 constexpr auto index = PKeyIndex_v<Seq>;
454 const auto& lastId = FromVariant<ValueAtC_t<Seq, index>> {} (query.lastInsertId ());
455 if constexpr (!std::is_const_v<T>)
456 Get<index> (t) = lastId;
463 template<
typename Seq>
474 constexpr auto del =
"DELETE FROM " + Seq::ClassName +
489 template<
typename T,
size_t...
Indices>
522 template<ExprType Type>
544 static_assert (std::is_same_v<struct D1, ExprType>,
"Invalid expression type");
567 WrapDirect<T>>::value_type;
569 template<ExprType Type,
typename Seq,
typename L,
typename R>
576 return requires (LReal l, RReal r) { l == r; };
582 template<ExprType Type,
typename L =
void,
typename R =
void>
588 template<ExprType Type,
typename L,
typename R>
591 template<
typename L,
typename R>
603 template<
typename Seq, CtString S>
604 constexpr static auto ToSql () noexcept
607 return L::GetFieldName () +
" = " + R::template
ToSql<Seq, S +
"r"> ();
612 template<
typename Seq, CtString S>
615 Left_.template
BindValues<Seq, S +
"l"> (query);
616 Right_.template
BindValues<Seq, S +
"r"> (query);
619 template<
typename OL,
typename OR>
626 template<ExprType Type,
typename L,
typename R>
632 constexpr ExprTree (
const L& l,
const R& r) noexcept
638 template<
typename Seq, CtString S>
639 constexpr static auto ToSql () noexcept
642 "Incompatible types passed to a relational operator.");
647 template<
typename Seq, CtString S>
650 Left_.template
BindValues<Seq, S +
"l"> (query);
651 Right_.template
BindValues<Seq, S +
"r"> (query);
680 template<
typename, CtString S>
681 constexpr static auto ToSql () noexcept
683 return ":bound_" + S;
686 template<
typename Seq, CtString S>
696 return std::tuple {};
715 template<
auto... Ptr>
726 template<
typename Seq, CtString S>
727 constexpr static auto ToSql () noexcept
732 template<
typename Seq, CtString S>
746 if constexpr (std::is_same_v<Seq, T>)
747 return std::tuple {};
749 return std::tuple { Seq::ClassName };
755 return !std::is_same_v<MemberPtrStruct_t<Ptr>, T>;
758 constexpr auto operator= (
const ExpectedType_t& r)
const noexcept
768 template<
typename, CtString>
769 constexpr static auto ToSql () noexcept
774 template<
typename, CtString>
788 template<ExprType Type,
typename L,
typename R>
796 template<
typename L,
typename R>
806 template<
typename L,
typename R>
809 template<
typename L,
typename R,
typename = EnableRelOp_t<L, R>>
810 auto operator< (
const L& left,
const R& right)
noexcept
815 template<
typename L,
typename R,
typename = EnableRelOp_t<L, R>>
816 auto operator> (
const L& left,
const R& right)
noexcept
821 template<
typename L,
typename R,
typename = EnableRelOp_t<L, R>>
827 template<
typename L,
typename R,
typename = EnableRelOp_t<L, R>>
828 auto operator!= (
const L& left,
const R& right)
noexcept
833 template<ExprType Op>
844 template<
typename L, ExprType Op>
850 template<
typename L, ExprType Op>
856 template<
typename L, ExprType Op,
typename R>
862 template<
typename L,
typename R,
typename = EnableRelOp_t<L, R>>
863 auto operator&& (
const L& left,
const R& right)
noexcept
868 template<
typename L,
typename R,
typename = EnableRelOp_t<L, R>>
869 auto operator|| (
const L& left,
const R& right)
noexcept
874 template<CtString BindPrefix,
typename Seq,
typename Tree>
877 return Tree::template ToSql<Seq, BindPrefix> ();
880 template<CtString BindPrefix,
typename Seq,
typename Tree>
883 tree.template BindValues<Seq, BindPrefix> (query);
893 template<AggregateFunction, auto Ptr>
900 template<
typename... MemberDirectionList>
903 template<
auto... Ptrs>
908 template<
typename L,
typename R>
917 template<AggregateFunction Fun, auto Ptr>
920 template<
auto... Ptrs>
923 template<
typename L,
typename R>
926 template<
typename L,
typename R,
typename = std::enable_if_t<IsSelector<L> {} && IsSelector<R> {}>>
938 template<
auto... Ptrs>
943 template<
auto... Ptrs>
946 template<
auto... Ptrs>
949 template<auto Ptr = detail::CountAllPtr>
959 template<
typename... Orders>
962 template<
auto... Ptrs>
989 template<
auto... Ptrs>
992 if constexpr (
sizeof... (Ptrs) == 1)
995 return [&]<
size_t... Ix> (std::index_sequence<Ix...>)
998 } (std::make_index_sequence<
sizeof... (Ptrs)> {});
1008 template<
size_t RepIdx,
size_t TupIdx,
typename Tuple,
typename NewType>
1011 if constexpr (RepIdx == TupIdx)
1012 return std::forward<NewType> (arg);
1014 return std::get<TupIdx> (tuple);
1017 template<
size_t RepIdx,
typename NewType,
typename Tuple,
size_t... TupIdxs>
1026 template<
size_t RepIdx,
typename NewType,
typename... TupleArgs>
1030 std::forward<NewType> (arg),
1031 std::index_sequence_for<TupleArgs...> {});
1034 template<
typename Seq,
typename T>
1040 template<
typename Seq,
typename... Args>
1046 template<
typename Seq>
1052 template<
typename... LArgs,
typename... RArgs>
1053 auto Combine (std::tuple<LArgs...>&& left, std::tuple<RArgs...>&& right)
noexcept
1055 return std::tuple_cat (std::move (left), std::move (right));
1058 template<
typename... LArgs,
typename R>
1059 auto Combine (std::tuple<LArgs...>&& left,
const R& right)
noexcept
1061 return std::tuple_cat (std::move (left), std::tuple { right });
1064 template<
typename L,
typename... RArgs>
1065 auto Combine (
const L& left, std::tuple<RArgs...>&& right)
noexcept
1067 return std::tuple_cat (std::tuple { left }, std::move (right));
1070 template<
typename L,
typename R>
1071 auto Combine (
const L& left,
const R& right)
noexcept
1073 return std::tuple { left, right };
1082 template<ResultBehaviour ResultBehaviour,
typename ResList>
1086 return std::forward<ResList> (list);
1088 return list.value (0);
1091 template<
typename F,
typename R>
1099 template<
typename F,
typename R>
1104 const QSqlDatabase DB_;
1112 auto&& binder)
const
1114 QSqlQuery query { DB_ };
1115 query.prepare (queryStr);
1120 qCritical () <<
"select query execution failed";
1129 template<
typename L,
typename O>
1132 if constexpr (std::is_same_v<L, LimitNone>)
1134 static_assert (std::is_same_v<O, OffsetNone>,
"LIMIT-less queries currently cannot have OFFSET");
1138 return " LIMIT :limit "_ct +
1141 if constexpr (std::is_same_v<O, OffsetNone>)
1144 return " OFFSET :offset"_ct;
1148 template<
typename L,
typename O>
1151 if constexpr (!std::is_same_v<std::decay_t<L>,
LimitNone>)
1152 query.bindValue (
":limit", qulonglong { limit.Count });
1153 if constexpr (!std::is_same_v<std::decay_t<O>,
OffsetNone>)
1154 query.bindValue (
":offset", qulonglong { offset.Count });
1157 template<
typename T,
typename Selector>
1164 template<
typename T>
1175 template<
typename T,
auto... Ptrs>
1179 template<
size_t... Ixs>
1180 constexpr static auto SelectFields ()
1193 template<
typename T>
1196 constexpr inline static auto Fields =
"count(1)"_ct;
1200 return q.value (startIdx).toLongLong ();
1204 template<
typename T, auto Ptr>
1211 return q.value (startIdx).toLongLong ();
1215 template<CtString Aggregate,
typename T, auto Ptr>
1226 template<
typename T, auto Ptr>
1229 template<
typename T, auto Ptr>
1239 template<
typename T,
typename L,
typename R>
1247 constexpr inline static auto Fields = HL::Fields +
", " + HR::Fields;
1251 constexpr auto shift =
DetectShift<T,
decltype (HL::Initializer (q, 0))>::Value;
1252 return Combine (HL::Initializer (q, startIdx), HR::Initializer (q, startIdx + shift));
1256 template<
typename T, SelectBehaviour SelectBehaviour>
1259 template<
typename ParamsTuple>
1263 ParamsTuple Params_;
1265 template<
typename NewTuple>
1266 constexpr auto RepTuple (NewTuple&& tuple)
noexcept
1268 return Builder<NewTuple> { W_, tuple };
1271 template<
typename U>
1272 constexpr auto Select (U&& selector) &&
noexcept
1277 template<
typename U>
1278 constexpr auto Where (U&& tree) &&
noexcept
1283 template<
typename U>
1284 constexpr auto Order (U&& order) &&
noexcept
1289 template<
typename U>
1290 constexpr auto Group (U&& group) &&
noexcept
1295 constexpr auto Limit (
Limit limit) &&
noexcept
1300 constexpr auto Limit (uint64_t limit) &&
noexcept
1302 return std::move (*this).Limit (
oral::Limit { limit });
1310 constexpr auto Offset (uint64_t offset) &&
noexcept
1312 return std::move (*this).Offset (
oral::Offset { offset });
1315 auto operator() () &&
1317 return std::apply (W_, Params_);
1320 template<
auto... Ptrs>
1321 constexpr auto Group () &&
noexcept
1331 std::tuple defParams
1340 return Builder<
decltype (defParams)> { *
this, defParams };
1343 auto operator() ()
const
1348 template<
typename Single>
1349 auto operator() (Single&& single)
const
1352 return (*
this) (
SelectWhole {}, std::forward<Single> (single));
1359 ExprType Type,
typename L,
typename R,
1365 auto operator() (Selector,
1369 Limit limit = LimitNone {},
1370 Offset offset = OffsetNone {})
const
1372 using TreeType_t = ExprTree<Type, L, R>;
1374 constexpr auto where = ExprTreeToSql<
"", T, TreeType_t> ();
1375 constexpr auto wherePrefix = [where]
1377 if constexpr (where.IsEmpty ())
1380 return " WHERE "_ct;
1382 constexpr auto from = BuildFromClause<TreeType_t> ();
1383 const auto binder = [&] (QSqlQuery& query)
1385 BindExprTree<
"", T> (tree, query);
1386 BindLimitOffset (query, limit, offset);
1388 using HS = HandleSelector<T, Selector>;
1390 constexpr auto query =
"SELECT " + HS::Fields +
1392 wherePrefix + where +
1393 HandleOrder (std::forward<Order> (order)) +
1394 HandleGroup (std::forward<Group> (group)) +
1395 LimitOffsetToString<Limit, Offset> ();
1396 auto selectResult = Select<HS> (ToString<query> (),
1398 return HandleResultBehaviour<HS::ResultBehaviour_v> (std::move (selectResult));
1401 template<
typename HS,
typename Binder>
1402 auto Select (
const QString& queryStr,
1403 Binder&& binder)
const
1405 auto query =
RunQuery (queryStr, binder);
1409 QList<
decltype (HS::Initializer (query, 0))> result;
1410 while (query.next ())
1411 result << HS::Initializer (query, 0);
1416 using RetType_t = std::optional<
decltype (HS::Initializer (query, 0))>;
1417 return query.next () ?
1418 RetType_t { HS::Initializer (query, 0) } :
1423 template<
typename Tree>
1424 consteval static auto BuildFromClause () noexcept
1426 if constexpr (Tree::template HasAdditionalTables<T> ())
1427 return T::ClassName +
", " + JoinTup (Nub<Tree::template AdditionalTables<T>> (),
", ");
1429 return T::ClassName;
1432 constexpr static auto HandleOrder (OrderNone)
noexcept
1437 template<
auto... Ptrs>
1438 constexpr static auto HandleSuborder (sph::asc<Ptrs...>)
noexcept
1440 return std::tuple { (GetQualifiedFieldNamePtr<Ptrs> () +
" ASC")... };
1443 template<
auto... Ptrs>
1444 constexpr static auto HandleSuborder (sph::desc<Ptrs...>)
noexcept
1446 return std::tuple { (GetQualifiedFieldNamePtr<Ptrs> () +
" DESC")... };
1449 template<
typename... Suborders>
1450 constexpr static auto HandleOrder (OrderBy<Suborders...>)
noexcept
1452 return " ORDER BY " +
JoinTup (std::tuple_cat (HandleSuborder (Suborders {})...),
", ");
1455 constexpr static auto HandleGroup (GroupNone)
noexcept
1460 template<
auto... Ptrs>
1461 constexpr static auto HandleGroup (GroupBy<Ptrs...>)
noexcept
1463 return " GROUP BY " +
Join (
", ", GetQualifiedFieldNamePtr<Ptrs> ()...);
1467 template<
typename T>
1470 const QSqlDatabase DB_;
1477 template<ExprType Type,
typename L,
typename R>
1482 constexpr auto selectAll =
"DELETE FROM " + T::ClassName +
" WHERE " + where;
1484 QSqlQuery query { DB_ };
1491 template<
typename T>
1494 const QSqlDatabase DB_;
1497 QSqlQuery UpdateByPKey_ { DB_ };
1506 constexpr auto update =
"UPDATE " + T::ClassName +
1507 " SET " +
JoinTup (statements,
", ") +
1508 " WHERE " + std::get<pkeyIdx> (statements);
1515 DoInsert (seq, UpdateByPKey_,
true);
1518 template<
typename SL,
typename SR, ExprType WType,
typename WL,
typename WR>
1522 "joins in update statements are not supported by SQL");
1527 constexpr auto update =
"UPDATE " + T::ClassName +
1528 " SET " + setClause +
1529 " WHERE " + whereClause;
1531 QSqlQuery query { DB_ };
1537 qCritical () <<
"update query execution failed";
1542 return query.numRowsAffected ();
1546 template<
typename T,
size_t... Fields>
1552 template<
typename T,
size_t... Fields>
1555 return "PRIMARY KEY (" +
Join (
", ", std::get<Fields> (
FieldNames<T>)...) +
")";
1558 template<
typename T>
1561 if constexpr (
requires {
typename T::Constraints; })
1563 return []<
typename... Args> (
Constraints<Args...>)
1566 } (
typename T::Constraints {});
1569 return std::tuple<> {};
1572 template<
typename ImplFactory,
typename T,
size_t...
Indices>
1573 constexpr auto GetTypes (std::index_sequence<Indices...>)
noexcept
1578 template<auto Name,
typename ImplFactory,
typename T>
1584 constexpr auto constraintsStr = [&]
1586 if constexpr (!std::tuple_size_v<
decltype (constraints)>)
1589 return ", " +
JoinTup (constraints,
", ");
1593 return "CREATE TABLE " +
1601 template<
typename ImplFactory,
typename T>
1608 template<
typename T>
1622 template<
typename T,
typename ImplFactory = detail::SQLite::ImplFactory>
1643 template<
typename T>
1646 template<
typename T,
typename ImplFactory = SQLiteImplFactory>
1652 template<
typename ImplFactory,
typename... Ts>
static UTIL_DB_API void DumpError(const QSqlError &error)
Dumps the error to the qWarning() stream.
A somewhat "strong" typedef.
~QueryException() noexcept=default
AdaptInsert(const QSqlDatabase &db) noexcept
AdaptUpdate(const QSqlDatabase &db) noexcept
constexpr AssignList(const L &l, const R &r) noexcept
void BindValues(QSqlQuery &query) const noexcept
static constexpr auto ToSql() noexcept
DeleteByFieldsWrapper(const QSqlDatabase &db) noexcept
static constexpr bool HasAdditionalTables() noexcept
void BindValues(QSqlQuery &) const noexcept
static constexpr auto ToSql() noexcept
static constexpr auto ToSql() noexcept
static constexpr auto AdditionalTables() noexcept
void BindValues(QSqlQuery &query) const noexcept
static constexpr bool HasAdditionalTables() noexcept
constexpr ExprTree(const T &t) noexcept
ExpectedType_t ValueType_t
static constexpr bool HasAdditionalTables() noexcept
static constexpr auto GetFieldName() noexcept
static constexpr auto ToSql() noexcept
void BindValues(QSqlQuery &) const noexcept
static constexpr auto AdditionalTables() noexcept
constexpr ExprTree(const L &l, const R &r) noexcept
static constexpr bool HasAdditionalTables() noexcept
void BindValues(QSqlQuery &query) const noexcept
static constexpr auto ToSql() noexcept
static constexpr auto AdditionalTables() noexcept
auto RunQuery(const QString &queryStr, auto &&binder) const
SelectWrapperCommon(const QSqlDatabase &db) noexcept
SelectWrapperCommon(const QSqlDatabase &db) noexcept
auto Build() const noexcept
auto operator==(const T &left, const T &right)
QSqlQuery RunTextQuery(const QSqlDatabase &db, const QString &text)
Runs the given query text on the given db.
void RunQuery(const QSqlDatabase &db, const QString &pluginName, const QString &filename)
Loads the query from the given resource file and runs it.
constexpr auto GetTypes(std::index_sequence< Indices... >) noexcept
constexpr auto AdaptCreateTableNamed() noexcept
auto MakeIndexedQueryHandler(const QSqlQuery &q, int startIdx=0) noexcept
consteval int PKeyIndex()
constexpr auto GetFieldNamePtr() noexcept
constexpr auto GetQualifiedFieldNamePtr() noexcept
constexpr auto ExprTreeToSql() noexcept
constexpr auto AsLeafData(const T &node) noexcept
constexpr auto LimitOffsetToString() noexcept
T InitializeFromQuery(const QSqlQuery &q, std::index_sequence< Indices... >, int startIdx) noexcept
void BindLimitOffset(QSqlQuery &query, L limit, O offset) noexcept
auto Combine(std::tuple< LArgs... > &&left, std::tuple< RArgs... > &&right) noexcept
constexpr auto GetConstraintsStrings() noexcept
std::enable_if_t< EitherIsExprTree< L, R >()> EnableRelOp_t
consteval int PKeyIndexUnsafe()
decltype(auto) HandleResultBehaviour(ResList &&list) noexcept
constexpr CountAll * CountAllPtr
constexpr auto ConstTrueTree_v
auto DoInsert(const Seq &seq, QSqlQuery &insertQuery, bool bindPrimaryKey)
constexpr decltype(auto) Get(const Seq &seq)
QVariant ToVariantF(const T &t) noexcept
constexpr bool IsRelational(ExprType type) noexcept
constexpr auto AdaptCreateTable() noexcept
auto MemberFromVariant(const QVariant &var) noexcept
constexpr auto FieldNames
constexpr auto ExtractConstraintFields(UniqueSubset< Fields... >)
consteval auto GetFieldName()
constexpr auto TypeToSql() noexcept
constexpr decltype(auto) GetReplaceTupleElem(Tuple &&tuple, NewType &&arg) noexcept
constexpr auto BoundFieldNames
constexpr auto ReplaceTupleElem(std::tuple< TupleArgs... > &&tuple, NewType &&arg) noexcept
constexpr auto CombineBehaviour(ResultBehaviour l, ResultBehaviour r) noexcept
constexpr bool EitherIsExprTree() noexcept
auto MakeExprTree(const L &left, const R &right) noexcept
void BindAtIndex(const Seq &seq, QSqlQuery &query, bool bindPrimaryKey)
constexpr auto QualifiedFieldNames
std::decay_t< decltype(Get< Idx >(std::declval< Seq >()))> ValueAtC_t
constexpr auto ReplaceTupleElemImpl(Tuple &&tuple, NewType &&arg, std::index_sequence< TupIdxs... >) noexcept
constexpr auto ExtractConflictingFields(InsertAction::Replace::PKeyType)
constexpr bool Typecheck()
typename std::conditional_t< IsIndirect< T > {}, T, WrapDirect< T > >::value_type UnwrapIndirect_t
void BindExprTree(const Tree &tree, QSqlQuery &query)
constexpr size_t FieldIndex() noexcept
constexpr int PKeyIndex_v
consteval auto MorphFieldName()
constexpr auto SeqIndices
constexpr auto HasAutogenPKey() noexcept
constexpr detail::InfixBinary< detail::ExprType::Like > like
constexpr detail::ExprTree< detail::ExprType::LeafStaticPlaceholder, detail::MemberPtrs< Ptr > > f
constexpr detail::SelectWhole all
constexpr detail::AggregateType< detail::AggregateFunction::Count, Ptr > count
constexpr detail::AggregateType< detail::AggregateFunction::Min, Ptr > min
constexpr detail::MemberPtrs< Ptrs... > fields
constexpr detail::AggregateType< detail::AggregateFunction::Max, Ptr > max
void AdaptPtrs(const QSqlDatabase &db, ObjectInfo_ptr< Ts > &... objects)
Typelist< Args... > Constraints
ObjectInfo_ptr< T > AdaptPtr(const QSqlDatabase &db)
constexpr detail::OrderBy< Orders... > OrderBy
Typelist< Args... > Indices
constexpr detail::GroupBy< Ptrs... > GroupBy
ObjectInfo< T > Adapt(const QSqlDatabase &db)
std::unique_ptr< ObjectInfo< T > > ObjectInfo_ptr
std::shared_ptr< QSqlQuery > QSqlQuery_ptr
typename AsTypelist< T >::Result_t AsTypelist_t
std::tuple_element_t< 0, detail::CallTypeGetter_t< F > > RetType_t
constexpr auto ZipWith(Tup1 &&tup1, auto &&sep, Tup2 &&tup2) noexcept
constexpr auto JoinTup(auto &&stringsTuple, auto &&sep) noexcept
constexpr bool HasType(List< Args... >)
MemberTypeType_t< decltype(Ptr)> MemberPtrType_t
constexpr auto Join(auto &&) noexcept
MemberTypeStruct_t< decltype(Ptr)> MemberPtrStruct_t
detail::AdaptUpdate< T > Update
detail::SelectWrapper< T, detail::SelectBehaviour::Some > Select
detail::AdaptDelete< T > Delete
detail::AdaptInsert< T > Insert
detail::DeleteByFieldsWrapper< T > DeleteBy
detail::SelectWrapper< T, detail::SelectBehaviour::One > SelectOne
AdaptDelete(const QSqlDatabase &db) noexcept
static constexpr int Value
static constexpr int Value
static constexpr int Value
static constexpr auto ResultBehaviour_v
static constexpr auto ResultBehaviour_v
static auto Initializer(const QSqlQuery &q, int startIdx) noexcept
static constexpr auto Fields
static auto Initializer(const QSqlQuery &q, int startIdx)
static constexpr auto Fields
static constexpr auto Fields
static auto Initializer(const QSqlQuery &q, int startIdx)
static constexpr auto Fields
static auto Initializer(const QSqlQuery &q, int startIdx) noexcept
static auto Initializer(const QSqlQuery &q, int startIdx)
static constexpr auto Fields
static constexpr auto Fields
static constexpr auto ResultBehaviour_v
HandleSelector< T, L > HL
static auto Initializer(const QSqlQuery &q, int startIdx) noexcept
HandleSelector< T, R > HR