sqlpipe

package
v0.0.0-...-7c93a10 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Inspired by Pipe-Syntax-In-SQL https://static.simonwillison.net/static/2024/Pipe-Syntax-In-SQL.html +gengo:runtimedoc=false

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Columns

func Columns[M Model](cols ...modelscoped.Column[M]) iter.Seq[modelscoped.Column[M]]

Types

type Embed

type Embed[M Model] struct {
	Underlying Source[M]
}

func (*Embed[M]) GetFlags

func (u *Embed[M]) GetFlags(ctx context.Context) internal.Flags

func (*Embed[M]) IsNil

func (e *Embed[M]) IsNil() bool

func (*Embed[M]) Unwrap

func (u *Embed[M]) Unwrap() Source[M]

type Filter

type Filter[M Model] interface {
	sqlfrag.Fragment
}

type FilterOp

type FilterOp uint8
const (
	FilterOpAnd FilterOp = iota
	FilterOpOr
)

type FromOptionFunc

type FromOptionFunc[M Model] func(x *sourceFrom[M])

func JoinOn

func JoinOn[M Model, B Model, S Model, T comparable](
	on modelscoped.TypedColumn[B, T],
	src modelscoped.TypedColumn[S, T],
) FromOptionFunc[M]

type LimitOption

type LimitOption interface {
	SetOffset(offset int64)
}

type LimitOptionFunc

type LimitOptionFunc = func(o LimitOption)

func Offset

func Offset(offset int64) LimitOptionFunc

type Model

type Model = sqlbuilder.Model

type ModelNewer

type ModelNewer[M Model] sqlbuilder.ModelNewer[M]

type OperatorType

type OperatorType uint
const (
	OperatorFilter OperatorType = iota + 1
	OperatorSort
	OperatorLimit
	OperatorOnConflict
	OperatorProject
	OperatorCommit
	OperatorSetting
)

type Source

type Source[M Model] interface {
	Pipe(operators ...SourceOperator[M]) Source[M]

	sqlfrag.Fragment

	internal.StmtPatcher[M]
}

func Aggregate

func Aggregate[S Model, O Model](src Source[S], cols ...modelscoped.Column[O]) Source[O]

func AggregateGroupBy

func AggregateGroupBy[S Model, O Model](src Source[S], by iter.Seq[modelscoped.Column[S]], cols ...modelscoped.Column[O]) Source[O]

func As

func As[M Model](src Source[M], name string) Source[M]

func From

func From[M Model](opts ...FromOptionFunc[M]) Source[M]

func FromAll

func FromAll[M Model](opts ...FromOptionFunc[M]) Source[M]

func InsertFrom

func InsertFrom[S Model, O Model](src Source[S], cols ...modelscoped.Column[O]) Source[O]

func Pipe

func Pipe[M Model](src Source[M], operators ...SourceOperator[M]) Source[M]

func Value

func Value[M Model](value *M, cols ...modelscoped.Column[M]) Source[M]

func ValueOmitZero

func ValueOmitZero[M Model](value *M, exclude ...modelscoped.Column[M]) Source[M]

func Values

func Values[Slice ~[]*M, M Model](values Slice, cols ...modelscoped.Column[M]) Source[M]

type SourceOperator

type SourceOperator[M Model] interface {
	internal.Operator[Source[M], Source[M]]

	OperatorType() OperatorType
}

func AscSort

func AscSort[M Model](col modelscoped.Column[M]) SourceOperator[M]

func CastAscSort

func CastAscSort[M Model, U Model](col modelscoped.Column[U]) SourceOperator[M]

func CastDescSort

func CastDescSort[M Model, U Model](col modelscoped.Column[U]) SourceOperator[M]

func CastOrWhere

func CastOrWhere[M Model, U Model, T comparable](col modelscoped.TypedColumn[U, T], valuer sqlbuilder.ColumnValuer[T]) SourceOperator[M]

func CastSelect

func CastSelect[M Model, U Model](cols ...modelscoped.Column[U]) SourceOperator[M]

func CastWhere

func CastWhere[M Model, U Model, T comparable](col modelscoped.TypedColumn[U, T], valuer sqlbuilder.ColumnValuer[T]) SourceOperator[M]

func DefaultProject

func DefaultProject[M Model](projects ...sqlfrag.Fragment) SourceOperator[M]

func DescSort

func DescSort[M Model](col modelscoped.Column[M]) SourceOperator[M]

func DoDelete

func DoDelete[M Model]() SourceOperator[M]

func DoDeleteHard

func DoDeleteHard[M Model]() SourceOperator[M]

func DoUpdate

func DoUpdate[M Model, T any](col modelscoped.TypedColumn[M, T], valuer sqlbuilder.ColumnValuer[T]) SourceOperator[M]

func DoUpdateSet

func DoUpdateSet[M Model](m *M, cols ...modelscoped.Column[M]) SourceOperator[M]

func DoUpdateSetOmitZero

func DoUpdateSetOmitZero[M Model](m *M, exclude ...modelscoped.Column[M]) SourceOperator[M]

func Limit

func Limit[M Model](limit int64, optFns ...LimitOptionFunc) SourceOperator[M]

func NewWhere

func NewWhere[M Model, T comparable](op FilterOp, col modelscoped.TypedColumn[M, T], valuer sqlbuilder.ColumnValuer[T]) SourceOperator[M]

func OnConflictDoNothing

func OnConflictDoNothing[M sqlbuilder.Model](cols modelscoped.ColumnSeq[M]) SourceOperator[M]

func OnConflictDoUpdateSet

func OnConflictDoUpdateSet[M sqlbuilder.Model](cols modelscoped.ColumnSeq[M], toUpdates ...modelscoped.Column[M]) SourceOperator[M]

func OnConflictDoWith

func OnConflictDoWith[M sqlbuilder.Model](
	cols modelscoped.ColumnSeq[M],
	with func(onConflictAddition sqlbuilder.OnConflictAddition) sqlbuilder.OnConflictAddition,
) SourceOperator[M]

func OrWhere

func OrWhere[M Model, T comparable](col modelscoped.TypedColumn[M, T], valuer sqlbuilder.ColumnValuer[T]) SourceOperator[M]

func Project

func Project[M Model](projects ...sqlfrag.Fragment) SourceOperator[M]

func Returning

func Returning[M Model](cols ...modelscoped.Column[M]) SourceOperator[M]

func Select

func Select[M Model](cols ...modelscoped.Column[M]) SourceOperator[M]

func SourceOperatorFunc

func SourceOperatorFunc[M Model](typ OperatorType, next func(in Source[M]) Source[M]) SourceOperator[M]

func Where

func Where[M Model, T comparable](col modelscoped.TypedColumn[M, T], valuer sqlbuilder.ColumnValuer[T]) SourceOperator[M]

func WhereInSelectFrom

func WhereInSelectFrom[M Model, S Model, T comparable](col modelscoped.TypedColumn[M, T], colSelect modelscoped.TypedColumn[S, T], source Source[S]) SourceOperator[M]

func WhereNotInSelectFrom

func WhereNotInSelectFrom[M Model, S Model, T comparable](col modelscoped.TypedColumn[M, T], colSelect modelscoped.TypedColumn[S, T], source Source[S]) SourceOperator[M]

Directories

Path Synopsis
ex
Package internal GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE
Package internal GENERATED BY gengo:runtimedoc DON'T EDIT THIS FILE

Jump to

Keyboard shortcuts

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