Skip to content

Commit

Permalink
moved method down
Browse files Browse the repository at this point in the history
  • Loading branch information
silverqx committed Aug 30, 2022
1 parent ff6c418 commit b853e7f
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions include/orm/tiny/relations/basepivot.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ namespace Orm::Tiny::Relations
fromRawAttributes(const Parent &parent, const QVector<AttributeItem> &attributes,
const QString &table, bool exists = false);

/*! Set the key names for the pivot model instance. */
PivotModel &setPivotKeys(const QString &foreignKey, const QString &relatedKey);
/*! Determine if the pivot model or given attributes has timestamp attributes. */
bool hasTimestampAttributes(const QVector<AttributeItem> &attributes) const;
/*! Determine if the pivot model or given attributes has timestamp attributes. */
Expand All @@ -68,6 +66,9 @@ namespace Orm::Tiny::Relations
/*! Get the "related key" column name. */
const QString &getRelatedKey() const noexcept;

/*! Set the key names for the pivot model instance. */
PivotModel &setPivotKeys(const QString &foreignKey, const QString &relatedKey);

// TODO fuckup, timestamps in pivot, the solution is to set CREATED_AT and UPDATED_AT right away in the fromAttributes method when I still have access to the parent, then I won't have to save a pointer to the parent. I can still save pointer to parent, but not for obtaining this timestamp column names. old - I will solve it when I will have to use timestamps in the code, anyway may be I will not need it, because I can pass to the method right away what I will need silverqx
// TODO also don't forget unsetRelations() if pivotParent will be implemented silverqx
/*! The parent model of the relationship. */
Expand Down Expand Up @@ -162,18 +163,6 @@ namespace Orm::Tiny::Relations
return instance;
}

template<typename PivotModel>
PivotModel &
BasePivot<PivotModel>::setPivotKeys(const QString &foreignKey,
const QString &relatedKey)
{
m_foreignKey = foreignKey;

m_relatedKey = relatedKey;

return this->model();
}

template<typename PivotModel>
bool BasePivot<PivotModel>::hasTimestampAttributes(
const QVector<AttributeItem> &attributes) const
Expand Down Expand Up @@ -255,6 +244,18 @@ namespace Orm::Tiny::Relations
return m_relatedKey;
}

template<typename PivotModel>
PivotModel &
BasePivot<PivotModel>::setPivotKeys(const QString &foreignKey,
const QString &relatedKey)
{
m_foreignKey = foreignKey;

m_relatedKey = relatedKey;

return this->model();
}

/* protected */

/* AsPivot */
Expand Down

0 comments on commit b853e7f

Please sign in to comment.