parser

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Name         string
	Type         string
	RawType      string
	IsNotNull    bool
	IsPrimaryKey bool
	IsUnique     bool
	Default      string
	Check        string
	References   *Reference
	OnDelete     string
}

Column represents a parsed column definition

func (*Column) DDLType

func (c *Column) DDLType() string

DDLType returns the DDL column type function name

func (*Column) GoType

func (c *Column) GoType() string

GoType returns the Go type for a SQL type

func (*Column) TypePrecision

func (c *Column) TypePrecision() (int, int)

TypePrecision returns precision parameters for types like CHAR(3) or NUMERIC(12,2)

type Index

type Index struct {
	Name    string
	Table   string
	Columns []string
	Where   string
	Unique  bool
}

Index represents a parsed index definition

type Reference

type Reference struct {
	Table  string
	Column string
}

Reference represents a foreign key reference

type Schema

type Schema struct {
	Tables  []Table
	Indexes []Index
}

Schema represents the entire parsed schema

func ParseSQL

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

ParseSQL parses a SQL schema string and returns the parsed schema

type Table

type Table struct {
	Name              string
	Columns           []Column
	PrimaryKey        []string // composite primary key
	UniqueConstraints [][]string
	Indexes           []Index
}

Table represents a parsed table definition

Jump to

Keyboard shortcuts

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