parser

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractColumnDirectives added in v0.10.0

func ExtractColumnDirectives(rawCreateTableSQL string) map[string]string

ExtractColumnDirectives is a convenience wrapper for backward compatibility.

func ExtractStmtDirectives added in v0.10.0

func ExtractStmtDirectives(rawSQL string, stmts []*pg_query.RawStmt) map[int32]string

ExtractStmtDirectives scans raw SQL for `-- pist:rename-from <name>` comments that appear in each statement's raw text region (including leading comments). pg_query includes leading comments in StmtLocation/StmtLen, so we scan the raw text of each statement for the directive. Returns a map from StmtLocation to the old name string.

func QualifyRenameFrom added in v0.10.0

func QualifyRenameFrom(value, defaultSchema string) string

QualifyRenameFrom qualifies a rename-from value with the default schema if it does not already contain a schema. Quoted identifiers containing dots (e.g. `"a.b"`) are treated as a single identifier.

func ReadSQLFile

func ReadSQLFile(path string) (string, error)

Types

type InlineDirectives added in v0.10.0

type InlineDirectives struct {
	Columns     map[string]string // new column name → old column name
	Constraints map[string]string // new constraint name → old constraint name
}

InlineDirectives holds rename directives for columns and constraints within a CREATE TABLE.

func ExtractInlineDirectives added in v0.10.0

func ExtractInlineDirectives(rawCreateTableSQL string) *InlineDirectives

ExtractInlineDirectives scans the raw text of a CREATE TABLE statement for `-- pist:rename-from <old_name>` directives that appear on lines immediately before column or constraint definitions.

type ParseResult

type ParseResult struct {
	Tables *orderedmap.Map[string, *model.Table]
	Views  *orderedmap.Map[string, *model.View]
	Enums  *orderedmap.Map[string, *model.Enum]
}

func ParseSQL

func ParseSQL(sql string) (*ParseResult, error)

func ParseSQLFile

func ParseSQLFile(path string) (*ParseResult, error)

func ParseSQLFileWithSchema added in v0.4.0

func ParseSQLFileWithSchema(path string, defaultSchema string) (*ParseResult, error)

func ParseSQLFiles added in v0.3.0

func ParseSQLFiles(paths []string) (*ParseResult, error)

func ParseSQLFilesWithSchema added in v0.4.0

func ParseSQLFilesWithSchema(paths []string, defaultSchema string) (*ParseResult, error)

func ParseSQLWithSchema added in v0.4.0

func ParseSQLWithSchema(sql string, defaultSchema string) (*ParseResult, error)

Jump to

Keyboard shortcuts

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