diff --git a/include/orm/tiny/relations/belongsto.hpp b/include/orm/tiny/relations/belongsto.hpp index 713f87482..8c9479b60 100644 --- a/include/orm/tiny/relations/belongsto.hpp +++ b/include/orm/tiny/relations/belongsto.hpp @@ -71,10 +71,20 @@ namespace Orm::Tiny::Relations inline Model &disassociate() const; /* Getters / Setters */ - /*! Get the name of the relationship. */ - inline const QString &getRelationName() const noexcept; + /*! Get the child of the relationship. */ + inline const Model &getChild() const noexcept; + /*! Get the key value of the child's foreign key. */ + inline QVariant getParentKey() const; + /*! Get the associated key of the relationship. */ + inline const QString &getOwnerKeyName() const noexcept; + /*! Get the fully qualified associated key of the relationship. */ + inline QString getQualifiedOwnerKeyName() const; + /*! Get the foreign key of the relationship. */ + inline const QString &getForeignKeyName() const noexcept; /*! Get the fully qualified foreign key of the relationship. */ inline QString getQualifiedForeignKeyName() const; + /*! Get the name of the relationship. */ + inline const QString &getRelationName() const noexcept; /* Others */ /*! The textual representation of the Relation type. */ @@ -289,9 +299,33 @@ namespace Orm::Tiny::Relations /* Getters / Setters */ template - const QString &BelongsTo::getRelationName() const noexcept + const Model &BelongsTo::getChild() const noexcept { - return m_relationName; + return m_child; + } + + template + QVariant BelongsTo::getParentKey() const + { + return m_child.getAttribute(m_foreignKey); + } + + template + const QString &BelongsTo::getOwnerKeyName() const noexcept + { + return m_ownerKey; + } + + template + QString BelongsTo::getQualifiedOwnerKeyName() const + { + return this->m_related->qualifyColumn(m_ownerKey); + } + + template + const QString &BelongsTo::getForeignKeyName() const noexcept + { + return m_foreignKey; } template @@ -300,6 +334,12 @@ namespace Orm::Tiny::Relations return m_child.qualifyColumn(m_foreignKey); } + template + const QString &BelongsTo::getRelationName() const noexcept + { + return m_relationName; + } + /* Others */ template