pub enum Literal {
Show 15 variants
String(String),
Number(String),
HexString(String),
HexNumber(String),
BitString(String),
ByteString(String),
NationalString(String),
Date(String),
Time(String),
Timestamp(String),
Datetime(String),
TripleQuotedString(String, char),
EscapeString(String),
DollarString(String),
RawString(String),
}Expand description
Represent a SQL literal value.
Numeric values are stored as their original text representation (not parsed
to i64/f64) so that precision, trailing zeros, and hex notation are
preserved across round-trips.
Dialect-specific literal forms (triple-quoted strings, dollar-quoted strings, raw strings, etc.) each have a dedicated variant so that the generator can emit them with the correct syntax.
Variants§
String(String)
Single-quoted string literal: 'hello'
Number(String)
Numeric literal, stored as the original text: 42, 3.14, 1e10
HexString(String)
Hex string literal: X'FF'
HexNumber(String)
Hex number: 0xA, 0xFF (BigQuery, SQLite style) - represents an integer in hex notation
BitString(String)
ByteString(String)
Byte string: b“…“ (BigQuery style)
NationalString(String)
National string: N’abc’
Date(String)
DATE literal: DATE ‘2024-01-15’
Time(String)
TIME literal: TIME ‘10:30:00’
Timestamp(String)
TIMESTAMP literal: TIMESTAMP ‘2024-01-15 10:30:00’
Datetime(String)
DATETIME literal: DATETIME ‘2024-01-15 10:30:00’ (BigQuery)
TripleQuotedString(String, char)
Triple-quoted string: “”“…”“” or ‘’‘…’‘’ Contains (content, quote_char) where quote_char is ‘“’ or ‘'’
EscapeString(String)
Escape string: E’…’ (PostgreSQL)
DollarString(String)
Dollar-quoted string: $$…$$ (PostgreSQL)
RawString(String)
Raw string: r“…“ or r’…’ (BigQuery, Spark, Databricks) In raw strings, backslashes are literal and not escape characters. When converting to a regular string, backslashes must be doubled.