sql

package
v1.0.0-...-1f0868f Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2019 License: Apache-2.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteSQL

func DeleteSQL(ir_del *ir.Delete, dialect Dialect) sqlgen.SQL

func ExprSQL

func ExprSQL(expr *ir.Expr, dialect Dialect) sqlgen.SQL

func GetLastSQL

func GetLastSQL(ir_model *ir.Model, dialect Dialect) sqlgen.SQL

func InsertSQL

func InsertSQL(ir_cre *ir.Create, dialect Dialect) sqlgen.SQL

func SQLFromGroupBy

func SQLFromGroupBy(group_by *GroupBy) sqlgen.SQL

func SQLFromInsert

func SQLFromInsert(insert *Insert) sqlgen.SQL

func SQLFromJoin

func SQLFromJoin(join Join) sqlgen.SQL

func SQLFromJoins

func SQLFromJoins(joins []Join) []sqlgen.SQL

func SQLFromOrderBy

func SQLFromOrderBy(order_by *OrderBy) sqlgen.SQL

func SQLFromSchema

func SQLFromSchema(schema *Schema) sqlgen.SQL

func SQLFromSelect

func SQLFromSelect(sel *Select) sqlgen.SQL

func SQLFromUpdate

func SQLFromUpdate(upd *Update) sqlgen.SQL

func SchemaSQL

func SchemaSQL(ir_root *ir.Root, dialect Dialect) sqlgen.SQL

func SelectSQL

func SelectSQL(ir_read *ir.Read, dialect Dialect) sqlgen.SQL

func UpdateSQL

func UpdateSQL(ir_upd *ir.Update, dialect Dialect) sqlgen.SQL

func WhereSQL

func WhereSQL(wheres []*ir.Where, dialect Dialect) (out []sqlgen.SQL)

Types

type Column

type Column struct {
	Name      string
	Type      string
	NotNull   bool
	Reference *Reference
}

type Dialect

type Dialect interface {
	Name() string
	Features() Features
	RowId() string
	ColumnType(field *ir.Field) string
	Rebind(sql string) string
	EscapeString(s string) string
	BoolLit(v bool) string
}

func Postgres

func Postgres() Dialect

func SQLite3

func SQLite3() Dialect

type Features

type Features struct {
	// Supports the RETURNING syntax on INSERT/UPDATE
	Returning bool

	// Supports positional argument placeholders
	PositionalArguments bool

	// Token used with LIMIT to mean "no limit"
	NoLimitToken string
}

type GroupBy

type GroupBy struct {
	Fields []string
}

func GroupByFromIRGroupBy

func GroupByFromIRGroupBy(ir_group_by *ir.GroupBy) (group_by *GroupBy)

type Index

type Index struct {
	Name    string
	Table   string
	Columns []string
	Unique  bool
}

type Insert

type Insert struct {
	Table     string
	Columns   []string
	Returning []string
}

func InsertFromIRCreate

func InsertFromIRCreate(ir_cre *ir.Create, dialect Dialect) *Insert

type Join

type Join struct {
	Type  string
	Table string
	Left  string
	Right string
}

func JoinFromIRJoin

func JoinFromIRJoin(ir_join *ir.Join) Join

func JoinsFromIRJoins

func JoinsFromIRJoins(ir_joins []*ir.Join) (joins []Join)

type OrderBy

type OrderBy struct {
	Fields     []string
	Descending bool
}

func OrderByFromIROrderBy

func OrderByFromIROrderBy(ir_order_by *ir.OrderBy) (order_by *OrderBy)

type Reference

type Reference struct {
	Table    string
	Column   string
	OnDelete string
	OnUpdate string
}

type Schema

type Schema struct {
	Tables  []Table
	Indexes []Index
}

func SchemaFromIRModels

func SchemaFromIRModels(ir_models []*ir.Model, dialect Dialect) *Schema

type Select

type Select struct {
	From    string
	Fields  []string
	Joins   []Join
	Where   []sqlgen.SQL
	OrderBy *OrderBy
	GroupBy *GroupBy
	Limit   string
	Offset  string
	Has     bool
}

func SelectFromIRRead

func SelectFromIRRead(ir_read *ir.Read, dialect Dialect) *Select

type Table

type Table struct {
	Name       string
	Columns    []Column
	PrimaryKey []string
	Unique     [][]string
}

type Update

type Update struct {
	Table     string
	Where     []sqlgen.SQL
	Returning []string
	In        sqlgen.SQL
}

func UpdateFromIRUpdate

func UpdateFromIRUpdate(ir_upd *ir.Update, dialect Dialect) *Update

Jump to

Keyboard shortcuts

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