postgres

package
v0.0.0-...-8afb70f Latest Latest
Warning

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

Go to latest
Published: May 19, 2015 License: MIT, MIT Imports: 5 Imported by: 0

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

This section is empty.

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 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 PostGres

type PostGres struct{}

Implement the Dialect interface

func (*PostGres) Parameterize

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

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)

Jump to

Keyboard shortcuts

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