IronQuery
A SQL-first query builder for C++
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
iron_query::TableWithColumns Class Referencefinal

Table with associated columns. Usually not created by hands. More...

#include <table_with_columns.hpp>

Inheritance diagram for iron_query::TableWithColumns:
Inheritance graph
[legend]
Collaboration diagram for iron_query::TableWithColumns:
Collaboration graph
[legend]

Public Member Functions

Expr SelectArgAll () const
 Builds a comma-separated Expr listing all column names, for use as a SELECT list.
 
TableWithColumns As (std::string_view name) const
 Aliases this table as this AS name, preserving its column list so Dot can verify a referenced column actually belongs to this table. Hides VirtualTable::As, which would otherwise discard the column list.
 
Expr Dot (const std::string &column_name) const
 Qualifies column_name as alias.column_name.
 
Expr Dot (const Column &column) const
 Qualifies column as alias.column.name.
 
- Public Member Functions inherited from iron_query::Table
std::string ToString () const override
 Renders this table value as single-line SQL text. See also ToStringFormatted for a multi-line, indented rendering.
 
std::string ToStringBracketed () const override
 Returns the name as-is: a bare table name never needs brackets.
 
std::string ToStringAsFromItem () const override
 Returns the name as-is; this also covers the aliased subqueries and joins that VirtualTable::As turns into a Table.
 
- Public Member Functions inherited from iron_query::VirtualTable
virtual std::string ToStringFormatted () const
 Renders this table value as multi-line, indented SQL text for readability (e.g. logging/debugging a generated query). Defaults to ToString; overridden by SelectExpr to lay out each clause on its own line.
 
Table As (std::string_view name) const
 Aliases this table value as this AS name, usable as a FROM source. name must be a valid (optionally dotted) SQL identifier.
 
 operator Expr () const &&
 Converts this table value into a subquery expression, e.g. for use as a scalar subquery. Only available on rvalues.
 

Static Public Member Functions

static TableWithColumns FromRaw (std::string name, std::vector< Column > columns)
 Attaches a set of columns to a trusted, developer-written table name. Never pass untrusted/dynamic data as name.
 
static TableWithColumns FromRaw (std::string name, std::initializer_list< Column > columns)
 Attaches a set of columns to a trusted, developer-written table name. Never pass untrusted/dynamic data as name.
 
- Static Public Member Functions inherited from iron_query::Table
static Table FromRaw (std::string name)
 Wraps a trusted, developer-written table name/reference. Never pass untrusted/dynamic data here — use Expr::Ident to escape a dynamically-sourced name and pass it as an alias/expression instead.
 

Additional Inherited Members

- Protected Member Functions inherited from iron_query::Table
 Table (std::string name)
 Stores a pre-validated table name; only reachable via FromRaw or a subclass.
 

Detailed Description

Table with associated columns. Usually not created by hands.

Member Function Documentation

◆ As()

TableWithColumns iron_query::TableWithColumns::As ( std::string_view  name) const

Aliases this table as this AS name, preserving its column list so Dot can verify a referenced column actually belongs to this table. Hides VirtualTable::As, which would otherwise discard the column list.

Exceptions
InvalidIdentifierif name is not a valid identifier.

◆ Dot() [1/2]

Expr iron_query::TableWithColumns::Dot ( const Column column) const

Qualifies column as alias.column.name.

Exceptions
LogicErrorif called before As.
UnknownColumnif column is not one of this table's columns.

◆ Dot() [2/2]

Expr iron_query::TableWithColumns::Dot ( const std::string &  column_name) const

Qualifies column_name as alias.column_name.

Exceptions
LogicErrorif called before As.
UnknownColumnif column_name is not one of this table's columns.

The documentation for this class was generated from the following file: