dinosql

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoubleSlashComment added in v1.0.0

func DoubleSlashComment(s string) string

func Generate

func Generate(r Generateable, settings config.CombinedSettings) (map[string]string, error)

func HasStarRef

func HasStarRef(cf nodes.ColumnRef) bool

func Imports

func Imports(r Generateable, settings config.CombinedSettings) func(string) [][]string

func LowerTitle

func LowerTitle(s string) string

func ParseCatalog

func ParseCatalog(schema string) (core.Catalog, error)

func ParseMetadata added in v1.0.0

func ParseMetadata(t string, commentStyle CommentSyntax) (string, string, error)

func ReadSQLFiles

func ReadSQLFiles(path string) ([]string, error)

func RemoveRollbackStatements

func RemoveRollbackStatements(contents string) string

Remove all lines after a rollback comment.

goose: -- +goose Down sql-migrate: -- +migrate Down tern: ---- create above / drop below ----

func StructName

func StructName(name string, settings config.CombinedSettings) string

func UsesArrays

func UsesArrays(r Generateable, settings config.CombinedSettings) bool

func UsesType

func UsesType(r Generateable, typ string, settings config.CombinedSettings) bool

Types

type CommentSyntax added in v1.0.0

type CommentSyntax int
const (
	CommentSyntaxDash CommentSyntax = iota
	CommentSyntaxStar               // Note: this is the only style supported by the MySQL sqlparser
	CommentSyntaxHash
)

type FileErr

type FileErr struct {
	Filename string
	Line     int
	Column   int
	Err      error
}

type Generateable

type Generateable interface {
	Structs(settings config.CombinedSettings) []GoStruct
	GoQueries(settings config.CombinedSettings) []GoQuery
	Enums(settings config.CombinedSettings) []GoEnum
}

type GoConstant

type GoConstant struct {
	Name  string
	Type  string
	Value string
}

type GoEnum

type GoEnum struct {
	Name      string
	Comment   string
	Constants []GoConstant
}

type GoField

type GoField struct {
	Name    string
	Type    string
	Tags    map[string]string
	Comment string
}

func (GoField) Tag

func (gf GoField) Tag() string

type GoQuery

type GoQuery struct {
	Cmd          string
	Comments     []string
	MethodName   string
	FieldName    string
	ConstantName string
	SQL          string
	SourceName   string
	Ret          GoQueryValue
	Arg          GoQueryValue
}

A struct used to generate methods and fields on the Queries struct

type GoQueryValue

type GoQueryValue struct {
	Emit   bool
	Name   string
	Struct *GoStruct
	Typ    string
}

func (GoQueryValue) EmitStruct

func (v GoQueryValue) EmitStruct() bool

func (GoQueryValue) IsStruct

func (v GoQueryValue) IsStruct() bool

func (GoQueryValue) Pair

func (v GoQueryValue) Pair() string

func (GoQueryValue) Params

func (v GoQueryValue) Params() string

func (GoQueryValue) Scan

func (v GoQueryValue) Scan() string

func (GoQueryValue) Type

func (v GoQueryValue) Type() string

type GoStruct

type GoStruct struct {
	Table   core.FQN
	Name    string
	Fields  []GoField
	Comment string
}

type Parameter

type Parameter struct {
	Number int
	Column core.Column
}

type ParserErr

type ParserErr struct {
	Errs []FileErr
}

func NewParserErr

func NewParserErr() *ParserErr

func (*ParserErr) Add

func (e *ParserErr) Add(filename, source string, loc int, err error)

func (*ParserErr) Error

func (e *ParserErr) Error() string

type ParserOpts added in v1.0.0

type ParserOpts struct {
	UsePositionalParameters bool
}

type Query

type Query struct {
	SQL      string
	Columns  []core.Column
	Params   []Parameter
	Name     string
	Cmd      string // TODO: Pick a better name. One of: one, many, exec, execrows
	Comments []string

	// XXX: Hack
	Filename string
}

Name and Cmd may be empty Maybe I don't need the SQL string if I have the raw Stmt?

type QueryCatalog

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

func (QueryCatalog) GetTable

func (qc QueryCatalog) GetTable(fqn core.FQN) (core.Table, *core.Error)

type Result

type Result struct {
	Queries []*Query
	Catalog core.Catalog
}

func ParseQueries

func ParseQueries(c core.Catalog, queries string, opts ParserOpts) (*Result, error)

func (Result) Enums

func (r Result) Enums(settings config.CombinedSettings) []GoEnum

func (Result) GoQueries

func (r Result) GoQueries(settings config.CombinedSettings) []GoQuery

func (Result) Structs

func (r Result) Structs(settings config.CombinedSettings) []GoStruct

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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