3#include "../schema/column.hpp"
4#include "../schema/table.hpp"
18template <ColumnType C>
27 std::string
to_sql()
const override {
return qualified_name(); }
29 std::vector<std::string>
bind_params()
const override {
return {}; }
31 std::string
column_name()
const override {
return std::string(C::name); }
33 std::string
table_name()
const override {
return std::string(table_name_); }
35 const C&
column()
const {
return col_; }
39 std::string_view table_name_;
41 std::string qualified_name()
const override {
42 if (table_name_.empty()) {
43 return std::string(C::name);
45 return std::string(table_name_) +
"." + std::string(C::name);
48 std::string_view get_parent_table_name()
const {
50 if constexpr (
requires {
typename C::table_type; }) {
51 using parent_table =
typename C::table_type;
52 return parent_table::table_name;
69 template <ColumnType C>
84template <ColumnType C>
85auto to_expr(
const C& col, std::string_view table_name =
"") {
Base class for column expressions.
Adapter to convert schema::column to a ColumnRef This allows direct use of schema columns in query ex...
std::string table_name() const override
typename C::value_type value_type
std::vector< std::string > bind_params() const override
std::string column_name() const override
std::string to_sql() const override
SchemaColumnAdapter(const C &col, std::string_view table_name="")
Adapter to convert schema::table to work with query builder This maintains table name and enables col...
auto get_column(const C &col) const
Get a column from this table as a SQL expression.
const T & schema_table() const
static constexpr auto table_name
SchemaTableAdapter(const T &table)
auto to_expr(const C &col, std::string_view table_name="")
Helper to wrap a schema column in a SQL expression.
auto to_table(const T &table)
Helper to wrap a schema table in a table adapter.