serializer
Module[Serializer]: a Select back to SQL.
Contents
use utopia_query::ast::serializer::Serializer;Rust
pub struct SerializerWrites a syntax tree as SQL, quoting identifiers the way one dialect does: backticks (MySQL, MariaDB, ClickHouse, and the base serializer) or double quotes (PostgreSQL, SQLite), with the quote doubled inside.
Rust
use utopia_query::ast::{Parser, Serializer};
let select = Parser::new().parse_sql("select id, name from users where id = 1")?;
assert_eq!(Serializer::new().serialize(&select)?, "SELECT `id`, `name` FROM `users` WHERE `id` = 1");
assert_eq!(Serializer::postgresql().serialize(&select)?, r#"SELECT "id", "name" FROM "users" WHERE "id" = 1"#);Also implements
Default.