diff --git a/drivers/common/include/orm/drivers/sqlrecord.hpp b/drivers/common/include/orm/drivers/sqlrecord.hpp index 6c46c558d..891ca21c0 100644 --- a/drivers/common/include/orm/drivers/sqlrecord.hpp +++ b/drivers/common/include/orm/drivers/sqlrecord.hpp @@ -41,6 +41,9 @@ namespace Orm::Drivers /*! Swap the SqlRecord. */ inline void swap(SqlRecord &other) noexcept; + /*! Get all field names. */ + QStringList fieldNames() const; + /*! Get the field name at the given index. */ QString fieldName(size_type index) const; /*! Get the index of the given field name (-1 if it can't be found). */ diff --git a/drivers/common/src/orm/drivers/sqlrecord.cpp b/drivers/common/src/orm/drivers/sqlrecord.cpp index 38f5fbec7..23a57dc5e 100644 --- a/drivers/common/src/orm/drivers/sqlrecord.cpp +++ b/drivers/common/src/orm/drivers/sqlrecord.cpp @@ -17,6 +17,17 @@ namespace Orm::Drivers /* public */ +QStringList SqlRecord::fieldNames() const +{ + QStringList result; + result.reserve(m_fields.size()); + + for (const auto &field : m_fields) + result << field.name(); + + return result; +} + QString SqlRecord::fieldName(const size_type index) const { return m_fields.value(index).name();