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

Any table value, including physical table, table result, materialized view, etc. More...

#include <virtual_table.hpp>

Inheritance diagram for iron_query::VirtualTable:
Inheritance graph
[legend]

Public Member Functions

virtual std::string ToString () const =0
 Renders this table value as single-line SQL text. See also ToStringFormatted for a multi-line, indented rendering.
 
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.
 
virtual std::string ToStringBracketed () const
 Renders this table value as SQL text, parenthesized so it can be safely embedded as a subquery. Overridden by Table to skip bracketing, since a bare table name never needs it.
 
virtual std::string ToStringAsFromItem () const
 Renders this table value as a FROM item. Distinct from ToStringBracketed because PostgreSQL's table_ref grammar accepts a bare join but parenthesizes one only when an alias follows.
 
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.
 

Detailed Description

Any table value, including physical table, table result, materialized view, etc.

Member Function Documentation

◆ As()

Table iron_query::VirtualTable::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.

Exceptions
InvalidIdentifierif name is not a valid identifier.

◆ operator Expr()

iron_query::VirtualTable::operator Expr ( ) const &&

Converts this table value into a subquery expression, e.g. for use as a scalar subquery. Only available on rvalues.

Note
Does not check that the underlying query yields exactly one column: a multi-column query converts just as freely as a single-column one.

◆ ToString()

virtual std::string iron_query::VirtualTable::ToString ( ) const
pure virtual

Renders this table value as single-line SQL text. See also ToStringFormatted for a multi-line, indented rendering.

Implemented in iron_query::DeleteFrom, iron_query::Join, iron_query::SelectExpr, iron_query::SetOp, iron_query::Table, and iron_query::WithQuery.

◆ ToStringAsFromItem()

virtual std::string iron_query::VirtualTable::ToStringAsFromItem ( ) const
virtual

Renders this table value as a FROM item. Distinct from ToStringBracketed because PostgreSQL's table_ref grammar accepts a bare join but parenthesizes one only when an alias follows.

Exceptions
LogicErrorfor table values that PostgreSQL requires an alias for, i.e. every subquery; call As first.

Reimplemented in iron_query::Join, and iron_query::Table.

◆ ToStringBracketed()

virtual std::string iron_query::VirtualTable::ToStringBracketed ( ) const
virtual

Renders this table value as SQL text, parenthesized so it can be safely embedded as a subquery. Overridden by Table to skip bracketing, since a bare table name never needs it.

Reimplemented in iron_query::Table.

◆ ToStringFormatted()

virtual std::string iron_query::VirtualTable::ToStringFormatted ( ) const
virtual

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.

Reimplemented in iron_query::SelectExpr, and iron_query::WithQuery.


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