added name methods to column class

This commit is contained in:
Sascha Kühl 2025-10-29 16:08:59 +01:00
parent 56f307fd37
commit 44c50cf2af
2 changed files with 15 additions and 3 deletions

View File

@ -18,8 +18,7 @@ enum class sql_function_t {
MAX
};
struct column
{
struct column {
column(const char *name, const std::string& as = ""); // NOLINT(*-explicit-constructor)
explicit column(std::string name, std::string as = ""); // NOLINT(*-explicit-constructor)
column(sql_function_t func, std::string name); // NOLINT(*-explicit-constructor)
@ -30,6 +29,8 @@ struct column
column& as(std::string a);
[[nodiscard]] const std::string& column_name() const;
[[nodiscard]] std::string full_name() const;
[[nodiscard]] bool is_function() const;
[[nodiscard]] bool has_alias() const;
@ -40,7 +41,7 @@ struct column
sql_function_t function_{sql_function_t::NONE};
};
column operator "" _col(const char *name, size_t len);
column operator ""_col(const char *name, size_t len);
}
#endif //QUERY_COLUMN_HPP

View File

@ -63,6 +63,17 @@ column &column::as(std::string a)
return *this;
}
const std::string& column::column_name() const {
return name;
}
std::string column::full_name() const {
if (table_ && !table_->name.empty()) {
return table_->name + "." + name;
}
return name;
}
bool column::is_function() const
{
return function_ != sql_function_t::NONE;