added name methods to column class
This commit is contained in:
parent
56f307fd37
commit
44c50cf2af
|
|
@ -18,8 +18,7 @@ enum class sql_function_t {
|
||||||
MAX
|
MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
struct column
|
struct column {
|
||||||
{
|
|
||||||
column(const char *name, const std::string& as = ""); // NOLINT(*-explicit-constructor)
|
column(const char *name, const std::string& as = ""); // NOLINT(*-explicit-constructor)
|
||||||
explicit column(std::string name, 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)
|
column(sql_function_t func, std::string name); // NOLINT(*-explicit-constructor)
|
||||||
|
|
@ -30,6 +29,8 @@ struct column
|
||||||
|
|
||||||
column& as(std::string a);
|
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 is_function() const;
|
||||||
[[nodiscard]] bool has_alias() const;
|
[[nodiscard]] bool has_alias() const;
|
||||||
|
|
||||||
|
|
@ -40,7 +41,7 @@ struct column
|
||||||
sql_function_t function_{sql_function_t::NONE};
|
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
|
#endif //QUERY_COLUMN_HPP
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,17 @@ column &column::as(std::string a)
|
||||||
return *this;
|
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
|
bool column::is_function() const
|
||||||
{
|
{
|
||||||
return function_ != sql_function_t::NONE;
|
return function_ != sql_function_t::NONE;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue