MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / strip_collate

Function strip_collate

nodedb-sql/src/planner/index_ddl/create.rs:73–86  ·  view source on GitHub ↗

Strip a `COLLATE ` wrapper from `expr` and return the inner expression together with whether the collation is a recognised case-insensitive collation.

(expr: &ast::Expr)

Source from the content-addressed store, hash-verified

71/// expression together with whether the collation is a recognised
72/// case-insensitive collation.
73fn strip_collate(expr: &ast::Expr) -> (&ast::Expr, bool) {
74 if let ast::Expr::Collate { expr, collation } = expr {
75 let ci = collation
76 .0
77 .iter()
78 .filter_map(|part| match part {
79 ast::ObjectNamePart::Identifier(ident) => Some(ident.value.as_str()),
80 _ => None,
81 })
82 .any(is_case_insensitive_collation);
83 return (expr.as_ref(), ci);
84 }
85 (expr, false)
86}
87
88fn is_case_insensitive_collation(name: &str) -> bool {
89 name.eq_ignore_ascii_case("NOCASE")

Callers 1

plan_create_indexFunction · 0.85

Calls 3

iterMethod · 0.45
as_strMethod · 0.45
as_refMethod · 0.45

Tested by

no test coverage detected