Documentation
¶
Overview ¶
Package sqlnorm canonicalizes SQL text so you can compare it for meaning rather than formatting. It parses the SQL into PostgreSQL's AST (through the parent sql package), optionally reorders column lists, and deparses back to a form with whitespace normalized and the trailing semicolon trimmed. If the input won't parse, we fall back to plain whitespace collapsing, so every input still gives you a deterministic result.
We call the package sqlnorm, not sql, so it doesn't clash with the parent github.com/gomatic/go-sql package it imports.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SQL ¶
type SQL string
SQL is normalized SQL text.
func (SQL) Normalize ¶
Normalize reformats the SQL to canonical form without touching column order, so it's safe where that order actually matters.
func (SQL) NormalizeRoutine ¶
NormalizeRoutine reformats the SQL and also sorts the column lists of simple SELECT and INSERT … SELECT statements. That's what you want for routine bodies, where column order means nothing and you're after a deterministic comparison.
func (SQL) NormalizeStrict ¶
NormalizeStrict reformats the SQL without reordering, just like SQL.Normalize; it's here to spell out the intent where column order matters.