sql
ModuleThe building blocks every statement uses: identifiers, table names, tenant conditions, column types, parameter types, statement execution with the statement timeout, and the mapping of driver errors onto the library's errors.
Contents
use utopia_database::adapter::postgres::sql::Binds;pub struct Binds(pub Vec<(String, Value)>)Bound values of a statement in the making, by placeholder, in the order
they were added ($binds).
use utopia_database::adapter::postgres::sql::bind_typed;pub fn bind_typed(stmt: &mut Statement, key: &str, value: Value) -> Result<()>$stmt->bindValue($key, $value, $this->getPDOType($value)).
use utopia_database::adapter::postgres::sql::filter;pub fn filter(value: &str) -> StringKeeps [A-Za-z0-9_-].
use utopia_database::adapter::postgres::sql::has_sequence;pub fn has_sequence(document: &Document) -> Result<bool>!empty($document->getSequence()).
use utopia_database::adapter::postgres::sql::id_value;pub fn id_value(document: &Document) -> Value$document->getId().
use utopia_database::adapter::postgres::sql::internal_key;pub fn internal_key(attribute: &str) -> &strUndocumented.
use utopia_database::adapter::postgres::sql::interpolate;pub fn interpolate(value: &Value) -> StringUndocumented.
use utopia_database::adapter::postgres::sql::json_encode;pub fn json_encode(value: &Value) -> ValueThe JSON text, or false when it fails.
use utopia_database::adapter::postgres::sql::json_text;pub fn json_text(value: &Value) -> StringAs text ("" when it fails, as interpolating
false gives).
use utopia_database::adapter::postgres::sql::pdo_type;pub fn pdo_type(value: &Value) -> Result<ParamType>Undocumented.
use utopia_database::adapter::postgres::sql::process_exception;pub fn process_exception(e: PdoError) -> Error(Postgres): driver errors with a known SQLSTATE
become the library's errors; others stay PDOExceptions.
use utopia_database::adapter::postgres::sql::processed;pub fn processed(e: PdoFailure) -> ErrorA failed statement through processException.
use utopia_database::adapter::postgres::sql::quote;pub fn quote(s: &str) -> String"string".
use utopia_database::adapter::postgres::sql::raw;pub fn raw(e: PdoFailure) -> ErrorA failed statement as it escapes unprocessed (PDOException).
use utopia_database::adapter::postgres::sql::row_to_document;pub fn row_to_document(mut row: Array, find: bool) -> Result<Document>A fetched row as a document: internal columns renamed to their $
attributes, each renamed key moving to the end, in the order
getDocument() (find = false) or find() renames them.
use utopia_database::adapter::postgres::sql::sequence;pub fn sequence(document: &Document) -> Result<Option<Value>>$document->getSequence(): null, or the value as a string (the
return type coerces it; an array is a TypeError).
use utopia_database::adapter::postgres::sql::short_key;pub fn short_key(key: &str) -> StringKeys longer than 63 bytes become their MD5, with
the part after the last _ kept as a suffix when it fits.
use utopia_database::adapter::postgres::sql::spatial_attributes;pub fn spatial_attributes(collection: &Document) -> Vec<String>Ids of the collection's spatial attribute documents.
use utopia_database::adapter::postgres::sql::sql_type;pub fn sql_type(kind: &str, size: i64, _signed: bool, array: bool, _required: bool) -> Result<String>Undocumented.
use utopia_database::adapter::postgres::sql::string_attribute;pub fn string_attribute(document: &Document, key: &str, getter: &str) -> Result<Value>A ?string getter of a document (getCreatedAt(), getUpdatedAt()):
the raw value coerced to a string.
use utopia_database::adapter::postgres::sql::tenant_value;pub fn tenant_value(document: &Document) -> Value$document->getTenant().
use utopia_database::adapter::postgres::sql::value_name;pub fn value_name(v: &Value) -> &strHow a TypeError names a value's type.
use utopia_database::adapter::postgres::sql::violated_columns;pub fn violated_columns(message: &str) -> Option<Vec<String>>The sorted columns of
Key (a, b)=(...), or None when the message has none.
pub const MAX_IDENTIFIER_NAME: usize = 63Postgres::MAX_IDENTIFIER_NAME.
pub const MAX_VARCHAR_LENGTH: i64 = 16381Undocumented.