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

Transitional representation for JOIN query. More...

#include <join.hpp>

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

Public Member Functions

 Join (const VirtualTable &a, const VirtualTable &b, const JoinKind &kind)
 Builds a kind JOIN b.
 
Join On (Condition exp) &&
 Sets the ON clause.
 
Join Using (std::initializer_list< Expr > columns) &&
 Sets the USING (cols) clause: joins by equating same-named columns from each side.
 
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 ToStringAsFromItem () const override
 Returns the join unbracketed: PostgreSQL only allows parentheses around a FROM-item join when an alias follows.
 
- 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.
 
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.
 
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

Transitional representation for JOIN query.

See also
https://www.postgresql.org/docs/current/sql-select.html

Member Function Documentation

◆ On()

Join iron_query::Join::On ( Condition  exp) &&

Sets the ON clause.

Note
Does not check that exp references only columns of the two joined tables.
Exceptions
LogicErrorif this is a NATURAL join, if the ON clause was already set, or if a USING clause was already set.

◆ ToString()

std::string iron_query::Join::ToString ( ) const
overridevirtual

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

Implements iron_query::VirtualTable.

◆ ToStringAsFromItem()

std::string iron_query::Join::ToStringAsFromItem ( ) const
overridevirtual

Returns the join unbracketed: PostgreSQL only allows parentheses around a FROM-item join when an alias follows.

Reimplemented from iron_query::VirtualTable.

◆ Using()

Join iron_query::Join::Using ( std::initializer_list< Expr columns) &&

Sets the USING (cols) clause: joins by equating same-named columns from each side.

Exceptions
LogicErrorif this is a NATURAL join, if a USING clause was already set, or if an ON clause was already set.
InvalidArgumentif columns is empty.

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