|
| bool | is_identifier (std::string_view s) |
| | True for a plain SQL identifier (name) or a qualified one (table.name): ASCII letters, digits and underscores, not starting with a digit. Identifiers cannot be bound as parameters, so anything else is rejected rather than spliced into SQL.
|
| |
| const std::string & | checked_identifier (const std::string &s) |
| |
| bool | is_reserved_word (std::string_view s) |
| |
| std::string | ident (const std::string &name) |
| | Validates an identifier (name or table.name) and marks the parts that are reserved words for quoting.
|
| |
| std::string | render_identifiers (std::string sql, bool mysql) |
| | Replaces quote marks with " (PostgreSQL, standard SQL) or a backtick (MySQL).
|
| |
| const std::string & | checked_operator (const std::string &op) |
| |
| template<typename T > |
| std::optional< std::string > | to_param (const T &val) |
| |
| std::optional< std::string > | json_to_param (const nlohmann::json &v) |
| |
| std::string | number_placeholders (const std::string &sql) |
| | Rewrites ? placeholders as PostgreSQL's $1, $2, ...
|
| |
| template<typename Escape > |
| std::string | inline_literals (const std::string &sql, const Params ¶ms, Escape &&escape) |
| | Replaces ? placeholders with escaped, quoted literals (for clients without parameter binding).
|
| |
| void | throw_if_failed (const database::ResultSet &rs) |
| |
| bool | is_unset_key (const nlohmann::json &v) |
| | A key that the database should generate: null, 0, or an empty string.
|
| |
| nlohmann::json | typed_value (const std::string &text, const nlohmann::json &proto) |
| | Converts a column's text to the JSON type of the model field proto.
|
| |
| template<typename ModelType > |
| std::vector< ModelType > | rows_to_models (const database::ResultSet &rs) |
| | Maps result rows to models, converting each column by the type of the model's field rather than by guessing from its text.
|
| |
template<typename ModelType >
Maps result rows to models, converting each column by the type of the model's field rather than by guessing from its text.
Every column arrives as text. Guessing turned a string column holding "42" or "007" into a number, which a std::string field then failed to read. Columns the model does not declare are ignored; fields with no column keep the value of a default-constructed model.
- Exceptions
-
| DatabaseError | if a row cannot be read into ModelType (e.g. NULL in a non-optional field). |