Help us shape the future of Go! Take the 2026 Go Developer Survey

mysql

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 5 Imported by: 2

Documentation

Overview

Package mysql provides a MySQL dialect parser using vitess/sqlparser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseViewSQL

func ParseViewSQL(sql []byte) (parser.ViewSQL, error)

ParseViewSQL parses a CREATE VIEW statement using vitess/sqlparser and extracts the view name, SELECT column metadata, and FROM clause table aliases.

func QualifyFilterIdentifiers

func QualifyFilterIdentifiers(expr, alias string) (string, error)

QualifyFilterIdentifiers rewrites every bare column reference inside expr to be qualified with alias. Already-qualified refs (table.column) are left untouched. The expression is parsed as a MySQL WHERE clause and re-emitted via vitess/sqlparser, so backtick-quoted identifiers, dialect operators (e.g. `:=`), CAST/CASE/function-call expressions, and string-literal contents are all handled by the upstream parser.

It performs the codegen-time qualification of sub-categorized o2o `filter:` predicates.

Types

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser implements the parser.Parser interface for MySQL DDL. It uses vitess/sqlparser (pure Go) to parse MySQL SQL statements.

func New

func New() (*Parser, error)

New creates a new MySQL parser.

func (*Parser) Parse

func (p *Parser) Parse(filename string, sql []byte) error

Parse parses MySQL DDL from sql. It can be called multiple times with different files; results accumulate.

func (*Parser) Schema

func (p *Parser) Schema() *parser.Schema

Schema returns the accumulated schema model.

func (*Parser) Seed

func (p *Parser) Seed(base *parser.Schema)

Seed pre-populates the parser with an existing schema. This enables "both" mode where introspected tables are loaded before file-based DDL is applied.

Jump to

Keyboard shortcuts

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