better_duck_diesel::dsl::*. Call
them in .select, .filter, or UPDATE … SET; the SQL type each returns is noted so you know the Rust
type it loads as (see Type mapping).
Case, trim, and basic transforms
Text -> Text unless noted:
lower, upper, trim, ltrim, rtrim, reverse, repeat(x, n: Integer),
replace(s, from, to), length(s) (→BigInt), md5(x) (→Text),
contains(haystack, needle) (→Bool), starts_with(s, prefix) (→Bool),
ends_with(s, suffix) (→Bool).
Search, position, and extraction
strpos(haystack, needle) (→BigInt), instr(haystack, needle) (→BigInt),
substr(s, start: Integer, length: Integer) (→Text), split_part(s, sep, index: Integer) (→Text),
left(s, n: Integer) (→Text), right(s, n: Integer) (→Text), ascii(s) (→Integer),
chr(code: Integer) (→Text).
Padding and joining
lpad(s, len: Integer, fill) (→Text), rpad(s, len: Integer, fill) (→Text),
concat(a, b) (→Text), concat_ws(sep, a, b) (→Text).
Similarity and distance
Edit-distance and similarity metrics:Regex
Function forms (distinct from the~/!~ operators):
regexp_matches(s, pattern) (→Bool), regexp_full_match(s, pattern) (→Bool),
regexp_replace(s, pattern, replacement) (→Text), regexp_extract(s, pattern) (→Text).
printf-style formatting
printf(format, arg) (→Text), format_(format, arg) (#[sql_name = "format"], →Text).
The function is named
format_ in Rust because format is a reserved-ish identifier; it emits
format(...) SQL via #[sql_name = "format"].Hashing
md5(x) (→Text, also listed above), sha1(x) (→Text), sha256(x) (→Text).
Encoding — BLOB / base64 / hex
See also
Operators
ILIKE / GLOB / regex operator forms.
Numeric & utility
Math and conditional functions.
Aggregates
string_agg, array_agg, and more.Type mapping
What
Text/Binary/BigInt load as.