OXY API 1.0
OXY API Library Documentation
Loading...
Searching...
No Matches
oxy::core::metadata::SqlConfig Struct Reference

Configuration structure for SQL database interactions. More...

#include <sql_generator.hpp>

Public Attributes

std::unordered_set< std::string > array_field_names {}
std::unordered_set< std::string > array_fields {}
 Names of fields that are JSON arrays (e.g., "tags"). Others are treated as scalars.
bool array_fields {false}
std::string column = "data"
std::unordered_set< std::string > datetime_field_names {}
SqlDialect dialect {SqlDialect::SQLite}
bool postgres_cast_to_jsonb = true
 PostgreSQL-specific: if your column is "json" not "jsonb", we will cast to jsonb anyway.
std::string table = ""

Detailed Description

Configuration structure for SQL database interactions.

Configuration for SQL generation behavior.

This structure holds configuration settings for SQL database interactions, including the SQL dialect, table name, column name, and specific settings for handling JSON fields. It allows for customization of SQL queries based on the database dialect and the structure of the data.

Members controlling structure and typing:

  • table: Optional table name used by select_star_where().
  • column: JSON column name; if empty, field paths are treated as direct SQL columns.
  • array_fields / array_field_names: declare array semantics at paths.
  • datetime_field_names: declare ISO 8601 datetime semantics at paths.
  • postgres_cast_to_jsonb: unify behavior by casting to jsonb before operators (PostgreSQL only).

Member Data Documentation

◆ array_field_names

std::unordered_set<std::string> oxy::core::metadata::SqlConfig::array_field_names {}

Specific dotted field names treated as arrays.

◆ array_fields

bool oxy::core::metadata::SqlConfig::array_fields {false}

Treat all fields as arrays if true.

◆ column

std::string oxy::core::metadata::SqlConfig::column = "data"

JSON column name; empty => plain columns.

◆ datetime_field_names

std::unordered_set<std::string> oxy::core::metadata::SqlConfig::datetime_field_names {}

Dotted names to be treated as ISO 8601 datetime text. Example: {"createdAt", "user.updated_at"}

Comparisons use dialect-specific conversions for Eq/Ne/Lt/Le/Gt/Ge:

  • SQLite: unixepoch(json_extract(...))
  • MySQL/MariaDB: COALESCE(STR_TO_DATE(...patterns...))
  • PostgreSQL: ::timestamptz

◆ dialect

SqlDialect oxy::core::metadata::SqlConfig::dialect {SqlDialect::SQLite}

SQL dialect selection.

◆ postgres_cast_to_jsonb

bool oxy::core::metadata::SqlConfig::postgres_cast_to_jsonb = true

PostgreSQL-specific: if your column is "json" not "jsonb", we will cast to jsonb anyway.

Cast column to jsonb prior to path navigation.

◆ table

std::string oxy::core::metadata::SqlConfig::table = ""

Default table name for SELECT helpers.