sqlc

package
v0.0.0-...-23c364c Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2015 License: Apache-2.0 Imports: 18 Imported by: 1

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

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

func Qualified

func Qualified(parts ...string) string

Types

type Aliasable

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

type BlobField

type BlobField interface {
	TableField

	Eq(value []byte) Condition
	IsEq(value BlobField) JoinCondition

	Gt(value []byte) Condition
	IsGt(value BlobField) JoinCondition

	Ge(value []byte) Condition
	IsGe(value BlobField) JoinCondition

	Lt(value []byte) Condition
	IsLt(value BlobField) JoinCondition

	Le(value []byte) Condition
	IsLe(value BlobField) JoinCondition
}

func Blob

func Blob(s Selectable, name string) BlobField

type BoolField

type BoolField interface {
	TableField

	Eq(value bool) Condition
	IsEq(value BoolField) JoinCondition

	Gt(value bool) Condition
	IsGt(value BoolField) JoinCondition

	Ge(value bool) Condition
	IsGe(value BoolField) JoinCondition

	Lt(value bool) Condition
	IsLt(value BoolField) JoinCondition

	Le(value bool) Condition
	IsLe(value BoolField) JoinCondition
}

func Bool

func Bool(s Selectable, name string) BoolField

type Condition

type Condition struct {
	Binding   FieldBinding
	Predicate PredicateType
}

type DateField

type DateField interface {
	TableField

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

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

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

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

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

func Date

func Date(s Selectable, name string) DateField

type DatetimeField

type DatetimeField interface {
	TableField

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

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

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

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

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

func Datetime

func Datetime(s Selectable, name string) DatetimeField

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
	Type() reflect.Type
	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 Float32Field

type Float32Field interface {
	TableField

	Eq(value float32) Condition
	IsEq(value Float32Field) JoinCondition

	Gt(value float32) Condition
	IsGt(value Float32Field) JoinCondition

	Ge(value float32) Condition
	IsGe(value Float32Field) JoinCondition

	Lt(value float32) Condition
	IsLt(value Float32Field) JoinCondition

	Le(value float32) Condition
	IsLe(value Float32Field) JoinCondition
}

func Float32

func Float32(s Selectable, name string) Float32Field

type Float64Field

type Float64Field interface {
	TableField

	Eq(value float64) Condition
	IsEq(value Float64Field) JoinCondition

	Gt(value float64) Condition
	IsGt(value Float64Field) JoinCondition

	Ge(value float64) Condition
	IsGe(value Float64Field) JoinCondition

	Lt(value float64) Condition
	IsLt(value Float64Field) JoinCondition

	Le(value float64) Condition
	IsLe(value Float64Field) JoinCondition
}

func Float64

func Float64(s Selectable, name string) Float64Field

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

	Substr2(_0 interface{}) Field

	Substr3(_0, _1 interface{}) 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 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 NullBlobField

type NullBlobField interface {
	TableField

	Eq(value NullableBlob) Condition
	IsEq(value NullBlobField) JoinCondition

	Gt(value NullableBlob) Condition
	IsGt(value NullBlobField) JoinCondition

	Ge(value NullableBlob) Condition
	IsGe(value NullBlobField) JoinCondition

	Lt(value NullableBlob) Condition
	IsLt(value NullBlobField) JoinCondition

	Le(value NullableBlob) Condition
	IsLe(value NullBlobField) JoinCondition
}

func NullBlob

func NullBlob(s Selectable, name string) NullBlobField

type NullBoolField

type NullBoolField interface {
	TableField

	Eq(value sql.NullBool) Condition
	IsEq(value NullBoolField) JoinCondition

	Gt(value sql.NullBool) Condition
	IsGt(value NullBoolField) JoinCondition

	Ge(value sql.NullBool) Condition
	IsGe(value NullBoolField) JoinCondition

	Lt(value sql.NullBool) Condition
	IsLt(value NullBoolField) JoinCondition

	Le(value sql.NullBool) Condition
	IsLe(value NullBoolField) JoinCondition
}

func NullBool

func NullBool(s Selectable, name string) NullBoolField

type NullDateField

type NullDateField interface {
	TableField

	Eq(value NullableDate) Condition
	IsEq(value NullDateField) JoinCondition

	Gt(value NullableDate) Condition
	IsGt(value NullDateField) JoinCondition

	Ge(value NullableDate) Condition
	IsGe(value NullDateField) JoinCondition

	Lt(value NullableDate) Condition
	IsLt(value NullDateField) JoinCondition

	Le(value NullableDate) Condition
	IsLe(value NullDateField) JoinCondition
}

func NullDate

func NullDate(s Selectable, name string) NullDateField

type NullInt64Field

type NullInt64Field interface {
	TableField

	Eq(value sql.NullInt64) Condition
	IsEq(value NullInt64Field) JoinCondition

	Gt(value sql.NullInt64) Condition
	IsGt(value NullInt64Field) JoinCondition

	Ge(value sql.NullInt64) Condition
	IsGe(value NullInt64Field) JoinCondition

	Lt(value sql.NullInt64) Condition
	IsLt(value NullInt64Field) JoinCondition

	Le(value sql.NullInt64) Condition
	IsLe(value NullInt64Field) JoinCondition
}

func NullInt64

func NullInt64(s Selectable, name string) NullInt64Field

type NullIntField

type NullIntField interface {
	TableField

	Eq(value sql.NullInt64) Condition
	IsEq(value NullIntField) JoinCondition

	Gt(value sql.NullInt64) Condition
	IsGt(value NullIntField) JoinCondition

	Ge(value sql.NullInt64) Condition
	IsGe(value NullIntField) JoinCondition

	Lt(value sql.NullInt64) Condition
	IsLt(value NullIntField) JoinCondition

	Le(value sql.NullInt64) Condition
	IsLe(value NullIntField) JoinCondition
}

func NullInt

func NullInt(s Selectable, name string) NullIntField

type NullStringField

func NullString

func NullString(s Selectable, name string) NullStringField

type NullTimeField

type NullTimeField interface {
	TableField

	Eq(value NullableTime) Condition
	IsEq(value NullTimeField) JoinCondition

	Gt(value NullableTime) Condition
	IsGt(value NullTimeField) JoinCondition

	Ge(value NullableTime) Condition
	IsGe(value NullTimeField) JoinCondition

	Lt(value NullableTime) Condition
	IsLt(value NullTimeField) JoinCondition

	Le(value NullableTime) Condition
	IsLe(value NullTimeField) JoinCondition
}

func NullTime

func NullTime(s Selectable, name string) NullTimeField

type NullableBlob

type NullableBlob struct {
	Inet  []byte
	Valid bool // Valid is true if Inet is not NULL
}

func (*NullableBlob) Scan

func (self *NullableBlob) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullableBlob) Value

func (self NullableBlob) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullableDate

type NullableDate struct {
	Date  time.Time
	Valid bool // Valid is true if Date is not NULL
}

func (*NullableDate) Scan

func (self *NullableDate) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullableDate) Value

func (self NullableDate) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullableDatetime

type NullableDatetime struct {
	Datetime time.Time
	Valid    bool // Valid is true if Datetime is not NULL
}

func (*NullableDatetime) Scan

func (self *NullableDatetime) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullableDatetime) Value

func (self NullableDatetime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullableTime

type NullableTime struct {
	Time  time.Time
	Valid bool // Valid is true if Time is not NULL
}

func (*NullableTime) Scan

func (self *NullableTime) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullableTime) Value

func (self NullableTime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

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 {
	BoolField(name string) BoolField

	DateField(name string) DateField

	DatetimeField(name string) DatetimeField

	Float32Field(name string) Float32Field

	Float64Field(name string) Float64Field

	BlobField(name string) BlobField

	IntField(name string) IntField

	Int64Field(name string) Int64Field

	NullBoolField(name string) NullBoolField

	NullDateField(name string) NullDateField

	NullDatetimeField(name string) NullDatetimeField

	NullFloat32Field(name string) NullFloat32Field

	NullFloat64Field(name string) NullFloat64Field

	NullBlobField(name string) NullBlobField

	NullIntField(name string) NullIntField

	NullInt64Field(name string) NullInt64Field

	NullStringField(name string) NullStringField

	NullTimeField(name string) NullTimeField

	StringField(name string) StringField

	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
}

Jump to

Keyboard shortcuts

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