mysql

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2020 License: MIT Imports: 17 Imported by: 0

README

Experimental MySQL Support

Missing Features

  • missing many MySQL types and function returns types

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	*sqlparser.ColumnDefinition
	Table string
}

type FromTable

type FromTable struct {
	TrueName     string // the true table name as described in the schema
	IsLeftJoined bool   // which could result in null columns
}

FromTable describes a table reference in the "FROM" clause of a query.

type FromTables

type FromTables map[string]FromTable

FromTables describes a map between table alias expressions and the proper table name

type PackageGenerator

type PackageGenerator struct {
	*Schema
	config.CombinedSettings
	// contains filtered or unexported fields
}

type Param

type Param struct {
	OriginalName string
	Name         string
	Typ          string
}

Param describes a runtime query parameter with its associated type. Example: "SELECT name FROM users id = ?"

type Query

type Query struct {
	SQL              string // the string representation of the parsed query
	Columns          []Column
	Params           []*Param // "?" params in the query string
	Name             string   // the Go function name
	Cmd              string   // TODO: Pick a better name. One of: one, many, exec, execrows
	DefaultTableName string   // for columns that are not qualified

	Filename string
}

Query holds the data for walking and validating mysql querys

type Result

type Result struct {
	PackageGenerator
	Queries []*Query
}

func GeneratePkg

func GeneratePkg(pkgName string, schemaPath, querysPath []string, settings config.CombinedSettings) (*Result, error)

GeneratePkg is the main entry to mysql generator package

func (*Result) Enums

func (r *Result) Enums(settings config.CombinedSettings) []golang.Enum

Enums generates parser-agnostic GoEnum types

func (*Result) GoQueries

func (r *Result) GoQueries(settings config.CombinedSettings) []golang.Query

GoQueries generates parser-agnostic query information for code generation

func (*Result) Structs

func (r *Result) Structs(settings config.CombinedSettings) []golang.Struct

Structs marshels each query into a go struct for generation

type Schema

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

Schema proves that information for mapping columns in queries to their respective table definitions and validating that they are correct so as to map to the correct Go type

func NewSchema

func NewSchema() *Schema

NewSchema gives a newly instantiated MySQL schema map

func (*Schema) Add

func (s *Schema) Add(ddl *sqlparser.DDL) error

Add add a MySQL table definition to the schema map

Jump to

Keyboard shortcuts

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