fixed table_column naming consistency and added result_name method
This commit is contained in:
@@ -25,7 +25,7 @@ public:
|
||||
table_column(const class table* tab, const std::string& name, utils::basic_type type, const utils::field_attributes& attributes);
|
||||
table_column(const class table*,
|
||||
const std::string& name,
|
||||
const std::string& alias,
|
||||
std::string alias,
|
||||
utils::basic_type type,
|
||||
const utils::field_attributes& attributes,
|
||||
sql::sql_function_t func = sql::sql_function_t::None);
|
||||
@@ -38,10 +38,46 @@ public:
|
||||
|
||||
[[nodiscard]] table_column as(const std::string& alias) const;
|
||||
|
||||
/**
|
||||
* Returns the canonical column name.
|
||||
*
|
||||
* @return The canonical column name
|
||||
*/
|
||||
[[nodiscard]] const std::string& name() const;
|
||||
|
||||
/**
|
||||
* Returns the column name without prepending
|
||||
* a table name or alias.
|
||||
*
|
||||
* @return Returns the column name
|
||||
*/
|
||||
[[nodiscard]] const std::string& column_name() const;
|
||||
|
||||
/**
|
||||
* Returns the canonical column name which means
|
||||
* if the column is owned by a table, the table name
|
||||
* id prepended.
|
||||
*
|
||||
* @return Returns the canonical column name
|
||||
*/
|
||||
[[nodiscard]] const std::string& canonical_name() const;
|
||||
|
||||
/**
|
||||
* Returns the alias name for the column. If no alias
|
||||
* is set, an empty string is returned.
|
||||
*
|
||||
* @return Returns the alias name for the column
|
||||
*/
|
||||
[[nodiscard]] const std::string& alias() const;
|
||||
|
||||
/**
|
||||
* Returns the result label name for this column in a SELECT list.
|
||||
* Semantics: alias if set, otherwise the raw column name (never table-qualified).
|
||||
*
|
||||
* @return If set the alias otherwise the raw column name
|
||||
*/
|
||||
[[nodiscard]] const std::string& result_name() const;
|
||||
|
||||
[[nodiscard]] utils::basic_type type() const;
|
||||
[[nodiscard]] utils::field_attributes attributes() const;
|
||||
|
||||
@@ -57,14 +93,14 @@ public:
|
||||
operator const std::string&() const; // NOLINT(*-explicit-constructor)
|
||||
|
||||
private:
|
||||
static std::string build_column_name(const class table *tab, const std::string& name);
|
||||
static std::string build_canonical_name(const class table *tab, const std::string& name);
|
||||
|
||||
private:
|
||||
friend class table;
|
||||
|
||||
const class table* table_{nullptr};
|
||||
std::string name_;
|
||||
std::string column_name_;
|
||||
std::string canonical_name_;
|
||||
std::string alias_;
|
||||
utils::basic_type type_{utils::basic_type::Unknown};
|
||||
utils::field_attributes attributes_{};
|
||||
|
||||
Reference in New Issue
Block a user