Macro mz_sql_parser::ident
source · macro_rules! ident { ($val:expr) => { ... }; (@internal_check $max_len:literal, $val:expr) => { ... }; }
Expand description
A macro that creates an Ident
from a string literal, validating all of our invariants at
compile time.
§Examples
use mz_sql_parser::ident;
// Checks invariants at compile time, returning an `Ident`.
let id = ident!("my_postgres_source");
assert_eq!(id.as_str(), "my_postgres_source");
ⓘ
use mz_sql_parser::ident;
const TOO_LONG: &str = "I am a very long identifier that is more than 255 characters long which is the max length for idents.\
I am a very long identifier that is more than 255 characters long which is the max length for idents.\
Use that sentance twice since 255 characters is actually a lot.";
// This fails to build since the string is too long.
let _id = ident!(TOO_LONG);
ⓘ
use mz_sql_parser::ident;
const FORBIDDEN: &str = ".";
ident!(FORBIDDEN);
ⓘ
use mz_sql_parser::ident;
const FORBIDDEN: &str = "..";
ident!(FORBIDDEN);