Documentation
¶
Index ¶
- func ExtractColumnDirectives(rawCreateTableSQL string) map[string]string
- func ExtractStmtDirectives(rawSQL string, stmts []*pg_query.RawStmt) map[int32]string
- func QualifyRenameFrom(value, defaultSchema string) string
- func ReadSQLFile(path string) (string, error)
- type InlineDirectives
- type ParseResult
- func ParseSQL(sql string) (*ParseResult, error)
- func ParseSQLFile(path string) (*ParseResult, error)
- func ParseSQLFileWithSchema(path string, defaultSchema string) (*ParseResult, error)
- func ParseSQLFiles(paths []string) (*ParseResult, error)
- func ParseSQLFilesWithSchema(paths []string, defaultSchema string) (*ParseResult, error)
- func ParseSQLWithSchema(sql string, defaultSchema string) (*ParseResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractColumnDirectives ¶ added in v0.10.0
ExtractColumnDirectives is a convenience wrapper for backward compatibility.
func ExtractStmtDirectives ¶ added in v0.10.0
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
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 ¶
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)