added some additional methods to table for later use

This commit is contained in:
Sascha Kühl 2026-02-12 16:16:46 +01:00
parent 4c63322024
commit 746fd9e8d2
2 changed files with 30 additions and 0 deletions

View File

@ -27,6 +27,7 @@ public:
[[nodiscard]] const std::string& table_name() const; [[nodiscard]] const std::string& table_name() const;
[[nodiscard]] const std::string& name() const; [[nodiscard]] const std::string& name() const;
[[nodiscard]] std::string schema_name() const;
[[nodiscard]] const std::vector<table_column>& columns() const; [[nodiscard]] const std::vector<table_column>& columns() const;
[[nodiscard]] bool has_alias() const; [[nodiscard]] bool has_alias() const;
@ -37,6 +38,12 @@ public:
const table_column* operator[](const std::string& column_name) const; const table_column* operator[](const std::string& column_name) const;
static const table_column* column_by_name(const table &tab, const std::string& column_name); static const table_column* column_by_name(const table &tab, const std::string& column_name);
[[nodiscard]] bool is_relation_table() const;
[[nodiscard]] bool has_primary_key() const;
[[nodiscard]] const std::string& join_column_name() const;
[[nodiscard]] const std::string& inverse_join_column_name() const;
protected: protected:
static const table_column& create_column(class table& tab, const std::string& name); static const table_column& create_column(class table& tab, const std::string& name);
@ -50,6 +57,10 @@ private:
std::string schema_name_; std::string schema_name_;
std::vector<table_column> columns_; std::vector<table_column> columns_;
std::string pk_column_name_;
std::string join_column_name_;
std::string inverse_join_column_name_;
}; };
template<typename Type = table> template<typename Type = table>

View File

@ -97,6 +97,25 @@ const table_column * table::column_by_name(const table &tab, const std::string &
} }
return nullptr; return nullptr;
} }
std::string table::schema_name() const {
return schema_name_;
}
bool table::is_relation_table() const {
return false;
}
bool table::has_primary_key() const {
return false;
}
const std::string &table::join_column_name() const {
return join_column_name_;
}
const std::string &table::inverse_join_column_name() const {
return inverse_join_column_name_;
}
const table_column& table::create_column(class table &tab, const std::string &name) { const table_column& table::create_column(class table &tab, const std::string &name) {
tab.columns_.emplace_back(name); tab.columns_.emplace_back(name);