sqlddl

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package sqlddl is codefit's hand-written PostgreSQL DDL parser. It implements providers.SchemaParser (the second implementer after the Prisma parser), turning ordered SQL-DDL migrations into the neutral core/db.Schema.

Two pieces (ADR 0018): a statement splitter that is aware of dollar-quoting ($$…$$ / $tag$…$tag$), strings, quoted identifiers and comments — so a PL/pgSQL DO block's internal semicolons never cut a statement — and an incremental reducer that applies statements IN ORDER over a mutable schema (CREATE TABLE creates, ALTER ADD/DROP COLUMN mutates, CREATE INDEX indexes, ADD CONSTRAINT constrains), accumulating to the final state.

It parses a DECLARED SUBSET; everything outside (CHECK constraints, ON DELETE actions, partial-index WHERE, CREATE TYPE, ALTER COLUMN, all DML) is skip-and-declared, each locked by a test. View/Procedure/Trigger are populated with Name/Pos (and Table for triggers); their bodies, view columns, and the materialized flag are NOT captured — a declared limit for the future DB-020..041 rules. No SQL parsing library is used (CGO_ENABLED=0).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Parser

type Parser struct{}

Parser is the SQL-DDL schema parser: it reconstructs the neutral db.Schema by applying DDL statements IN ORDER (an incremental reducer over migrations). It implements providers.SchemaParser and nothing else — SQL is a schema source, not a programming language codefit audits for security/surface (ADR 0018).

func New

func New() *Parser

New returns a SQL-DDL schema parser.

func (*Parser) ParseSchema

func (*Parser) ParseSchema(sources []providers.SourceFile) (*db.Schema, error)

ParseSchema parses ordered SQL-DDL sources (e.g. Flyway migrations, already version-ordered by the caller) into the accumulated final schema. It is filesystem-free: the caller reads and orders the files (ADR 0014). Statements outside the declared subset are skipped, never an error.

Jump to

Keyboard shortcuts

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