Skip to main content

quote

Function quote 

Source
pub fn quote(identifier: &str, wrap: char) -> Result<String>
Expand description

Quotes a possibly qualified identifier with wrap: each dot-separated segment is wrapped (the wrap character doubled inside), a final * stays bare, and * alone is returned as is. Control characters are refused.

PHP: QuotesIdentifiers::quote() (with $wrapChar).

use utopia_query::quote;

assert_eq!(quote("schema.users", '`')?, "`schema`.`users`");
assert_eq!(quote("users.*", '"')?, "\"users\".*");
use Utopia\Query\Builder\MySQL;

echo (new MySQL())->from('schema.users')->build()->query, "\n"; // SELECT * FROM `schema`.`users`