sqlc

package
v0.0.0-...-1b06aa4 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2014 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func FilterBindata

func FilterBindata(filter string, r func(string) ([]string, error)) []string

func Generate

func Generate(db *sql.DB, version string, opts *Options) error

func GroupConcat

func GroupConcat(field Field) *groupConcat

func LoadBindata

func LoadBindata(assets []string, r func(string) ([]byte, error)) []string

func Migrate

func Migrate(db *sql.DB, d Dialect, steps []string) error

Types

type Aliasable

type Aliasable interface {
	Alias() string
	MaybeAlias() string
}

type Condition

type Condition struct {
	Binding   FieldBinding
	Predicate PredicateType
}

type DeleteWhereStep

type DeleteWhereStep interface {
	Executable
	Where(...Condition) Executable
}

func Delete

func Delete(t TableLike) DeleteWhereStep

type Dialect

type Dialect int
const (
	Sqlite Dialect = iota
	MySQL
	Postgres
)

type Executable

type Executable interface {
	Renderable
	Exec(Dialect, *sql.DB) (sql.Result, error)
}

type Field

type Field interface {
	Aliasable
	Functional
	Name() string
	As(string) Field
	Function() FieldFunction
}

type FieldBinding

type FieldBinding struct {
	Field Field
	Value interface{}
}

type FieldFunction

type FieldFunction struct {
	Child *FieldFunction
	Name  string
	Expr  string
	Args  []interface{}
}

type FieldMeta

type FieldMeta struct {
	Name string
	Type string
}

type Functional

type Functional interface {
	Avg() Field

	Max() Field

	Min() Field

	Ceil() Field

	Div(_0 interface{}) Field

	Cast(_0 interface{}) Field

	Md5() Field

	Lower() Field

	Hex() Field
}

type InsertResultStep

type InsertResultStep interface {
	Renderable
	Fetch(Dialect, *sql.DB) (*sql.Row, error)
}

type InsertSetMoreStep

type InsertSetMoreStep interface {
	Executable
	InsertSetStep
	Returning(TableField) InsertResultStep
}

type InsertSetStep

type InsertSetStep interface {
	SetString(StringField, string) InsertSetMoreStep

	SetInt(IntField, int) InsertSetMoreStep

	SetInt64(Int64Field, int64) InsertSetMoreStep

	SetTime(TimeField, time.Time) InsertSetMoreStep
}

func InsertInto

func InsertInto(t TableLike) InsertSetStep

type Int64Field

type Int64Field interface {
	TableField

	Eq(value int64) Condition
	IsEq(value Int64Field) JoinCondition

	Gt(value int64) Condition
	IsGt(value Int64Field) JoinCondition

	Ge(value int64) Condition
	IsGe(value Int64Field) JoinCondition

	Lt(value int64) Condition
	IsLt(value Int64Field) JoinCondition

	Le(value int64) Condition
	IsLe(value Int64Field) JoinCondition
}

func Int64

func Int64(s Selectable, name string) Int64Field

type IntField

type IntField interface {
	TableField

	Eq(value int) Condition
	IsEq(value IntField) JoinCondition

	Gt(value int) Condition
	IsGt(value IntField) JoinCondition

	Ge(value int) Condition
	IsGe(value IntField) JoinCondition

	Lt(value int) Condition
	IsLt(value IntField) JoinCondition

	Le(value int) Condition
	IsLe(value IntField) JoinCondition
}

func Count

func Count() IntField

func Int

func Int(s Selectable, name string) IntField

type JoinCondition

type JoinCondition struct {
	Lhs, Rhs  TableField
	Predicate PredicateType
}

type JoinType

type JoinType int
const (
	Join JoinType = iota
	LeftOuterJoin
	NotJoined
)

type Options

type Options struct {
	File    string `short:"f" long:"file" description:"The path to the sqlite file"`
	Url     string `short:"u" long:"url" description:"The DB URL"`
	Output  string `short:"o" long:"output" description:"The path to save the generated objects to" required:"true"`
	Package string `short:"p" long:"package" description:"The package to put the generated objects into" required:"true"`
	Type    string `short:"t" long:"type" description:"The type of the DB (mysql,postgres,sqlite)" required:"true"`
	Schema  string `short:"s" long:"schema" description:"The target DB schema (required for MySQL and Postgres)"`
	Version func() `short:"V" long:"version" description:"Print sqlc version and exit"`
	Dialect Dialect
}

func (*Options) DbType

func (o *Options) DbType() (Dialect, error)

func (*Options) Validate

func (o *Options) Validate() error

type PredicateType

type PredicateType int
const (
	EqPredicate PredicateType = iota
	GtPredicate
	GePredicate
	LtPredicate
	LePredicate
	InPredicate
)

type Provenance

type Provenance struct {
	Version   string
	Timestamp time.Time
}

type Query

type Query interface {
	Renderable
	Selectable
	Query(Dialect, *sql.DB) (*sql.Rows, error)
	QueryRow(Dialect, *sql.DB) (*sql.Row, error)
}

type Queryable

type Queryable interface {
	Fields() []Field
}

type Reflectable

type Reflectable interface {
	StringField(name string) StringField

	IntField(name string) IntField

	Int64Field(name string) Int64Field

	TimeField(name string) TimeField
}

type Renderable

type Renderable interface {
	Render(Dialect, io.Writer) []interface{}
	String(Dialect) string
}

type SelectFromStep

type SelectFromStep interface {
	From(Selectable) SelectWhereStep
}

func Select

func Select(f ...Field) SelectFromStep

func SelectCount

func SelectCount() SelectFromStep

type SelectGroupByStep

type SelectGroupByStep interface {
	GroupBy(...Field) SelectHavingStep
}

type SelectHavingStep

type SelectHavingStep interface {
	SelectOrderByStep
	Query
}

type SelectJoinStep

type SelectJoinStep interface {
	Join(Selectable) SelectOnStep
	LeftOuterJoin(Selectable) SelectOnStep
}

type SelectLimitStep

type SelectLimitStep interface {
	Query
}

type SelectOnStep

type SelectOnStep interface {
	On(...JoinCondition) SelectWhereStep
	Query
}

type SelectOrderByStep

type SelectOrderByStep interface {
	OrderBy(...Field) SelectLimitStep
}

type SelectWhereStep

type SelectWhereStep interface {
	Query
	SelectGroupByStep
	SelectJoinStep
	Where(conditions ...Condition) Query
}

type Selectable

type Selectable interface {
	Aliasable
	Reflectable
	IsSelectable()
}

type StringField

type StringField interface {
	TableField

	Eq(value string) Condition
	IsEq(value StringField) JoinCondition

	Gt(value string) Condition
	IsGt(value StringField) JoinCondition

	Ge(value string) Condition
	IsGe(value StringField) JoinCondition

	Lt(value string) Condition
	IsLt(value StringField) JoinCondition

	Le(value string) Condition
	IsLe(value StringField) JoinCondition
}

func String

func String(s Selectable, name string) StringField

type TableField

type TableField interface {
	Field
	Parent() Selectable
}

type TableFieldBinding

type TableFieldBinding struct {
	Field TableField
	Value interface{}
}

type TableLike

type TableLike interface {
	Selectable
	Name() string
	As(string) Selectable
	Queryable
}

func Table

func Table(name string) TableLike

type TableMeta

type TableMeta struct {
	Name   string
	Fields []FieldMeta
}

type TimeField

type TimeField interface {
	TableField

	Eq(value time.Time) Condition
	IsEq(value TimeField) JoinCondition

	Gt(value time.Time) Condition
	IsGt(value TimeField) JoinCondition

	Ge(value time.Time) Condition
	IsGe(value TimeField) JoinCondition

	Lt(value time.Time) Condition
	IsLt(value TimeField) JoinCondition

	Le(value time.Time) Condition
	IsLe(value TimeField) JoinCondition
}

func Time

func Time(s Selectable, name string) TimeField

func Trunc

func Trunc(field TimeField, format string) TimeField

type UpdateSetMoreStep

type UpdateSetMoreStep interface {
	Executable
	UpdateSetStep
	Where(conditions ...Condition) Executable
}

type UpdateSetStep

type UpdateSetStep interface {
	SetString(StringField, string) UpdateSetMoreStep

	SetInt(IntField, int) UpdateSetMoreStep

	SetInt64(Int64Field, int64) UpdateSetMoreStep

	SetTime(TimeField, time.Time) UpdateSetMoreStep
}

func Update

func Update(t TableLike) UpdateSetStep

Jump to

Keyboard shortcuts

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