Squirrelix.SQL (Squirrelix v0.4.0)

Copy Markdown View Source

SQL helpers used by query analysis and code generation.

Summary

Types

identifier_reason()

@type identifier_reason() ::
  :empty | {:invalid_grapheme, non_neg_integer(), String.t()}

Functions

identifier_error(identifier)

@spec identifier_error(String.t()) :: identifier_reason() | nil

infer_parameter_names(sql)

@spec infer_parameter_names(String.t()) :: %{required(pos_integer()) => String.t()}

similar_identifier(identifier)

@spec similar_identifier(String.t()) :: String.t() | nil

single_statement?(sql)

@spec single_statement?(String.t()) :: boolean()

Returns true when sql contains a single statement (ignoring comments/strings).

A trailing semicolon is allowed. Additional ; separators are rejected so callers can safely wrap the SQL in EXPLAIN over the simple query protocol.

valid_identifier?(identifier)

@spec valid_identifier?(String.t()) :: boolean()