sql

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	input.File
	Queries []Query
}

type FileGroup

type FileGroup []File

type FileGroups

type FileGroups []FileGroup

func Parse

func Parse(ctx context.Context, logger zerolog.Logger, repo Repo, inGroups []input.FileGroup) (FileGroups, error)

type Param

type Param struct {
	Ordinal       int    // User Defined Order (generally used to order the params in the func call
	QueryPosition int    // Order in the query
	Name          string // Database field name
	Type          string // DB type
	TypeID        uint32 // DB type ID
	Nullable      bool   // True means the param is nullable
	Generated     bool   // Indicates type should be generated (locally defined)
	Query         *Query `json:"-"` // The owning query
}

func (Param) Path

func (p Param) Path() string

type Params

type Params []*Param

func (Params) ByName

func (pp Params) ByName(name string) *Param

func (Params) ByOrdinal

func (pp Params) ByOrdinal() Params

func (Params) ByQuery

func (pp Params) ByQuery() Params

func (Params) Names

func (pp Params) Names() stringlist.Strings

type Parser

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

type Query

type Query struct {
	Filename string
	Name     string
	Result   Result
	Params   Params
	SQL      string
	Raw      string
	Comment  string
	Type     string
}

func (Query) IsType

func (q Query) IsType(t ...string) bool

type Repo

type Repo interface {
	DescribeQuery(ctx context.Context, q *Query) error
}

type Result

type Result struct {
	Type          string // Type of the query result, provided in query descriptor or inferred from table typing
	IsSingleTable bool   // If a single table in the response, you can use table type mapping to resolve type
	Schema        string `json:"schema,omitempty"` // Schema of the single table response, empty otherwise
	Table         string `json:"table,omitempty"`  // Table of the single table response, empty otherwise
	Params        Params `json:"params,omitempty"` // Params in the response, empty otherwise
}

func (Result) GenerateType

func (r Result) GenerateType() bool

func (Result) TypeParam

func (r Result) TypeParam() *Param

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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