sqlparse

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT, MIT Imports: 5 Imported by: 35

README

SQL migration parser

Based on the goose migration parser.

License

This library is distributed under the MIT license.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LineSeparator = ""

LineSeparator can be used to split migrations by an exact line match. This line will be removed from the output. If left blank, it is not considered. It is defaulted to blank so you will have to set it manually. Use case: in MSSQL, it is convenient to separate commands by GO statements like in SQL Query Analyzer.

Functions

This section is empty.

Types

type ParsedMigration

type ParsedMigration struct {
	UpStatements   []string
	DownStatements []string

	DisableTransactionUp   bool
	DisableTransactionDown bool
}

func ParseMigration

func ParseMigration(r io.ReadSeeker) (*ParsedMigration, error)

Split the given sql script into individual statements.

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.

Jump to

Keyboard shortcuts

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