sql

package
v1.2.117 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolSliceArgs

func BoolSliceArgs(src ...bool) []any

func CompliantName

func CompliantName(in string) string

CompliantName returns a compliant id name that can be used for a bind or as var. replace special runes with '_' a.b -> a_b

func ExpandAsColumns

func ExpandAsColumns(cols ...string) []string

ExpandAsColumns expand columns with alias AS query := ExpandAsColumns("table.foo", "bar") // []string{"table.foo AS table_foo", "bar AS bar"}

func Int16SliceArgs

func Int16SliceArgs(src ...int16) []any

func Int32SliceArgs

func Int32SliceArgs(src ...int32) []any

func Int8SliceArgs

func Int8SliceArgs(src ...int8) []any

func IntSliceArgs

func IntSliceArgs(src ...int) []any

func JoinColumns

func JoinColumns(cols ...string) string

JoinColumns concatenates the elements of cols to column1, column2, ... query := JoinColumns("foo", "bar") // "foo,bar"

func JoinColumnsWithAs

func JoinColumnsWithAs(cols ...string) string

JoinColumnsWithAs concatenates the elements of cols to column1, column2, ... query := JoinColumnsWithAs("foo", "bar") // "foo AS foo,bar AS bar"

func JoinTableColumns

func JoinTableColumns(table string, cols ...string) string

JoinTableColumns concatenates the elements of cols to column1, column2, ... query := JoinTableColumns("table", "foo", "bar") // "table.foo, table.bar"

func JoinTableColumnsValues

func JoinTableColumnsValues(cmp string, table string, cols ...string) string

JoinTableColumnsValues concatenates the elements of values to table.value1=:value1, table.value2=:value2 ... query := JoinTableColumnsValues("table", "foo", "bar") // "table.foo=?, table.bar=?"

func JoinTableColumnsWithAs

func JoinTableColumnsWithAs(table string, cols ...string) string

JoinTableColumnsWithAs concatenates the elements of cols to column1, column2, ... query := JoinTableColumnsWithAs("table", "foo", "bar") // "table.foo AS table.foo, table.bar AS table.bar"

func JoinTableValues

func JoinTableValues(cols ...string) string

JoinTableValues concatenates the elements of values to :value1, :value2, ... query := JoinTableValues("foo", "bar") // "?,?" query := JoinTableValues() // ""

func Pagination

func Pagination(limit, offset int) string

Pagination returns the "LIMIT %d, OFFSET %d" query := Pagination(0, 0) // "LIMIT 0, OFFSET 0"

func Placeholders

func Placeholders(n int) string

Placeholders behaves like strings.Join([]string{"?",...,"?"}, ",")

func StringSliceArgs

func StringSliceArgs(src ...string) []any

func TableColumns

func TableColumns(table string, cols ...string) []string

TableColumns returns the []string{table.value1, table.value2 ...} query := Columns("table", "foo", "bar") // []string{"table.foo", "table.bar"}

func TableColumnsValues

func TableColumnsValues(cmp string, table string, cols ...string) []string

TableColumnsValues returns the []string{table.value1=:value1, table.value2=:value2 ...} query := ColumnsValues("table", "foo", "bar") // []string{"table.foo=?", "table.bar=?"}

func TableValues

func TableValues(cols ...string) []string

TableValues returns the []string{:value1, :value2 ...} query := TableValues("foo", "bar") // []string{"?", "?"}

func TimeSliceArgs

func TimeSliceArgs(src ...time.Time) []any

func Uint16SliceArgs

func Uint16SliceArgs(src ...uint16) []any

func Uint32SliceArgs

func Uint32SliceArgs(src ...uint32) []any

func Uint8SliceArgs

func Uint8SliceArgs(src ...uint8) []any

func UintSliceArgs

func UintSliceArgs(src ...uint) []any

Types

type NullDuration

type NullDuration struct {
	Data time.Duration

	Valid bool // Valid is true if Data is not NULL
}

NullDuration represents an interface that may be null. NullDuration implements the Scanner interface so it can be used as a scan destination, similar to sql.NullString.

func (*NullDuration) Scan

func (nj *NullDuration) Scan(src any) error

Scan implements the sql.Scanner interface.

func (NullDuration) Value

func (nj NullDuration) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type NullJson

type NullJson struct {
	Data any // must be set with a pointer to zero value of expect type

	Valid bool // Valid is true if Data is not NULL
}

NullJson represents an interface that may be null. NullJson implements the Scanner interface so it can be used as a scan destination, similar to sql.NullString. Deprecate, use go-nulljson instead. For more information, see: https://godoc.org/github.com/searKing/golang/tools/go-nulljson

func (*NullJson) Scan

func (nj *NullJson) Scan(src any) error

Scan implements the sql.Scanner interface.

func (NullJson) Value

func (nj NullJson) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

Jump to

Keyboard shortcuts

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