renamed method to detachAll(bool)

To avoid unwanted overload resolution because of int to bool conversion.

 - also updated docs
This commit is contained in:
silverqx
2023-12-20 14:48:04 +01:00
parent d9a794c7f7
commit 953dad6d57
3 changed files with 6 additions and 6 deletions

View File

@@ -1229,7 +1229,7 @@ Sometimes it may be necessary to remove a role from a user. To remove a many-to-
user->roles()->detach(roleId);
// Detach all roles from the user...
user->roles()->detach();
user->roles()->detachAll();
For convenience, `attach` and `detach` also accept vectors of IDs or Model instances as input:

View File

@@ -128,8 +128,8 @@ namespace Concerns
/*! Detach models from the relationship. */
inline int detach(const QVector<QVariant> &ids, bool touch = true) const;
/*! Detach models from the relationship. */
inline int detach(bool touch = true) const;
/*! Detach all models from the relationship. */
inline int detachAll(bool touch = true) const;
/*! Detach models from the relationship. */
inline int detach(const QVector<std::reference_wrapper<Related>> &models,
bool touch = true) const;
@@ -523,7 +523,7 @@ namespace Concerns
template<class Model, class Related, class PivotType>
int
InteractsWithPivotTable<Model, Related, PivotType>::detach(const bool touch) const
InteractsWithPivotTable<Model, Related, PivotType>::detachAll(const bool touch) const
{
return detach(true, {}, touch);
}

View File

@@ -2024,7 +2024,7 @@ void tst_Relations_Inserting_Updating::detach_BasicPivot_All() const
QCOMPARE(tagged["active"].value(), QVariant(false));
}
auto affected = tag5->torrents()->detach(false);
auto affected = tag5->torrents()->detachAll(false);
QCOMPARE(affected, 2);
@@ -2192,7 +2192,7 @@ void tst_Relations_Inserting_Updating::detach_CustomPivot_All() const
QCOMPARE(tagged["active"].value(), QVariant(false));
}
auto affected = torrent5->tags()->detach(false);
auto affected = torrent5->tags()->detachAll(false);
QCOMPARE(affected, 2);