Documentation
¶
Index ¶
- Constants
- func Cidr() types.BaseType
- func Date() (t timestamp)
- func DateRange() (t rangeType)
- func Inet() types.BaseType
- func Int4Range() (t rangeType)
- func Int8Range() (t rangeType)
- func JSON() (t json)
- func Macaddr() types.BaseType
- func NumRange() (t rangeType)
- func Serial() (t serial)
- func Time() (t timestamp)
- func Timestamp() (t timestamp)
- func TimestampRange() (t rangeType)
- func TimestampWithTimezoneRange() (t rangeType)
- func UUID() (t uuid)
- type ColumnElem
- func (col ColumnElem) ContainedBy(param interface{}) sol.BinaryClause
- func (col ColumnElem) Contains(param interface{}) sol.BinaryClause
- func (col ColumnElem) Difference(param interface{}) sol.BinaryClause
- func (col ColumnElem) DoesNotExtendToTheLeftOf(param interface{}) sol.BinaryClause
- func (col ColumnElem) DoesNotExtendToTheRightOf(param interface{}) sol.BinaryClause
- func (col ColumnElem) Intersection(param interface{}) sol.BinaryClause
- func (col ColumnElem) IsAdjacentTo(param interface{}) sol.BinaryClause
- func (col ColumnElem) Overlap(param interface{}) sol.BinaryClause
- func (col ColumnElem) StrictlyLeftOf(param interface{}) sol.BinaryClause
- func (col ColumnElem) StrictlyRightOf(param interface{}) sol.BinaryClause
- func (col ColumnElem) Union(param interface{}) sol.BinaryClause
- type InsertStmt
- func (stmt InsertStmt) Compile(d dialect.Dialect, ps *sol.Parameters) (string, error)
- func (stmt InsertStmt) DoNothing() InsertStmt
- func (stmt InsertStmt) DoUpdate(values sol.Values) InsertStmt
- func (stmt InsertStmt) OnConflict(targets ...string) InsertStmt
- func (stmt InsertStmt) RemoveOnConflict() InsertStmt
- func (stmt InsertStmt) Returning(selections ...sol.Selectable) InsertStmt
- func (stmt InsertStmt) String() string
- func (stmt InsertStmt) Values(args interface{}) InsertStmt
- func (stmt InsertStmt) Where(conditions ...sol.Clause) InsertStmt
- type PostGres
- type TableElem
Constants ¶
const ( Contains = "@>" ContainedBy = "<@" Overlap = "&&" StrictlyLeftOf = "<<" StrictlyRightOf = ">>" DoesNotExtendToTheRightOf = "&<" DoesNotExtendToTheLeftOf = "&>" IsAdjacentTo = "-|-" Union = "+" Intersection = "*" Difference = "-" )
const ( NowUTC = "now() at time zone 'utc'" Now = "now()" )
const GenerateV4 = `uuid_generate_v4()`
TODO Don't hardcode utc?
Variables ¶
This section is empty.
Functions ¶
func TimestampRange ¶
func TimestampRange() (t rangeType)
func TimestampWithTimezoneRange ¶
func TimestampWithTimezoneRange() (t rangeType)
Types ¶
type ColumnElem ¶
type ColumnElem struct {
sol.ColumnElem
}
ColumnElem is the postgres dialect's implementation of a SQL column
func (ColumnElem) ContainedBy ¶
func (col ColumnElem) ContainedBy(param interface{}) sol.BinaryClause
func (ColumnElem) Contains ¶
func (col ColumnElem) Contains(param interface{}) sol.BinaryClause
func (ColumnElem) Difference ¶
func (col ColumnElem) Difference(param interface{}) sol.BinaryClause
func (ColumnElem) DoesNotExtendToTheLeftOf ¶
func (col ColumnElem) DoesNotExtendToTheLeftOf(param interface{}) sol.BinaryClause
func (ColumnElem) DoesNotExtendToTheRightOf ¶
func (col ColumnElem) DoesNotExtendToTheRightOf(param interface{}) sol.BinaryClause
func (ColumnElem) Intersection ¶
func (col ColumnElem) Intersection(param interface{}) sol.BinaryClause
func (ColumnElem) IsAdjacentTo ¶
func (col ColumnElem) IsAdjacentTo(param interface{}) sol.BinaryClause
func (ColumnElem) Overlap ¶
func (col ColumnElem) Overlap(param interface{}) sol.BinaryClause
func (ColumnElem) StrictlyLeftOf ¶
func (col ColumnElem) StrictlyLeftOf(param interface{}) sol.BinaryClause
func (ColumnElem) StrictlyRightOf ¶
func (col ColumnElem) StrictlyRightOf(param interface{}) sol.BinaryClause
func (ColumnElem) Union ¶
func (col ColumnElem) Union(param interface{}) sol.BinaryClause
type InsertStmt ¶
type InsertStmt struct { sol.InsertStmt // contains filtered or unexported fields }
InsertStmt is the internal representation of an INSERT ... RETURNING statement.
func Insert ¶
func Insert(selections ...sol.Selectable) InsertStmt
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 (InsertStmt) Compile ¶
func (stmt InsertStmt) Compile(d dialect.Dialect, ps *sol.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 (InsertStmt) DoNothing ¶
func (stmt InsertStmt) DoNothing() InsertStmt
DoNothing sets the ON CONFLICT behavior to DO NOTHING
func (InsertStmt) DoUpdate ¶
func (stmt InsertStmt) DoUpdate(values sol.Values) InsertStmt
DoUpdate sets the ON CONFLICT behavior to DO UPDATE if at least one value is given
func (InsertStmt) OnConflict ¶
func (stmt InsertStmt) OnConflict(targets ...string) InsertStmt
OnConflict adds UPSERT behavior to the INSERT. By Default, it will DO NOTHING.
func (InsertStmt) RemoveOnConflict ¶
func (stmt InsertStmt) RemoveOnConflict() InsertStmt
RemoveOnConflict will remove the ON CONFLICT behavior
func (InsertStmt) Returning ¶
func (stmt InsertStmt) Returning(selections ...sol.Selectable) InsertStmt
Returning adds a RETURNING clause to the statement. TODO How to remove a returning?
func (InsertStmt) String ¶
func (stmt InsertStmt) String() string
String outputs the parameter-less INSERT ... RETURNING statement in the PostGres dialect.
func (InsertStmt) Values ¶
func (stmt InsertStmt) Values(args interface{}) InsertStmt
Values proxies to the inner InsertStmt's Values method
func (InsertStmt) Where ¶
func (stmt InsertStmt) Where(conditions ...sol.Clause) InsertStmt
Where should only be used alongside OnConflict. Only one WHERE is allowed per statement. Additional calls to Where will overwrite the existing WHERE clause.
type PostGres ¶
type PostGres struct{}
PostGres implements the Dialect interface for postgres databases.
type TableElem ¶
TableElem is a postgres specific implementation of a table. Major differences include: * Column and C methods returns postgres specific columns * Insert return postgres specific INSERT statements with RETURNING syntax
func (TableElem) Column ¶
func (table TableElem) Column(name string) ColumnElem
Column will return a postgres specific ColumnElem rather than a generic ColumnElem. It is assumed that all columns belonging to postgres table are postgres columns
func (*TableElem) Insert ¶
func (table *TableElem) Insert() InsertStmt
Insert creates a postgres.InsertStmt from the table