Skip to main content

quote_ident

Function quote_ident 

Source
pub fn quote_ident(name: &str) -> Result<String>
Expand description

Validates and returns name in a form safe to inline into a GQL admin statement that takes an identifier (CREATE USER, ALTER USER, CREATE MIGRATION, etc.).

Valid identifiers consist of ASCII letters, digits, underscore, and hyphen, and must not start with a hyphen. Digits are permitted at any position, including the first character, because some upstream catalogs use digit-prefixed names (e.g. migration names like 005_add_index).

§Errors

Returns Error::Validation for empty strings or inputs containing characters outside this set (including a leading hyphen).

§Example

use geode_client::quote_ident;

assert_eq!(quote_ident("user_01").unwrap(), "user_01");
assert_eq!(quote_ident("005_add_index").unwrap(), "005_add_index");
assert!(quote_ident("-bad").is_err());
assert!(quote_ident("").is_err());