Helpers for safely quoting and sanitizing ClickHouse identifiers.
ClickHouse identifiers (table names, column names, database names) may be quoted with backticks. Unquoted identifiers are limited to a restricted set of characters. This module provides validation and quoting helpers so the data layer can build SQL safely without opening SQL-injection vectors.
Summary
Functions
Quotes an identifier with backticks, escaping any embedded backticks.
Sanitizes an identifier, raising ArgumentError if it is invalid.
Returns true if the given identifier is a valid unquoted ClickHouse identifier.
Validates a database name, raising ArgumentError if invalid.
Validates a table name, raising ArgumentError if invalid.
Functions
Quotes an identifier with backticks, escaping any embedded backticks.
Examples
iex> AshClickhouse.Identifier.quote_name("users")
"`users`"
iex> AshClickhouse.Identifier.quote_name("my`table")
"`my``table`"
Sanitizes an identifier, raising ArgumentError if it is invalid.
A valid ClickHouse identifier consists of letters, digits, and underscores, and must not start with a digit.
Returns true if the given identifier is a valid unquoted ClickHouse identifier.
@spec validate_database!(String.t() | nil) :: :ok
Validates a database name, raising ArgumentError if invalid.
@spec validate_table!(String.t()) :: :ok
Validates a table name, raising ArgumentError if invalid.