package sqlparser

import "github.com/pressly/goose/v3/internal/sqlparser"

Index

Functions

func ParseSQLMigration

func ParseSQLMigration(r io.Reader, direction Direction, debug bool) (stmts []string, useTx bool, err error)

Split given SQL script into individual statements and return SQL statements for given direction (up=true, down=false).

The base case is to simply split on semicolons, as these naturally terminate a statement.

However, more complex cases like pl/pgsql can have semicolons within a statement. For these cases, we provide the explicit annotations 'StatementBegin' and 'StatementEnd' to allow the script to tell us to ignore semicolons.

Types

type Direction

type Direction string
const (
	DirectionUp   Direction = "up"
	DirectionDown Direction = "down"
)

func FromBool

func FromBool(b bool) Direction

func (Direction) String

func (d Direction) String() string

func (Direction) ToBool

func (d Direction) ToBool() bool

type ParsedSQL

type ParsedSQL struct {
	UseTx    bool
	Up, Down []string
}

func ParseAllFromFS

func ParseAllFromFS(fsys fs.FS, filename string, debug bool) (*ParsedSQL, error)

Source Files

parse.go parser.go

Version
v3.23.0
Published
Nov 21, 2024
Platform
js/wasm
Imports
13 packages
Last checked
51 minutes ago

Tools for package owners.