postgres

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2015 License: MIT Imports: 5 Imported by: 13

README

PostGres

Development

To run tests for the postgres subpackage enable the UUID extension:

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

More info here: http://stackoverflow.com/a/12505220

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GenerateV4 string = `uuid_generate_v4()`
View Source
var Now string = `now() at time zone 'utc'`

Now represents the clause needed to return a now timestamp in postgres

Functions

func IsEmpty added in v0.4.0

func IsEmpty(c aspect.Clause) aspect.FuncClause

func StringAgg added in v0.5.2

func StringAgg(c aspect.ColumnElem, separator string) aspect.ColumnElem

Types

type AlterSeqStmt

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

func AlterSequence

func AlterSequence(sequence Sequence) (stmt AlterSeqStmt)

func (AlterSeqStmt) Compile

func (stmt AlterSeqStmt) Compile(d aspect.Dialect, ps *aspect.Parameters) (string, error)

func (AlterSeqStmt) RenameTo

func (stmt AlterSeqStmt) RenameTo(name string) AlterSeqStmt

func (AlterSeqStmt) RestartWith

func (stmt AlterSeqStmt) RestartWith(n int) AlterSeqStmt

func (AlterSeqStmt) String

func (stmt AlterSeqStmt) String() string

type ColumnElem added in v0.4.0

type ColumnElem struct {
	aspect.ColumnElem
}

ColumnElem expands aspect's ColumnElem by adding PostGres specific operators and functions

func C added in v0.4.0

func C(column aspect.ColumnElem) ColumnElem

C is a shorthand for Column

func Column added in v0.4.0

func Column(column aspect.ColumnElem) ColumnElem

Column wraps an aspect ColumnElem and adds postgres specific functionality C wraps an aspect ColumnElem and adds postgres specific functionality

func (ColumnElem) ContainedBy added in v0.4.0

func (c ColumnElem) ContainedBy(i interface{}) aspect.BinaryClause

func (ColumnElem) Contains added in v0.4.0

func (c ColumnElem) Contains(i interface{}) aspect.BinaryClause

func (ColumnElem) Difference added in v0.4.0

func (c ColumnElem) Difference(i interface{}) aspect.BinaryClause

func (ColumnElem) DoesNotExtendToTheLeftOf added in v0.4.0

func (c ColumnElem) DoesNotExtendToTheLeftOf(i interface{}) aspect.BinaryClause

func (ColumnElem) DoesNotExtendToTheRightOf added in v0.4.0

func (c ColumnElem) DoesNotExtendToTheRightOf(i interface{}) aspect.BinaryClause

func (ColumnElem) GetJSON added in v0.5.3

func (c ColumnElem) GetJSON(name string) ColumnElem

func (ColumnElem) GetJSONText added in v0.5.3

func (c ColumnElem) GetJSONText(name string) ColumnElem

func (ColumnElem) GreaterThan added in v0.4.0

func (c ColumnElem) GreaterThan(i interface{}) aspect.BinaryClause

func (ColumnElem) GreaterThanOrEqual added in v0.4.0

func (c ColumnElem) GreaterThanOrEqual(i interface{}) aspect.BinaryClause

func (ColumnElem) Intersection added in v0.4.0

func (c ColumnElem) Intersection(i interface{}) aspect.BinaryClause

func (ColumnElem) IsAdjacentTo added in v0.4.0

func (c ColumnElem) IsAdjacentTo(i interface{}) aspect.BinaryClause

func (ColumnElem) LessThan added in v0.4.0

func (c ColumnElem) LessThan(i interface{}) aspect.BinaryClause

func (ColumnElem) LessThanOrEqual added in v0.4.0

func (c ColumnElem) LessThanOrEqual(i interface{}) aspect.BinaryClause

func (ColumnElem) NotEqual added in v0.4.0

func (c ColumnElem) NotEqual(i interface{}) aspect.BinaryClause

func (ColumnElem) Overlap added in v0.4.0

func (c ColumnElem) Overlap(i interface{}) aspect.BinaryClause

func (ColumnElem) StrictlyLeftOf added in v0.4.0

func (c ColumnElem) StrictlyLeftOf(i interface{}) aspect.BinaryClause

func (ColumnElem) StrictlyRightOf added in v0.4.0

func (c ColumnElem) StrictlyRightOf(i interface{}) aspect.BinaryClause

func (ColumnElem) Union added in v0.4.0

func (c ColumnElem) Union(i interface{}) aspect.BinaryClause

type DateRange added in v0.4.0

type DateRange struct{}

func (DateRange) Create added in v0.4.0

func (s DateRange) Create(d aspect.Dialect) (string, error)

func (DateRange) IsPrimaryKey added in v0.4.0

func (s DateRange) IsPrimaryKey() bool

func (DateRange) IsRequired added in v0.4.0

func (s DateRange) IsRequired() bool

func (DateRange) IsUnique added in v0.4.0

func (s DateRange) IsUnique() bool

func (DateRange) Validate added in v0.4.0

func (s DateRange) Validate(i interface{}) (interface{}, error)

type ExcludeConstraint added in v0.4.0

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

func Exclude added in v0.4.0

func Exclude(clauses ...WithClause) ExcludeConstraint

Exclude creates a new ExcludeConstraint

func (ExcludeConstraint) Create added in v0.4.0

func (exclude ExcludeConstraint) Create(d aspect.Dialect) (string, error)

Create returns the proper syntax for CREATE TABLE commands.

func (ExcludeConstraint) Modify added in v0.4.0

func (exclude ExcludeConstraint) Modify(table *aspect.TableElem) error

Modify adds the ExcludeConstraint to the table's creates

func (ExcludeConstraint) Using added in v0.4.0

func (exclude ExcludeConstraint) Using(method IndexMethod) ExcludeConstraint

Using sets the ExcludeConstraints index method

type IndexMethod added in v0.4.0

type IndexMethod string
const (
	Gist  IndexMethod = "gist"
	Gin   IndexMethod = "gin"
	Btree IndexMethod = "btree"
	Hash  IndexMethod = "hash"
)

type Inet

type Inet struct {
	NotNull    bool
	Unique     bool
	PrimaryKey bool
}

func (Inet) Create

func (s Inet) Create(d aspect.Dialect) (string, error)

Create returns the syntax need to create this column in CREATE statements.

func (Inet) IsPrimaryKey

func (s Inet) IsPrimaryKey() bool

func (Inet) IsRequired

func (s Inet) IsRequired() bool

func (Inet) IsUnique

func (s Inet) IsUnique() bool

func (Inet) Validate

func (s Inet) Validate(i interface{}) (interface{}, error)

type JSON added in v0.3.0

type JSON struct {
	PrimaryKey bool
	NotNull    bool
	Default    string // TODO clause that compiles?
}

func (JSON) Create added in v0.3.0

func (s JSON) Create(d aspect.Dialect) (string, error)

func (JSON) IsPrimaryKey added in v0.3.0

func (s JSON) IsPrimaryKey() bool

func (JSON) IsRequired added in v0.3.0

func (s JSON) IsRequired() bool

func (JSON) IsUnique added in v0.3.0

func (s JSON) IsUnique() bool

func (JSON) Validate added in v0.3.0

func (s JSON) Validate(i interface{}) (interface{}, error)

type Operator added in v0.4.0

type Operator string
const (
	Equal                     Operator = "="
	NotEqual                  Operator = "<>"
	LessThan                  Operator = "<"
	GreaterThan               Operator = ">"
	LessThanOrEqual           Operator = "<="
	GreaterThanOrEqual        Operator = ">="
	Contains                  Operator = "@>"
	ContainedBy               Operator = "<@"
	Overlap                   Operator = "&&"
	StrictlyLeftOf            Operator = "<<"
	StrictlyRightOf           Operator = ">>"
	DoesNotExtendToTheRightOf Operator = "&<"
	DoesNotExtendToTheLeftOf  Operator = "&>"
	IsAdjacentTo              Operator = "-|-"
	Union                     Operator = "+"
	Intersection              Operator = "*"
	Difference                Operator = "-"
)

func (Operator) Compile added in v0.4.0

func (op Operator) Compile(d aspect.Dialect, p *aspect.Parameters) (string, error)

func (Operator) String added in v0.4.0

func (op Operator) String() string

func (Operator) With added in v0.4.0

func (op Operator) With(name string) WithClause

type PostGres

type PostGres struct{}

PostGres implements the Dialect interface for postgres databases.

func (*PostGres) Parameterize

func (d *PostGres) Parameterize(i int) string

Parameterize returns the postgres specific parameterization scheme.

type RetInsertStmt

type RetInsertStmt struct {
	aspect.InsertStmt
	// contains filtered or unexported fields
}

RetInsertStmt is the internal representation of an INSERT ... RETURNING statement.

func Insert

Insert creates an INSERT ... RETURNING statement for the given columns. There must be at least one column and all columns must belong to the same table.

func (RetInsertStmt) Compile

func (stmt RetInsertStmt) Compile(d aspect.Dialect, params *aspect.Parameters) (string, error)

Compile outputs the INSERT ... RETURNING statement using the given dialect and parameters. An error may be returned because of a pre-existing error or because an error occurred during compilation.

func (RetInsertStmt) CompileColumns

func (stmt RetInsertStmt) CompileColumns(d aspect.Dialect, params *aspect.Parameters, columns []aspect.ColumnElem) []string

TODO are errors required? TODO This should be a generalized function

func (RetInsertStmt) Returning

func (stmt RetInsertStmt) Returning(cs ...aspect.Selectable) RetInsertStmt

Returning adds a RETURNING clause to the statement.

func (RetInsertStmt) String

func (stmt RetInsertStmt) String() string

String outputs the parameter-less INSERT ... RETURNING statement in a neutral dialect.

func (RetInsertStmt) Values

func (stmt RetInsertStmt) Values(args interface{}) RetInsertStmt

Values proxies to the inner InsertStmt's Values method

type Sequence

type Sequence string

type Serial

type Serial struct {
	PrimaryKey bool
	NotNull    bool
}

func (Serial) Create

func (s Serial) Create(d aspect.Dialect) (string, error)

func (Serial) IsPrimaryKey

func (s Serial) IsPrimaryKey() bool

func (Serial) IsRequired

func (s Serial) IsRequired() bool

func (Serial) IsUnique

func (s Serial) IsUnique() bool

func (Serial) Validate

func (s Serial) Validate(i interface{}) (interface{}, error)

type UUID

type UUID struct {
	PrimaryKey bool
	NotNull    bool
	Default    string // TODO clause that compiles?
}

func (UUID) Create

func (s UUID) Create(d aspect.Dialect) (string, error)

func (UUID) IsPrimaryKey

func (s UUID) IsPrimaryKey() bool

func (UUID) IsRequired

func (s UUID) IsRequired() bool

func (UUID) IsUnique

func (s UUID) IsUnique() bool

func (UUID) Validate

func (s UUID) Validate(i interface{}) (interface{}, error)

type WithClause added in v0.4.0

type WithClause struct {
	Name     string
	Operator Operator
}

TODO Replace with a more robust binary clause?

func (WithClause) Compile added in v0.4.0

func (clause WithClause) Compile(d aspect.Dialect, params *aspect.Parameters) (string, error)

func (WithClause) String added in v0.4.0

func (clause WithClause) String() string

Jump to

Keyboard shortcuts

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