Documentation ¶
Index ¶
- Constants
- Variables
- func AttributeCast(attr *dal.Attribute, val exp.Expression) (exp.Expression, error)
- func BooleanCheck(val exp.Expression) exp.Expression
- func IndexFieldModifiers(attr *dal.Attribute, quoteIdent func(i string) string, ...) (string, error)
- func OpHandlerIn(d Dialect, n *ql.ASTNode, args ...exp.Expression) (expr exp.Expression, err error)
- func OpHandlerNotIn(d Dialect, n *ql.ASTNode, args ...exp.Expression) (expr exp.Expression, err error)
- func RegexpLike(format, val exp.Expression) exp.BooleanExpression
- func TimeLayout(tz bool, precision int) string
- func TimestampLayout(tz bool, precision int) string
- type Column
- type Dialect
- type GenericTableCodec
- func (t *GenericTableCodec) AttributeExpression(ident string) (exp.Expression, error)
- func (t *GenericTableCodec) AttributeExpressionQuoted(ident string) (exp.Expression, error)
- func (t *GenericTableCodec) Columns() []Column
- func (t *GenericTableCodec) Decode(buf []any, r dal.ValueSetter) (err error)
- func (t *GenericTableCodec) Encode(r dal.ValueGetter) (_ []any, err error)
- func (t *GenericTableCodec) Ident() exp.IdentifierExpression
- func (t *GenericTableCodec) MakeScanBuffer() []any
- type ID
- type Nuances
- type SimpleJsonDocColumn
- func (c *SimpleJsonDocColumn) Attribute() *dal.Attribute
- func (c *SimpleJsonDocColumn) Decode(raw any, r dal.ValueSetter) (err error)
- func (c *SimpleJsonDocColumn) DecodeOld(raw any, r dal.ValueSetter) (err error)
- func (c *SimpleJsonDocColumn) Encode(r dal.ValueGetter) (_ any, err error)
- func (c *SimpleJsonDocColumn) IsPrimaryKey() bool
- func (c *SimpleJsonDocColumn) Name() string
- func (c *SimpleJsonDocColumn) Type() Type
- type SingleValueColumn
- func (c *SingleValueColumn) Attribute() *dal.Attribute
- func (c *SingleValueColumn) Decode(raw any, r dal.ValueSetter) error
- func (c *SingleValueColumn) Encode(r dal.ValueGetter) (any, error)
- func (c *SingleValueColumn) IsPrimaryKey() bool
- func (c *SingleValueColumn) Name() string
- func (c *SingleValueColumn) Type() Type
- type TableCodec
- type Type
- type TypeBlob
- type TypeBoolean
- type TypeDate
- type TypeEnum
- type TypeGeometry
- type TypeID
- type TypeJSON
- type TypeNumber
- type TypeRef
- type TypeText
- type TypeTime
- type TypeTimestamp
- type TypeUUID
Constants ¶
View Source
const (
DateLayout = "2006-01-02"
)
Variables ¶
View Source
var ( CheckID = exp.NewLiteralExpression(`'^[0-9]+$'`) CheckNumber = exp.NewLiteralExpression(`'^[+-]?[0-9]+(\.[0-9]+)?$'`) CheckFullISO8061 = exp.NewLiteralExpression(`'^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2}(\.[0-9]*)?)((-([0-9]{2}):([0-9]{2})|Z)?)$'`) CheckDateISO8061 = exp.NewLiteralExpression(`'^([0-9]{4})-([0-9]{2})-([0-9]{2})(T([0-9]{2}):([0-9]{2}):([0-9]{2}(\.[0-9]*)?)((-([0-9]{2}):([0-9]{2})|Z)?))?$'`) CheckTimeISO8061 = exp.NewLiteralExpression(`'^(([0-9]{4})-([0-9]{2})-([0-9]{2}))?T?([0-9]{2}):([0-9]{2}):([0-9]{2}(\.[0-9]*)?)((-([0-9]{2}):([0-9]{2})|Z)?)$'`) LiteralNULL = exp.NewLiteralExpression(`NULL`) LiteralFALSE = exp.NewLiteralExpression(`FALSE`) LiteralTRUE = exp.NewLiteralExpression(`TRUE`) )
Functions ¶
func AttributeCast ¶
func AttributeCast(attr *dal.Attribute, val exp.Expression) (exp.Expression, error)
func BooleanCheck ¶
func BooleanCheck(val exp.Expression) exp.Expression
func IndexFieldModifiers ¶
func IndexFieldModifiers(attr *dal.Attribute, quoteIdent func(i string) string, mm ...dal.IndexFieldModifier) (string, error)
@note copied to data_definer_test to avoid import cycle; if modified, fixup both parts
func OpHandlerIn ¶
func OpHandlerIn(d Dialect, n *ql.ASTNode, args ...exp.Expression) (expr exp.Expression, err error)
func OpHandlerNotIn ¶
func OpHandlerNotIn(d Dialect, n *ql.ASTNode, args ...exp.Expression) (expr exp.Expression, err error)
func RegexpLike ¶
func RegexpLike(format, val exp.Expression) exp.BooleanExpression
func TimeLayout ¶
func TimestampLayout ¶
Types ¶
type Dialect ¶
type Dialect interface { // Nuances returns dialect nuances // subtle differences between RDBMS implementations that // should be handled on common code Nuances() Nuances // GOQU returns goqu's dialect wrapper struct GOQU() goqu.DialectWrapper DialectOptions() *sqlgen.SQLDialectOptions JsonQuote(exp.Expression) exp.Expression // JsonExtract returns expression that returns a value from inside JSON document // // Use this when you want use JSON encoded value JsonExtract(exp.Expression, ...any) (exp.Expression, error) // JsonExtractUnquote returns expression that returns a value from inside JSON document: // // Use this when you want to use unencoded value! JsonExtractUnquote(exp.Expression, ...any) (exp.Expression, error) // JsonArrayContains generates expression JSON array containment check expression // // Literal values need to be JSON docs! // // @todo recheck if we really need JsonArrayContains on Dialect interface JsonArrayContains(needle, haystack exp.Expression) (exp.Expression, error) // AttributeCast prepares complex SQL expression that verifies // arbitrary string value in the db and casts it to b used in // comparison or soring expression AttributeCast(*dal.Attribute, exp.Expression) (exp.Expression, error) AttributeExpression(attr *dal.Attribute, modelIdent string, ident string) (expr exp.Expression, err error) // TableCodec returns table codec (encodes & decodes data to/from db table) TableCodec(*dal.Model) TableCodec // TypeWrap returns driver's type implementation for a particular attribute type TypeWrap(dal.Type) Type QuoteIdent(string) string AggregateBase(t TableCodec, gb []dal.AggregateAttr, out []dal.AggregateAttr) *goqu.SelectDataset // AttributeToColumn converts attribute to column defunition AttributeToColumn(*dal.Attribute) (*ddl.Column, error) ColumnFits(base, assert *ddl.Column) bool // ExprHandler returns driver specific expression handling ExprHandler(*ql.ASTNode, ...exp.Expression) (exp.Expression, error) // ValHandler returns driver specific value expression handling ValHandler(*ql.ASTNode) (exp.Expression, error) // OrderedExpression returns compatible expression for ordering // // Database understand order modifiers differently. For example, MySQL does not know // about NULLS FIRST/LAST. Drivers should gracefully handle this. OrderedExpression(exp.Expression, exp.SortDirection, exp.NullSortType) exp.OrderedExpression }
type GenericTableCodec ¶
type GenericTableCodec struct {
// contains filtered or unexported fields
}
GenericTableCodec is a generic implementation of TableCodec
func NewTableCodec ¶
func NewTableCodec(m *dal.Model, d Dialect) *GenericTableCodec
func (*GenericTableCodec) AttributeExpression ¶
func (t *GenericTableCodec) AttributeExpression(ident string) (exp.Expression, error)
func (*GenericTableCodec) AttributeExpressionQuoted ¶
func (t *GenericTableCodec) AttributeExpressionQuoted(ident string) (exp.Expression, error)
func (*GenericTableCodec) Columns ¶
func (t *GenericTableCodec) Columns() []Column
func (*GenericTableCodec) Decode ¶
func (t *GenericTableCodec) Decode(buf []any, r dal.ValueSetter) (err error)
func (*GenericTableCodec) Encode ¶
func (t *GenericTableCodec) Encode(r dal.ValueGetter) (_ []any, err error)
func (*GenericTableCodec) Ident ¶
func (t *GenericTableCodec) Ident() exp.IdentifierExpression
func (*GenericTableCodec) MakeScanBuffer ¶
func (t *GenericTableCodec) MakeScanBuffer() []any
type ID ¶
nullUint64 represents an uint64 that may be null. nullUint64 implements the Scanner interface so it can be used as a scan dåestination, similar to NullString.
type Nuances ¶
type Nuances struct { // HavingClauseMustUseAlias // For example, Postgres and SQLite require // use of aliases inside HAVING clause and // MySQL does not. HavingClauseMustUseAlias bool // TwoStepUpsert allows support for databases which don't have an upsert // or we simply couldn't figure out how to make work. // // TwoStepUpsert uses the context from the update statement to figure out // if it needs to do an insert. TwoStepUpsert bool // @todo change this around; temporary fix as not sure how I'd rewrite ExpandedJsonColumnSelector func(ident string) exp.Expression }
type SimpleJsonDocColumn ¶
type SimpleJsonDocColumn struct {
// contains filtered or unexported fields
}
func (*SimpleJsonDocColumn) Attribute ¶
func (c *SimpleJsonDocColumn) Attribute() *dal.Attribute
func (*SimpleJsonDocColumn) Decode ¶
func (c *SimpleJsonDocColumn) Decode(raw any, r dal.ValueSetter) (err error)
func (*SimpleJsonDocColumn) DecodeOld ¶
func (c *SimpleJsonDocColumn) DecodeOld(raw any, r dal.ValueSetter) (err error)
func (*SimpleJsonDocColumn) Encode ¶
func (c *SimpleJsonDocColumn) Encode(r dal.ValueGetter) (_ any, err error)
func (*SimpleJsonDocColumn) IsPrimaryKey ¶
func (c *SimpleJsonDocColumn) IsPrimaryKey() bool
func (*SimpleJsonDocColumn) Name ¶
func (c *SimpleJsonDocColumn) Name() string
func (*SimpleJsonDocColumn) Type ¶
func (c *SimpleJsonDocColumn) Type() Type
type SingleValueColumn ¶
type SingleValueColumn struct {
// contains filtered or unexported fields
}
func NewSingleValueColumn ¶
func NewSingleValueColumn(d Dialect, a *dal.Attribute) *SingleValueColumn
func (*SingleValueColumn) Attribute ¶
func (c *SingleValueColumn) Attribute() *dal.Attribute
func (*SingleValueColumn) Decode ¶
func (c *SingleValueColumn) Decode(raw any, r dal.ValueSetter) error
func (*SingleValueColumn) Encode ¶
func (c *SingleValueColumn) Encode(r dal.ValueGetter) (any, error)
func (*SingleValueColumn) IsPrimaryKey ¶
func (c *SingleValueColumn) IsPrimaryKey() bool
func (*SingleValueColumn) Name ¶
func (c *SingleValueColumn) Name() string
func (*SingleValueColumn) Type ¶
func (c *SingleValueColumn) Type() Type
type TableCodec ¶
type TableCodec interface { Columns() []Column Ident() exp.IdentifierExpression MakeScanBuffer() []any Encode(r dal.ValueGetter) (_ []any, err error) Decode(buf []any, r dal.ValueSetter) (err error) AttributeExpression(string) (exp.Expression, error) AttributeExpressionQuoted(string) (exp.Expression, error) }
TableCodec is an RDBMS representation of data.Model structure and its arguments
type Type ¶
type TypeBlob ¶
func (*TypeBlob) MakeScanBuffer ¶
type TypeBoolean ¶
type TypeBoolean struct{ *dal.TypeBoolean }
func (*TypeBoolean) MakeScanBuffer ¶
func (*TypeBoolean) MakeScanBuffer() any
type TypeDate ¶
func (*TypeDate) MakeScanBuffer ¶
type TypeEnum ¶
func (*TypeEnum) MakeScanBuffer ¶
type TypeGeometry ¶
type TypeGeometry struct{ *dal.TypeGeometry }
func (*TypeGeometry) MakeScanBuffer ¶
func (*TypeGeometry) MakeScanBuffer() any
type TypeID ¶
func (*TypeID) MakeScanBuffer ¶
type TypeJSON ¶
func (*TypeJSON) MakeScanBuffer ¶
type TypeNumber ¶
type TypeNumber struct{ *dal.TypeNumber }
func (*TypeNumber) MakeScanBuffer ¶
func (*TypeNumber) MakeScanBuffer() any
type TypeRef ¶
func (*TypeRef) MakeScanBuffer ¶
type TypeText ¶
func (*TypeText) MakeScanBuffer ¶
type TypeTime ¶
func (*TypeTime) MakeScanBuffer ¶
type TypeTimestamp ¶
type TypeTimestamp struct{ *dal.TypeTimestamp }
func (*TypeTimestamp) MakeScanBuffer ¶
func (*TypeTimestamp) MakeScanBuffer() any
Click to show internal directories.
Click to hide internal directories.