pub struct Grammar;Expand description
The lexical rules for function names and cast types, which the
Serializer writes verbatim, so a quoted identifier
cannot carry SQL into them.
PHP: Utopia\Query\AST\Grammar.
Implementations§
Source§impl Grammar
impl Grammar
Sourcepub fn is_identifier(value: &str) -> bool
pub fn is_identifier(value: &str) -> bool
Whether value is a bare identifier: ASCII letters, digits and _,
not starting with a digit.
PHP: Grammar::isIdentifier().
use utopia_query::ast::Grammar;
assert!(Grammar::is_identifier("LOWER"));
assert!(!Grammar::is_identifier("NOW() OR 1=1"));use Utopia\Query\AST\Grammar;
var_dump(Grammar::isIdentifier('LOWER')); // bool(true)
var_dump(Grammar::isIdentifier('NOW() OR 1=1')); // bool(false)Sourcepub fn is_type(value: &str) -> bool
pub fn is_type(value: &str) -> bool
Whether value is a type name: whitespace-separated identifiers,
optionally followed by parenthesised arguments of identifiers, commas
and whitespace (DECIMAL(10, 2), TIMESTAMP WITH TIME ZONE).
PHP: Grammar::isType().
use utopia_query::ast::Grammar;
assert!(Grammar::is_type("DECIMAL(10, 2)"));
assert!(!Grammar::is_type("TEXT) OR (1=1"));use Utopia\Query\AST\Grammar;
var_dump(Grammar::isType('DECIMAL(10, 2)')); // bool(true)
var_dump(Grammar::isType('TEXT) OR (1=1')); // bool(false)Trait Implementations§
Auto Trait Implementations§
impl Forget for Grammar
impl Freeze for Grammar
impl Move for Grammar
impl RefUnwindSafe for Grammar
impl Send for Grammar
impl Sync for Grammar
impl Unpin for Grammar
impl UnsafeUnpin for Grammar
impl UnwindSafe for Grammar
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more