dinosql

package
v0.0.0-devel Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2019 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(r *Result, settings GenerateSettings) (string, error)

func IsStarRef

func IsStarRef(cf nodes.ColumnRef) bool

func ParseCatalog

func ParseCatalog(dir string, settings GenerateSettings) (core.Catalog, error)

func RemoveGooseRollback

func RemoveGooseRollback(contents string) string

Remove all lines after a `-- +goose Down` comment

func Walk

func Walk(f Visitor, node nodes.Node)

Types

type Error

type Error struct {
	Message string
	Code    string
	Hint    string
}

func (Error) Error

func (e Error) Error() string

type GenerateSettings

type GenerateSettings struct {
	SchemaDir           string         `json:"schema"`
	QueryDir            string         `json:"queries"`
	Out                 string         `json:"out"`
	Package             string         `json:"package"`
	EmitPreparedQueries bool           `json:"emit_prepared_queries"`
	EmitTags            bool           `json:"emit_tags"`
	Overrides           []TypeOverride `json:"overrides"`
}

type GoConstant

type GoConstant struct {
	Name  string
	Type  string
	Value string
}

type GoEnum

type GoEnum struct {
	Name      string
	Constants []GoConstant
}

type GoField

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

func (GoField) Tag

func (gf GoField) Tag() string

type GoQuery

type GoQuery struct {
	Cmd          string
	MethodName   string
	FieldName    string
	ConstantName string
	SQL          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
	// contains filtered or unexported fields
}

TODO: Terrible name

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 {
	Name   string
	Fields []GoField
}

type Parameter

type Parameter struct {
	Number   int
	DataType string
	Name     string // TODO: Relation?
	NotNull  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

	// XXX: Hack
	NeedsEdit bool
}

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 NewQueryCatalog

func NewQueryCatalog(c core.Catalog, with *nodes.WithClause) QueryCatalog

func (QueryCatalog) GetTable

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

type Result

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

func ParseQueries

func ParseQueries(c core.Catalog, settings GenerateSettings) (*Result, error)

func (Result) Enums

func (r Result) Enums() []GoEnum

func (Result) GoQueries

func (r Result) GoQueries() []GoQuery

func (Result) PkgImports

func (r Result) PkgImports(settings GenerateSettings) []string

func (Result) StdImports

func (r Result) StdImports() []string

func (Result) Structs

func (r Result) Structs() []GoStruct

func (Result) UsesType

func (r Result) UsesType(typ string) bool

type TypeOverride

type TypeOverride struct {
	Package      string `json:"package"`
	PostgresType string `json:"postgres_type"`
	GoType       string `json:"go_type"`
	Null         bool   `json:"null"`
}

type Visitor

type Visitor interface {
	Visit(nodes.Node) Visitor
}

type VisitorFunc

type VisitorFunc func(nodes.Node)

func (VisitorFunc) Visit

func (vf VisitorFunc) Visit(node nodes.Node) Visitor

Jump to

Keyboard shortcuts

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