Skip to content

Commit

Permalink
added a new withPivot() overload
Browse files Browse the repository at this point in the history
  • Loading branch information
silverqx committed Sep 1, 2022
1 parent 6d6ad32 commit 97a12a9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/orm/tiny/relations/concerns/interactswithpivottable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ TINY_SYSTEM_HEADER
#include <range/v3/view/set_algorithm.hpp>

#include "orm/exceptions/domainerror.hpp"
#include "orm/ormconcepts.hpp"
#include "orm/tiny/types/syncchanges.hpp"
#include "orm/tiny/utils/attribute.hpp"
#include "orm/utils/query.hpp"
Expand Down Expand Up @@ -83,6 +84,9 @@ namespace Concerns
BelongsToManyType &withPivot(QStringList &&columns);
/*! Set the columns on the pivot table to retrieve. */
inline BelongsToManyType &withPivot(QString &&column);
/*! Set the columns on the pivot table to retrieve. */
template<QStringConcept ...Args>
BelongsToManyType &withPivot(Args &&...columns);

/*! Determine whether the given column is defined as a pivot column. */
inline bool hasPivotColumn(const QString &column) const;
Expand Down Expand Up @@ -347,6 +351,14 @@ namespace Concerns
return withPivot(QStringList {std::move(column)});
}

template<class Model, class Related, class PivotType>
template<QStringConcept ...Args>
BelongsToMany<Model, Related, PivotType> &
InteractsWithPivotTable<Model, Related, PivotType>::withPivot(Args &&...columns)
{
return withPivot(QStringList {std::forward<Args>(columns)...});
}

template<class Model, class Related, class PivotType>
bool InteractsWithPivotTable<Model, Related, PivotType>::hasPivotColumn(
const QString &column) const
Expand Down

0 comments on commit 97a12a9

Please sign in to comment.