mysql

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2020 License: MIT Imports: 14 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 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 PositionedErr

type PositionedErr struct {
	Pos int
	Err error
}

func (PositionedErr) Error

func (e PositionedErr) Error() string

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
	SchemaLookup     *Schema  // for validation and conversion to Go types

	Filename string
}

Query holds the data for walking and validating mysql querys

type Result

type Result struct {
	Queries []*Query
	Schema  *Schema
	// contains filtered or unexported fields
}

Result holds the mysql validated queries schema

func GeneratePkg

func GeneratePkg(pkgName, schemaPath, querysPath string, settings dinosql.GenerateSettings) (*Result, error)

GeneratePkg is the main entry to mysql generator package

func (*Result) Enums

func (r *Result) Enums(settings dinosql.GenerateSettings) []dinosql.GoEnum

Enums generates parser-agnostic GoEnum types

func (*Result) GoQueries

func (r *Result) GoQueries(settings dinosql.GenerateSettings) []dinosql.GoQuery

GoQueries generates parser-agnostic query information for code generation

func (*Result) PkgName

func (r *Result) PkgName() string

PkgName exposes the result set's associated go package identifier as specified in the sqlc.json config.

func (*Result) Structs

func (r *Result) Structs(settings dinosql.GenerateSettings) []dinosql.GoStruct

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)

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