OXY API 1.0
OXY API Library Documentation
Loading...
Searching...
No Matches
oxy::core::metadata::SqlGenerator Class Reference

Emits SQL WHERE clauses or SELECT statements for a parsed query AST. More...

#include <sql_generator.hpp>

Public Member Functions

 SqlGenerator (SqlConfig cfg)
OXYCORE_API std::string select_star_where (const ExprNode &root) const
 Emit 'SELECT * FROM.
OXYCORE_API std::string select_star_where (const std::string &table, const ExprNode &root) const
 Emit 'SELECT * FROM.
OXYCORE_API std::string to_sql (const ExprNode &root) const
 Alias of where_clause() for semantic clarity.
OXYCORE_API std::string where_clause (const ExprNode &root) const
 Convert root expression to a SQL WHERE clause fragment.

Detailed Description

Emits SQL WHERE clauses or SELECT statements for a parsed query AST.

Usage pattern:

auto ast = p.parse("name: john and age >= 30");
SqlConfig cfg; cfg.column = "data"; cfg.dialect = SqlDialect::SQLite;
SqlGenerator gen(cfg);
std::string sqlWhere = gen.where_clause(*ast);
Parse textual queries into an expression AST.
Definition parser.hpp:88
OXYCORE_API ExprNode parse(std::string_view input)
Parse the input query string into an AST.
Configuration structure for SQL database interactions.
Definition sql_dialect.hpp:36
SqlDialect dialect
Definition sql_dialect.hpp:37
std::string column
Definition sql_dialect.hpp:39

Member Function Documentation

◆ select_star_where() [1/2]

OXYCORE_API std::string oxy::core::metadata::SqlGenerator::select_star_where ( const ExprNode & root) const

Emit 'SELECT * FROM.

<expr>' using config_.table or fallback.

◆ select_star_where() [2/2]

OXYCORE_API std::string oxy::core::metadata::SqlGenerator::select_star_where ( const std::string & table,
const ExprNode & root ) const

Emit 'SELECT * FROM.

<expr>' for a provided table name.