queryx

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UNKNOWN = iota
	QUESTION
	DOLLAR
	NAMED
	AT
)

https://github.com/jmoiron/sqlx/blob/master/bind.go

Variables

This section is empty.

Functions

func Deref

func Deref(t reflect.Type) reflect.Type

Deref is Indirect for reflect.Types

func In

func In(query string, args ...interface{}) (string, []interface{}, error)

In expands slice values in args, returning the modified query string and a new arg list that can be executed by a database. The `query` should use the `?` bindVar. The return value uses the `?` bindVar.

func ScanOne

func ScanOne(rows *sql.Rows, v interface{}) error

TODO: share code between ScanOne and ScanSlice TODO: improve error messages TODO: should we support sql.Row or sql.Rows ?

func ScanSlice

func ScanSlice(rows *sql.Rows, v interface{}) error

Types

type Adapter

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

func NewAdapter

func NewAdapter(db DB) *Adapter

func (*Adapter) Exec

func (a *Adapter) Exec(query string, args ...interface{}) (int64, error)

func (*Adapter) Query

func (a *Adapter) Query(query string, args ...interface{}) *Rows

func (*Adapter) QueryOne

func (a *Adapter) QueryOne(query string, args ...interface{}) *Row

type BigInt

type BigInt struct {
	Val  int64
	Null bool
	Set  bool
}

func NewBigInt

func NewBigInt(v int64) BigInt

func NewNullableBigInt

func NewNullableBigInt(v *int64) BigInt

func (BigInt) MarshalJSON

func (b BigInt) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*BigInt) Scan

func (b *BigInt) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*BigInt) UnmarshalJSON

func (b *BigInt) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (BigInt) Value

func (b BigInt) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type BigIntColumn

type BigIntColumn struct {
	Name  string
	Table *Table
}

func (*BigIntColumn) Asc

func (c *BigIntColumn) Asc() string

func (*BigIntColumn) Between

func (c *BigIntColumn) Between(start int64, end int64) *Clause

func (*BigIntColumn) Desc

func (c *BigIntColumn) Desc() string

func (*BigIntColumn) EQ

func (c *BigIntColumn) EQ(v int64) *Clause

func (*BigIntColumn) GE

func (c *BigIntColumn) GE(v int64) *Clause

func (*BigIntColumn) GT

func (c *BigIntColumn) GT(v int64) *Clause

func (*BigIntColumn) In

func (c *BigIntColumn) In(v []int64) *Clause

func (*BigIntColumn) InRange

func (c *BigIntColumn) InRange(start int64, end int64) *Clause

func (*BigIntColumn) LE

func (c *BigIntColumn) LE(v int64) *Clause

func (*BigIntColumn) LT

func (c *BigIntColumn) LT(v int64) *Clause

func (*BigIntColumn) NE

func (c *BigIntColumn) NE(v int64) *Clause

type Boolean

type Boolean struct {
	Val  bool
	Null bool
	Set  bool
}

func NewBoolean

func NewBoolean(v bool) Boolean

func NewNullableBoolean

func NewNullableBoolean(v *bool) Boolean

func (Boolean) MarshalJSON added in v0.1.5

func (b Boolean) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*Boolean) Scan

func (b *Boolean) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*Boolean) UnmarshalJSON added in v0.1.5

func (b *Boolean) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (Boolean) Value

func (b Boolean) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type BooleanColumn

type BooleanColumn struct {
	Name  string
	Table *Table
}

func (*BooleanColumn) Asc added in v0.1.5

func (b *BooleanColumn) Asc() string

func (*BooleanColumn) Desc added in v0.1.5

func (b *BooleanColumn) Desc() string

func (*BooleanColumn) EQ

func (c *BooleanColumn) EQ(v bool) *Clause

func (*BooleanColumn) NE

func (c *BooleanColumn) NE(v bool) *Clause

type Clause

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

func (*Clause) And

func (c *Clause) And(clauses ...*Clause) *Clause

func (*Clause) Err

func (c *Clause) Err() error

func (*Clause) Or

func (c *Clause) Or(clauses ...*Clause) *Clause

type DB

type DB interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
}

type DeleteStatemnet

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

func NewDelete

func NewDelete() *DeleteStatemnet

func (*DeleteStatemnet) From

func (s *DeleteStatemnet) From(from string) *DeleteStatemnet

func (*DeleteStatemnet) ToSQL

func (s *DeleteStatemnet) ToSQL() (string, []interface{})

func (*DeleteStatemnet) Where

func (s *DeleteStatemnet) Where(expr *Clause) *DeleteStatemnet

type Float

type Float struct {
	Val  float64
	Null bool
	Set  bool
}

func NewFloat

func NewFloat(v float64) Float

func NewNullableFloat

func NewNullableFloat(v *float64) Float

func (Float) MarshalJSON added in v0.1.5

func (f Float) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*Float) Scan

func (f *Float) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*Float) UnmarshalJSON added in v0.1.5

func (f *Float) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (Float) Value

func (f Float) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type FloatColumn

type FloatColumn struct {
	Name  string
	Table *Table
}

func (*FloatColumn) Asc added in v0.1.5

func (c *FloatColumn) Asc() string

func (*FloatColumn) Desc added in v0.1.5

func (c *FloatColumn) Desc() string

func (*FloatColumn) EQ

func (c *FloatColumn) EQ(v float64) *Clause

func (*FloatColumn) GE

func (c *FloatColumn) GE(v float64) *Clause

func (*FloatColumn) GT

func (c *FloatColumn) GT(v float64) *Clause

func (*FloatColumn) In

func (c *FloatColumn) In(v []float64) *Clause

func (*FloatColumn) LE

func (c *FloatColumn) LE(v float64) *Clause

func (*FloatColumn) LT

func (c *FloatColumn) LT(v float64) *Clause

type InsertStatement

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

func NewInsert

func NewInsert() *InsertStatement

func (*InsertStatement) Columns

func (s *InsertStatement) Columns(columns ...string) *InsertStatement

func (*InsertStatement) Into

func (s *InsertStatement) Into(into string) *InsertStatement

func (*InsertStatement) OnConflict

func (s *InsertStatement) OnConflict(onConflict string) *InsertStatement

func (*InsertStatement) Returning

func (s *InsertStatement) Returning(returning ...string) *InsertStatement

func (*InsertStatement) ToSQL

func (s *InsertStatement) ToSQL() (string, []interface{})

func (*InsertStatement) Values

func (s *InsertStatement) Values(values ...interface{}) *InsertStatement

type Integer

type Integer struct {
	Val  int32
	Null bool
	Set  bool
}

func NewInteger

func NewInteger(v int32) Integer

func NewNullableInteger

func NewNullableInteger(v *int32) Integer

func (Integer) MarshalJSON

func (i Integer) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*Integer) Scan

func (i *Integer) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*Integer) UnmarshalJSON

func (i *Integer) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (Integer) Value

func (i Integer) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type IntegerColumn

type IntegerColumn struct {
	Name  string
	Table *Table
}

func (*IntegerColumn) Asc

func (c *IntegerColumn) Asc() string

func (*IntegerColumn) Between

func (c *IntegerColumn) Between(start int32, end int32) *Clause

func (*IntegerColumn) Desc

func (c *IntegerColumn) Desc() string

func (*IntegerColumn) EQ

func (c *IntegerColumn) EQ(v int32) *Clause

func (*IntegerColumn) GE

func (c *IntegerColumn) GE(v int32) *Clause

func (*IntegerColumn) GT

func (c *IntegerColumn) GT(v int32) *Clause

func (*IntegerColumn) In

func (c *IntegerColumn) In(v []int32) *Clause

func (*IntegerColumn) InRange

func (c *IntegerColumn) InRange(start int32, end int32) *Clause

func (*IntegerColumn) LE

func (c *IntegerColumn) LE(v int32) *Clause

func (*IntegerColumn) LT

func (c *IntegerColumn) LT(v int32) *Clause

func (*IntegerColumn) NE

func (c *IntegerColumn) NE(v int32) *Clause

type JSON

type JSON struct {
	Val  map[string]interface{}
	Null bool
	Set  bool
}

func NewJSON

func NewJSON(v map[string]interface{}) JSON

func NewNullableJSON

func NewNullableJSON(v interface{}) JSON

func (JSON) MarshalJSON added in v0.1.5

func (j JSON) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*JSON) Scan

func (j *JSON) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*JSON) UnmarshalJSON added in v0.1.5

func (j *JSON) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (JSON) Value

func (j JSON) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type JSONColumn

type JSONColumn struct {
	Name  string
	Table *Table
}

func (*JSONColumn) EQ

func (c *JSONColumn) EQ(k string, v interface{}) *Clause

func (*JSONColumn) IsNull

func (c *JSONColumn) IsNull() *Clause

func (*JSONColumn) NotNull

func (c *JSONColumn) NotNull() *Clause

type Logger

type Logger interface {
	Print(v ...interface{})
	Printf(format string, v ...interface{})
	Println(v ...interface{})
	Panic(v ...interface{})
	Panicf(format string, v ...interface{})
	Panicln(v ...interface{})
	Fatal(v ...interface{})
	Fatalf(format string, v ...interface{})
	Fatalln(v ...interface{})
}

type Row

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

func (*Row) Scan

func (r *Row) Scan(v interface{}) error

type Rows

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

func (*Rows) Scan

func (r *Rows) Scan(v interface{}) error

type SelectStatement

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

func NewSelect

func NewSelect() *SelectStatement

func (*SelectStatement) Delete

func (s *SelectStatement) Delete() *DeleteStatemnet

convert select statement to delete statement

func (*SelectStatement) Distinct

func (s *SelectStatement) Distinct(distinct ...string) *SelectStatement

func (*SelectStatement) From

func (s *SelectStatement) From(from string) *SelectStatement

func (*SelectStatement) GroupBy

func (s *SelectStatement) GroupBy(group string) *SelectStatement

func (*SelectStatement) Having

func (s *SelectStatement) Having(having string) *SelectStatement

func (*SelectStatement) Join

func (s *SelectStatement) Join(join ...string) *SelectStatement

func (*SelectStatement) Limit

func (s *SelectStatement) Limit(limit int) *SelectStatement

func (*SelectStatement) Offset

func (s *SelectStatement) Offset(offset int) *SelectStatement

func (*SelectStatement) Order

func (s *SelectStatement) Order(order ...string) *SelectStatement

func (*SelectStatement) Select

func (s *SelectStatement) Select(selection ...string) *SelectStatement

func (*SelectStatement) ToSQL

func (s *SelectStatement) ToSQL() (string, []interface{})

func (*SelectStatement) Update

func (s *SelectStatement) Update() *UpdateStatement

convert select statement to update statement

func (*SelectStatement) Where

func (s *SelectStatement) Where(expr *Clause) *SelectStatement

type String

type String struct {
	Val  string
	Null bool
	Set  bool
}

func NewNullableString

func NewNullableString(v *string) String

func NewString

func NewString(v string) String

func (String) MarshalJSON

func (s String) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*String) Scan

func (s *String) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*String) UnmarshalJSON

func (s *String) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (String) Value

func (s String) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type StringColumn

type StringColumn struct {
	Name  string
	Table *Table
}

func (*StringColumn) Asc

func (c *StringColumn) Asc() string

func (*StringColumn) Desc

func (c *StringColumn) Desc() string

func (*StringColumn) EQ

func (c *StringColumn) EQ(v string) *Clause

func (*StringColumn) EndsWith

func (c *StringColumn) EndsWith(v string) *Clause

func (*StringColumn) IEQ

func (c *StringColumn) IEQ(v string) *Clause

func (*StringColumn) IEndsWith

func (c *StringColumn) IEndsWith(v string) *Clause

func (*StringColumn) ILike

func (c *StringColumn) ILike(v string) *Clause

func (*StringColumn) IStartsWith

func (c *StringColumn) IStartsWith(v string) *Clause

func (*StringColumn) In

func (c *StringColumn) In(v []string) *Clause

func (*StringColumn) Like

func (c *StringColumn) Like(v string) *Clause

func (*StringColumn) NE

func (c *StringColumn) NE(v string) *Clause

func (*StringColumn) StartsWith

func (c *StringColumn) StartsWith(v string) *Clause

type Table

type Table struct {
	Name string
}

func NewTable

func NewTable(name string) *Table

func (*Table) NewBigIntColumn

func (t *Table) NewBigIntColumn(name string) *BigIntColumn

func (*Table) NewBooleanColumn

func (t *Table) NewBooleanColumn(name string) *BooleanColumn

func (*Table) NewFloatColumn

func (t *Table) NewFloatColumn(name string) *FloatColumn

func (*Table) NewIntegerColumn

func (t *Table) NewIntegerColumn(name string) *IntegerColumn

func (*Table) NewJSONColumn

func (t *Table) NewJSONColumn(name string) *JSONColumn

func (*Table) NewStringColumn

func (t *Table) NewStringColumn(name string) *StringColumn

func (*Table) NewUUIDColumn

func (t *Table) NewUUIDColumn(name string) *UUIDColumn

type UUID

type UUID struct {
	Val  string
	Null bool
	Set  bool
}

func NewNullableUUID

func NewNullableUUID(v *string) UUID

func NewUUID

func NewUUID(v string) UUID

func (UUID) MarshalJSON

func (u UUID) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*UUID) Scan

func (u *UUID) Scan(value interface{}) error

Scan implements the Scanner interface.

func (*UUID) UnmarshalJSON

func (u *UUID) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (UUID) Value

func (u UUID) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type UUIDColumn

type UUIDColumn struct {
	Name  string
	Table *Table
}

func (*UUIDColumn) Asc added in v0.1.5

func (c *UUIDColumn) Asc() string

func (*UUIDColumn) Desc added in v0.1.5

func (c *UUIDColumn) Desc() string

func (*UUIDColumn) EQ

func (c *UUIDColumn) EQ(v string) *Clause

func (*UUIDColumn) NE

func (c *UUIDColumn) NE(v string) *Clause

type UpdateStatement

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

func NewUpdate

func NewUpdate() *UpdateStatement

func (*UpdateStatement) Columns

func (s *UpdateStatement) Columns(columns ...string) *UpdateStatement

func (*UpdateStatement) Returning

func (s *UpdateStatement) Returning(returning string) *UpdateStatement

func (*UpdateStatement) Table

func (s *UpdateStatement) Table(table string) *UpdateStatement

func (*UpdateStatement) ToSQL

func (s *UpdateStatement) ToSQL() (string, []interface{})

func (*UpdateStatement) Values

func (s *UpdateStatement) Values(values ...interface{}) *UpdateStatement

func (*UpdateStatement) Where

func (s *UpdateStatement) Where(expr *Clause) *UpdateStatement

Jump to

Keyboard shortcuts

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