sqlnorm

package
v0.1.26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 3 Imported by: 0

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

func (p SQL) Normalize() SQL

Normalize reformats the SQL to canonical form without touching column order, so it's safe where that order actually matters.

func (SQL) NormalizeRoutine

func (p SQL) NormalizeRoutine() SQL

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

func (p SQL) NormalizeStrict() SQL

NormalizeStrict reformats the SQL without reordering, just like SQL.Normalize; it's here to spell out the intent where column order matters.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL