cake/fragment
Fragments are low level building blocks of queries which allow direct manipulation of the query string.
If you want to insert parameters, you are required to use prepared fragments, which will be validated against the number of parameters given and the parameters are automatically escaped by the RDBMS to prevent SQL injections.
Types
Constants
pub const placeholder: String
This placeholder must be used when building fragments with parameters.
Functions
pub fn literal(string str: String) -> Fragment
Create a new fragment from a literal string.
⛔ ⛔ ⛔
WARNING: YOU ARE FORBIDDEN TO INSERT UNCONTROLLED USER INPUT THIS WAY!
⛔ ⛔ ⛔
pub fn prepared(
string str: String,
params prms: List(Param),
) -> Fragment
Create a new fragment from a string and a list of parameters.
⛔ ⛔ ⛔
If you missmatch the number of placeholders with the number of parameters, an error will be printed to stderr and the fragment will be created with the given parameters:
- If there are too many placeholders, the fragment will be created with the given parameters and the last parameter will be repeated for the remaining placeholders.
- If there are too many parameters, the fragment will be created with the given parameters and the excess parameters will be ignored.
⛔ ⛔ ⛔