relx 0.1.0
A Modern C++23 Type-Safe SQL Query Builder
Loading...
Searching...
No Matches
relx::connection::sql_utils Namespace Reference

Functions

std::string convert_placeholders_to_postgresql (const std::string &sql)
 Convert ? placeholders to PostgreSQL $1, $2, etc.
 
std::string isolation_level_to_postgresql_string (int isolation_level)
 Convert IsolationLevel enum to PostgreSQL isolation level string.
 
result::ResultSet process_postgresql_result (PGresult *pg_result, bool convert_bytea=false)
 Process PostgreSQL result into relx ResultSet format.
 

Function Documentation

◆ convert_placeholders_to_postgresql()

std::string relx::connection::sql_utils::convert_placeholders_to_postgresql ( const std::string &  sql)

Convert ? placeholders to PostgreSQL $1, $2, etc.

format

This function properly handles SQL syntax by respecting:

  • Single quotes (string literals): 'Don''t replace ? here'
  • Double quotes (quoted identifiers): "weird?column"
  • Escaped quotes: '' and "" Only replaces ? that appear outside of quoted contexts.
    Parameters
    sqlThe SQL string with ? placeholders
    Returns
    SQL string with $1, $2, etc. placeholders

◆ isolation_level_to_postgresql_string()

std::string relx::connection::sql_utils::isolation_level_to_postgresql_string ( int  isolation_level)

Convert IsolationLevel enum to PostgreSQL isolation level string.

Parameters
isolation_levelThe isolation level enum value (cast from IsolationLevel)
Returns
PostgreSQL-compatible isolation level string

◆ process_postgresql_result()

result::ResultSet relx::connection::sql_utils::process_postgresql_result ( PGresult pg_result,
bool  convert_bytea = false 
)

Process PostgreSQL result into relx ResultSet format.

Parameters
pg_resultPointer to PGresult from libpq
convert_byteaWhether to convert BYTEA columns from hex to binary
Returns
ResultSet containing the processed data