Documentation
¶
Index ¶
- Variables
- type AllDirective
- type BetweenColumnDirective
- type BetweenStructField
- type Boolean
- type ColIdent
- type ColIdentList
- type ColumnDirective
- type ConstraintDirective
- type ContextField
- type DefaultDirective
- type ErrorHandlerField
- type FieldInfo
- type FieldPtr
- type FieldSelectorNode
- type FieldVar
- type FilterConstructorField
- type FilterField
- type FilterStruct
- type ForceDirective
- type FuncName
- type IgnoreDirective
- type IndexDirective
- type Info
- type JoinBoolTagItem
- type JoinConditionTagItem
- type JoinDirective
- type JoinStruct
- type JoinTagItem
- type JoinType
- type LimitField
- type LiteralType
- type NullsPosition
- type OffsetField
- type OnConflictStruct
- type OptionalDirective
- type OrderByDirective
- type OrderByTagItem
- type OrderDirection
- type OverrideDirective
- type OverridingKind
- type Predicate
- func (p Predicate) CanQuantify() bool
- func (p Predicate) IsArray() bool
- func (p Predicate) IsBinary() bool
- func (p Predicate) IsBoolean() bool
- func (p Predicate) IsNull() bool
- func (p Predicate) IsOneOf(pp ...Predicate) bool
- func (p Predicate) IsPatternMatch() bool
- func (p Predicate) IsRange() bool
- func (p Predicate) IsUnary() bool
- func (p Predicate) String() string
- type Quantifier
- type QueryKind
- type QueryStruct
- func (s *QueryStruct) GetRelField() *RelField
- func (s *QueryStruct) GetRelIdent() RelIdent
- func (s *QueryStruct) HasNoErrorInfoHandler() bool
- func (s *QueryStruct) HasNoQualifier() bool
- func (s *QueryStruct) HasQualifier() bool
- func (s *QueryStruct) IsInsertOrUpdate() bool
- func (s *QueryStruct) IsInsertOrUpdateSlice() bool
- func (s *QueryStruct) IsSelectCountOrExists() bool
- func (s *QueryStruct) IsSingleOutput() bool
- func (s *QueryStruct) IsUpdateSlice() bool
- func (s *QueryStruct) IsUpdateWithPKeys() bool
- func (s *QueryStruct) IsUpdateWithoutPKeys() bool
- func (s *QueryStruct) IsWithoutOutput() bool
- func (s *QueryStruct) OutputIsAfterScanner() bool
- func (s *QueryStruct) OutputRelFieldName() string
- func (s *QueryStruct) OutputRelType() RelType
- type RangeBound
- type RelField
- type RelIdent
- type RelType
- type RelationDirective
- type ResultField
- type ReturnDirective
- type RowsAffectedField
- type TargetStruct
- type TextSearchDirective
- type TypeInfo
- func (t *TypeInfo) GenericLiteral() LiteralType
- func (t *TypeInfo) ImplementsJSONMarshaler() bool
- func (t *TypeInfo) ImplementsJSONUnmarshaler() bool
- func (t TypeInfo) ImplementsScanner() bool
- func (t TypeInfo) ImplementsValuer() bool
- func (t *TypeInfo) ImplementsXMLMarshaler() bool
- func (t *TypeInfo) ImplementsXMLUnmarshaler() bool
- func (t *TypeInfo) Is(kk ...TypeKind) bool
- func (t *TypeInfo) IsArray() bool
- func (t *TypeInfo) IsJSONIllegal() bool
- func (t *TypeInfo) IsNilable() bool
- func (t *TypeInfo) IsSequence() bool
- func (t *TypeInfo) IsSlice() bool
- func (t *TypeInfo) IsSliceKind(kk ...TypeKind) bool
- func (t *TypeInfo) IsXMLIllegal() bool
- func (t *TypeInfo) Literal() LiteralType
- type TypeKind
- type UpdateDirective
- type WhereBetweenStruct
- type WhereBoolTag
- type WhereColumnDirective
- type WhereItem
- type WhereStruct
- type WhereStructField
Constants ¶
This section is empty.
Variables ¶
var JoinTypes = [...]string{ JoinTypeCross: "CrossJoin", JoinTypeInner: "InnerJoin", JoinTypeLeft: "LeftJoin", JoinTypeRight: "RightJoin", JoinTypeFull: "FullJoin", }
JoinTypes is an array of join directive names indexed by their respective JoinType values.
Functions ¶
This section is empty.
Types ¶
type AllDirective ¶
type AllDirective struct { }
AllDirective is the result of analyzing the "_ gosql.All" directive.
type BetweenColumnDirective ¶
type BetweenColumnDirective struct { // The column identifier parsed from the field's `sql` tag. ColIdent ColIdent }
BetweenColumnDirective is the result of analyzing a "_ gosql.Column" directive field in a BetweenStruct.
type BetweenStructField ¶
type BetweenStructField struct { // The name of the field. Name string // The information on the type of the field. Type TypeInfo }
BetweenStructField is the result of analyzing a plain BetweenStruct field.
type Boolean ¶
type Boolean uint8
boolean operation
const ( BoolAnd Boolean // conjunction BoolOr // disjunction BoolNot // negation )
type ColIdent ¶
type ColIdent struct { // The name of the column. Name string // The table or table alias qualifier of the column, or empty. Qualifier string }
ColIdent represents a column identifier as parsed from a field's `sql` tag.
type ColIdentList ¶
type ColIdentList struct { // The individual column identifiers parsed from the `sql` tag. Items []ColIdent // If set to `true`, indicates that "*" was used in the `sql` tag. All bool }
ColIdentList represents a list of column identifiers as parsed from a field's `sql` tag.
func (*ColIdentList) Contains ¶
func (cl *ColIdentList) Contains(cid ColIdent) bool
containts reports whether or not the list contains the given column identifier.
type ColumnDirective ¶
type ColumnDirective struct { // The list of column identifiers as parsed from the `sql` tag of the directive. ColIdents []ColIdent }
ColumnDirective is the result of analyzing the "_ gosql.Column" directive.
type ConstraintDirective ¶
type ConstraintDirective struct { // The name of the constraint as parsed from the `sql` tag of the directive. Name string }
ConstraintDirective is the result of analyzing the "_ gosql.Constraint" directive.
type ContextField ¶
type ContextField struct { // Name of the field (case preserved). Name string }
ContextField is the result of analyzing a query struct's context.Context type field.
type DefaultDirective ¶
type DefaultDirective struct { // The list of column identifiers as parsed from the `sql` tag of the directive. ColIdentList }
DefaultDirective is the result of analyzing the "_ gosql.Default" directive.
type ErrorHandlerField ¶
type ErrorHandlerField struct { // Name of the field (case preserved). Name string // Indicates whether or not the field's type implements // the gosql.ErrorInfoHandler interface. IsInfo bool }
ErrorHandlerField is the result of analyzing a query struct's field whose type implements the gosql.ErrorHandler or gosql.ErrorInfoHandler interface.
type FieldInfo ¶
type FieldInfo struct { // Name of the struct field. Name string // Info about the field's type. Type TypeInfo // If the field is nested, selector will hold the parent fields' information. Selector []*FieldSelectorNode // Indicates whether or not the field is embedded. IsEmbedded bool // Indicates whether or not the field is exported. IsExported bool // The field's parsed tag. Tag tagutil.Tag // The column identifier parsed from the field's `sql` tag. ColIdent ColIdent // If set, indicates the the "nullempty" option was used in the field's `sql` tag. NullEmpty bool // If set, indicates the the "ro" option was used in the field's `sql` tag. ReadOnly bool // If set, indicates the the "wo" option was used in the field's `sql` tag. WriteOnly bool // If set, indicates the the "default" option was used in the field's `sql` tag. UseDefault bool // If set, indicates the the "add" option was used in the field's `sql` tag. UseAdd bool // If set, indicates the the "coalesce" option was used in the field's `sql` tag. UseCoalesce bool // Will hold the "alternative" value as parsed from the "coalesce" option of the field's `sql` tag. CoalesceValue string }
FieldInfo is the result of analyzing a RelType's field and its associated tag.
type FieldPtr ¶
type FieldPtr interface{}
FieldPtr represents a pointer to the result of an analyzed struct field.
type FieldSelectorNode ¶
type FieldSelectorNode struct { // The name of the field. Name string // The tag of the field. Tag tagutil.Tag // The name of the field's type. Empty if the type is unnamed. TypeName string // The package import path for the field's type. Empty if the type is unnamed. TypePkgPath string // The name of the package of the field's type. Empty if the type is unnamed. TypePkgName string // The local name of the imported package of the field's type (including "."). // Empty if the type is unnamed. TypePkgLocal string // Indicates whether or not the type is imported. IsImported bool // Indicates whether or not the field is embedded. IsEmbedded bool // Indicates whether or not the field is exported. IsExported bool // Indicates whether or not the field type is a pointer type. IsPointer bool }
FieldSelectorNode represents a single node in a nested field's "selector". This is a stripped-down version of FieldInfo that holds only that information that is needed by the generator to produce correct Go field selector expressions.
type FieldVar ¶
type FieldVar struct { // types.Var representation of the struct field. Var *types.Var // The raw string value of the field's tag. Tag string }
FieldVar holds the types.Var represenation and the raw tag of a struct field.
type FilterConstructorField ¶
type FilterConstructorField struct { // Name of the field (case preserved). Name string }
FilterConstructorField is the result of analyzing a filter struct's field that implements the gosql.FilterConstructor interface.
type FilterField ¶
type FilterField struct { // Name of the field (case preserved). Name string }
FilterField is the result of analyzing a query struct's gosql.Filter type field.
type FilterStruct ¶
type FilterStruct struct { // Name of the filter struct type. TypeName string // The primary, `rel`-tagged field of the filter struct type. Rel *RelField // Info on the gosql.TextSearch directive field of the filter struct type, or nil. TextSearch *TextSearchDirective // Info on the field that implements the gosql.FilterConstructor interface. FilterConstructor *FilterConstructorField }
FilterStruct represents the result of the analysis of a target "filter" struct type.
func (*FilterStruct) GetRelField ¶
func (s *FilterStruct) GetRelField() *RelField
GetRelField (implements TargetStruct) returns the RelField of the FilterStruct.
func (*FilterStruct) GetRelIdent ¶
func (s *FilterStruct) GetRelIdent() RelIdent
GetRelIdent (implements TargetStruct) returns the RelIdent of the FilterStruct.
type ForceDirective ¶
type ForceDirective struct { // The list of column identifiers as parsed from the `sql` tag of the directive. ColIdentList }
ForceDirective is the result of analyzing the "_ gosql.Force" directive.
type FuncName ¶
type FuncName string
FuncName is the name of a database function that can either be used to modify a value, like lower, upper, etc. or a function that can be used as an aggregate.
type IgnoreDirective ¶
type IgnoreDirective struct { }
IgnoreDirective is the result of analyzing the "_ gosql.Ignore" directive.
type IndexDirective ¶
type IndexDirective struct { // The name of the index as parsed from the `sql` tag of the directive. Name string }
IndexDirective is the result of analyzing the "_ gosql.Index" directive.
type Info ¶
type Info struct { // The FileSet associated with the analyzed TargetStruct. FileSet *token.FileSet // The package path of the analyzed TargetStruct. PkgPath string // The type name of the analyzed TargetStruct. TypeName string // The soruce position of the TargetStruct's type name. TypeNamePos token.Pos // FieldMap maintains a map of pointers of arbitrary type that represent // the result of analyzed fields, to the fields' related go/types specific // information. Intended for error reporting by the backend type-checker. FieldMap map[FieldPtr]FieldVar // RelSpace maintains a set of *unique* relation names or aliases that map // onto their respective RelIdent values that were parsed from struct tags. RelSpace map[string]RelIdent }
Info holds information related to an analyzed TargetStruct. If the analysis returns an error, the collected information will be incomplete.
type JoinBoolTagItem ¶
type JoinBoolTagItem WhereBoolTag
JoinBoolTagItem is the boolean operator parsed from a join directive's `sql` tag.
type JoinConditionTagItem ¶
type JoinConditionTagItem WhereColumnDirective
JoinConditionTagItem is the conditional expression parsed from a join directive's `sql` tag.
type JoinDirective ¶
type JoinDirective struct { // The type of the join. JoinType JoinType // The relation identifier parsed from the `sql` tag. RelIdent RelIdent // List of items parsed from the `sql` tag. TagItems []JoinTagItem }
JoinDirective is the result of analyzing one of the "_ gosql.JoinXxx" directives.
type JoinStruct ¶
type JoinStruct struct { // Name of the field (case preserved). FieldName string // Info on the gosql.Relation directive of the "from" and "using" // JoinStruct variation, nil for the "join" variation. Relation *RelationDirective // The list of gosql.JoinXxx directives declared in the JoinStruct. Directives []*JoinDirective }
JoinStruct represents a struct analyzed from a QueryStruct's field named "join", "from", or "using" (case insensitive).
type JoinTagItem ¶
type JoinTagItem interface {
// contains filtered or unexported methods
}
The JoinTagItem interface is implemented by the JoinBoolTagItem and JoinConditionTagItem types.
type JoinType ¶
type JoinType uint8
JoinType indicates the gosql.XxxJoin directive used in a query struct.
const ( JoinTypeCross JoinType // CROSS JOIN JoinTypeInner // INNER JOIN JoinTypeLeft // LEFT JOIN JoinTypeRight // RIGHT JOIN JoinTypeFull // FULL JOIN )
type LimitField ¶
type LimitField struct { // The name of the field (case preserved), or empty if it's a gosql.Limit directive. Name string // The value provided in the limit field's / directive's `sql` tag. // If the LimitField was produced from a directive the value will be // used as a constant. // // If the LimitField was produced from a normal field the value should *only* // be used if the field's actual value is empty, at runtime during the query's // execution, essentially acting as a default fallback. Value uint64 }
The LimitField is the result of analyzing a query struct's "limit" (case insensitive) field or the "_ gosql.Limit" directive.
type LiteralType ¶
type LiteralType string
LiteralType is a string representation of literal type or type name.
const ( LiteralBool LiteralType = "bool" LiteralBoolSlice LiteralType = "[]bool" LiteralBoolSliceSlice LiteralType = "[][]bool" LiteralString LiteralType = "string" LiteralStringSlice LiteralType = "[]string" LiteralStringSliceSlice LiteralType = "[][]string" LiteralStringMap LiteralType = "map[string]string" LiteralStringMapSlice LiteralType = "[]map[string]string" LiteralByte LiteralType = "byte" LiteralByteSlice LiteralType = "[]byte" LiteralByteSliceSlice LiteralType = "[][]byte" LiteralByteSliceSliceSlice LiteralType = "[][][]byte" LiteralByteArray16 LiteralType = "[16]byte" LiteralByteArray16Slice LiteralType = "[][16]byte" LiteralRune LiteralType = "rune" LiteralRuneSlice LiteralType = "[]rune" LiteralRuneSliceSlice LiteralType = "[][]rune" LiteralInt LiteralType = "int" LiteralIntSlice LiteralType = "[]int" LiteralIntSliceSlice LiteralType = "[][]int" LiteralIntArray2 LiteralType = "[2]int" LiteralIntArray2Slice LiteralType = "[][2]int" LiteralInt8 LiteralType = "int8" LiteralInt8Slice LiteralType = "[]int8" LiteralInt8SliceSlice LiteralType = "[][]int8" LiteralInt8Array2 LiteralType = "[2]int8" LiteralInt8Array2Slice LiteralType = "[][2]int8" LiteralInt16 LiteralType = "int16" LiteralInt16Slice LiteralType = "[]int16" LiteralInt16SliceSlice LiteralType = "[][]int16" LiteralInt16Array2 LiteralType = "[2]int16" LiteralInt16Array2Slice LiteralType = "[][2]int16" LiteralInt32 LiteralType = "int32" LiteralInt32Slice LiteralType = "[]int32" LiteralInt32SliceSlice LiteralType = "[][]int32" LiteralInt32Array2 LiteralType = "[2]int32" LiteralInt32Array2Slice LiteralType = "[][2]int32" LiteralInt64 LiteralType = "int64" LiteralInt64Slice LiteralType = "[]int64" LiteralInt64SliceSlice LiteralType = "[][]int64" LiteralInt64Array2 LiteralType = "[2]int64" LiteralInt64Array2Slice LiteralType = "[][2]int64" LiteralUint LiteralType = "uint" LiteralUintSlice LiteralType = "[]uint" LiteralUintSliceSlice LiteralType = "[][]uint" LiteralUintArray2 LiteralType = "[2]uint" LiteralUintArray2Slice LiteralType = "[][2]uint" LiteralUint8 LiteralType = "uint8" LiteralUint8Slice LiteralType = "[]uint8" LiteralUint8SliceSlice LiteralType = "[][]uint8" LiteralUint8Array2 LiteralType = "[2]uint8" LiteralUint8Array2Slice LiteralType = "[][2]uint8" LiteralUint16 LiteralType = "uint16" LiteralUint16Slice LiteralType = "[]uint16" LiteralUint16SliceSlice LiteralType = "[][]uint16" LiteralUint16Array2 LiteralType = "[2]uint16" LiteralUint16Array2Slice LiteralType = "[][2]uint16" LiteralUint32 LiteralType = "uint32" LiteralUint32Slice LiteralType = "[]uint32" LiteralUint32SliceSlice LiteralType = "[][]uint32" LiteralUint32Array2 LiteralType = "[2]uint32" LiteralUint32Array2Slice LiteralType = "[][2]uint32" LiteralUint64 LiteralType = "uint64" LiteralUint64Slice LiteralType = "[]uint64" LiteralUint64SliceSlice LiteralType = "[][]uint64" LiteralUint64Array2 LiteralType = "[2]uint64" LiteralUint64Array2Slice LiteralType = "[][2]uint64" LiteralFloat32 LiteralType = "float32" LiteralFloat32Slice LiteralType = "[]float32" LiteralFloat32SliceSlice LiteralType = "[][]float32" LiteralFloat32Array2 LiteralType = "[2]float32" LiteralFloat32Array2Slice LiteralType = "[][2]float32" LiteralFloat64 LiteralType = "float64" LiteralFloat64Slice LiteralType = "[]float64" LiteralFloat64SliceSlice LiteralType = "[][]float64" LiteralFloat64Array2 LiteralType = "[2]float64" LiteralFloat64Array2Slice LiteralType = "[][2]float64" LiteralFloat64Array2SliceSlice LiteralType = "[][][2]float64" LiteralFloat64Array2Array2 LiteralType = "[2][2]float64" LiteralFloat64Array2Array2Slice LiteralType = "[][2][2]float64" LiteralFloat64Array3 LiteralType = "[3]float64" LiteralFloat64Array3Slice LiteralType = "[][3]float64" LiteralIP LiteralType = "net.IP" LiteralIPSlice LiteralType = "[]net.IP" LiteralIPNet LiteralType = "net.IPNet" LiteralIPNetSlice LiteralType = "[]net.IPNet" LiteralHardwareAddr LiteralType = "net.HardwareAddr" LiteralHardwareAddrSlice LiteralType = "[]net.HardwareAddr" LiteralTime LiteralType = "time.Time" LiteralTimeSlice LiteralType = "[]time.Time" LiteralTimeArray2 LiteralType = "[2]time.Time" LiteralTimeArray2Slice LiteralType = "[][2]time.Time" LiteralBigInt LiteralType = "big.Int" LiteralBigIntSlice LiteralType = "[]big.Int" LiteralBigIntArray2 LiteralType = "[2]big.Int" LiteralBigIntArray2Slice LiteralType = "[][2]big.Int" LiteralBigFloat LiteralType = "big.Float" LiteralBigFloatSlice LiteralType = "[]big.Float" LiteralBigFloatArray2 LiteralType = "[2]big.Float" LiteralBigFloatArray2Slice LiteralType = "[][2]big.Float" LiteralNullStringMap LiteralType = "map[string]sql.NullString" LiteralNullStringMapSlice LiteralType = "[]map[string]sql.NullString" LiteralStringPtrMap LiteralType = "map[string]*string" LiteralStringPtrMapSlice LiteralType = "[]map[string]*string" LiteralEmptyInterface LiteralType = "interface{}" )
type NullsPosition ¶
type NullsPosition uint8
NullsPosition is used to specify the position of NULLs in an ORDER BY clause.
const ( NullsFirst NullsPosition // NULLS FIRST NullsLast // NULLS LAST )
type OffsetField ¶
type OffsetField struct { // The name of the field (case preserved), or empty if it's a gosql.Offset directive. Name string // The value provided in the offset field's / directive's `sql` tag. // If the OffsetField was produced from a directive the value will be // used as a constant. // // If the OffsetField was produced from a normal field the value should *only* // be used if the field's actual value is empty, at runtime during the query's // execution, essentially acting as a default fallback. Value uint64 }
The OffsetField is the result of analyzing a query struct's "offset" (case insensitive) field or the "_ gosql.Offset" directive.
type OnConflictStruct ¶
type OnConflictStruct struct { // Name of the field (case preserved). FieldName string // If set, indicates that the gosql.Column "conflict_target" directive was used. Column *ColumnDirective // If set, indicates that the gosql.Index "conflict_target" directive was used. Index *IndexDirective // If set, indicates that the gosql.Constraint "conflict_target" directive was used. Constraint *ConstraintDirective // If set, indicates that the gosql.Ignore "conflict_action" directive was used. Ignore *IgnoreDirective // If set, indicates that the gosql.Update "conflict_action" directive was used. Update *UpdateDirective }
OnConflictStruct represents a struct analyzed from a QueryStruct's field named "onconflict" (case insensitive).
type OptionalDirective ¶ added in v0.0.3
type OptionalDirective struct { // The list of column identifiers as parsed from the `sql` tag of the directive. ColIdentList }
OptionalDirective is the result of analyzing the "_ gosql.Optional" directive.
type OrderByDirective ¶
type OrderByDirective struct { // The list of ORDER BY items as parsed from the `sql` tag of the directive. Items []OrderByTagItem }
OrderByDirective is the result of analyzing the "_ gosql.OrderBy" directive.
type OrderByTagItem ¶
type OrderByTagItem struct { // The column identifier parsed from the `sql` tag. ColIdent ColIdent // The ordering direction parsed from the `sql` tag. Direction OrderDirection // The NULL position parsed from the `sql` tag. Nulls NullsPosition }
OrderByTagItem represents a single item parsed from the tag of a "_ gosql.OrderBy" directive.
type OrderDirection ¶
type OrderDirection uint8
OrderDirection is used to specify the order direction in an ORDER BY clause.
const ( OrderAsc OrderDirection = iota // ASC, default OrderDesc // DESC )
type OverrideDirective ¶
type OverrideDirective struct { // The OVERRIDING value as parsed from the `sql` tag of the directive. Kind OverridingKind }
OverrideDirective is the result of analyzing the "_ gosql.Override" directive.
type OverridingKind ¶
type OverridingKind uint8
OverridingKind indicates the option used with the gosql.Override directive.
const ( OverridingSystem OverridingKind // OVERRIDING SYSTEM VALUE OverridingUser // OVERRIDING USER VALUE )
type Predicate ¶
type Predicate uint
Predicate represents the predicate type of a search condition.
const ( IsEQ Predicate // equals NotEQ // not equals NotEQ2 // not equals IsLT // less than IsGT // greater than IsLTE // less than or equal IsGTE // greater than or equal IsDistinct // IS DISTINCT FROM NotDistinct // IS NOT DISTINCT FROM IsMatch // match regular expression IsMatchi // match regular expression (case insensitive) NotMatch // not match regular expression NotMatchi // not match regular expression (case insensitive) IsLike // LIKE NotLike // NOT LIKE IsILike // ILIKE NotILike // NOT ILIKE IsSimilar // IS SIMILAR TO NotSimilar // IS NOT SIMILAR TO IsIn // IN NotIn // NOT IN IsBetween // BETWEEN x AND y NotBetween // NOT BETWEEN x AND y IsBetweenSym // BETWEEN SYMMETRIC x AND y NotBetweenSym // NOT BETWEEN SYMMETRIC x AND y IsBetweenAsym // BETWEEN ASYMMETRIC x AND y NotBetweenAsym // NOT BETWEEN ASYMMETRIC x AND y IsNull // IS NULL NotNull // IS NOT NULL IsTrue // IS TRUE NotTrue // IS NOT TRUE IsFalse // IS FALSE NotFalse // IS NOT FALSE IsUnknown // IS UNKNOWN NotUnknown // IS NOT UNKNOWN )
func (Predicate) CanQuantify ¶
CanQuantify reports whether or not the predicate can be used together with a quantifier.
func (Predicate) IsArray ¶
IsArray reports whether or not the predicate represents an array comparison.
func (Predicate) IsBinary ¶
IsBinary reports whether or not the predicate represents a binary comparison.
func (Predicate) IsBoolean ¶
IsBoolean reports whether or not the predicate represents a boolean test.
func (Predicate) IsPatternMatch ¶
IsPatternMatch reports whether or not the predicate represents a pattern-match comparison.
func (Predicate) IsRange ¶
IsRange reports whether or not the predicate represents a range comparison.
type Quantifier ¶
type Quantifier uint8
Quantifier represents the type of a comparison predicate quantifier.
const ( QuantAny Quantifier // ANY QuantSome // SOME QuantAll // ALL )
func (Quantifier) String ¶
func (q Quantifier) String() string
type QueryKind ¶
type QueryKind uint8
const ( QueryKindInsert QueryKind QueryKindUpdate QueryKindDelete QueryKindSelect QueryKindSelectCount QueryKindSelectExists QueryKindSelectNotExists )
type QueryStruct ¶
type QueryStruct struct { // Name of the query struct type. TypeName string // The queryKind analyzed from query struct's type name. Kind QueryKind // The primary, `rel`-tagged field of the query struct. Rel *RelField // Info on the "result" field of the query struct type, or nil. Result *ResultField // Info on the "where" struct field of the query struct type, or nil. Where *WhereStruct // Info on the "join", "using", or "from" struct field of the query struct type, or nil. Join *JoinStruct // Info on the "onConflict" struct field of the query struct type, or nil. OnConflict *OnConflictStruct // Info on the gosql.OrderBy directive field of the query struct type, or nil. OrderBy *OrderByDirective // Info on the "limit" field or the gosql.Limit directive of the query struct type, or nil. Limit *LimitField // Info on the "offset" field or the gosql.Offset directive of the query struct type, or nil. Offset *OffsetField // Info on the "rowsaffected" field of the query struct type, or nil. RowsAffected *RowsAffectedField // Info on the gosql.Force directive field of the query struct type, or nil. Force *ForceDirective // Info on the gosql.Optional directive field of the query struct type, or nil. Optional *OptionalDirective // Info on the gosql.Default directive field of the query struct type, or nil. Default *DefaultDirective // Info on the gosql.Return directive field of the query struct type, or nil. Return *ReturnDirective // Info on the gosql.Override directive field of the query struct type, or nil. Override *OverrideDirective // Info on the gosql.ErrorHandler or gosql.ErrorInfoHandler field of the query struct type, or nil. ErrorHandler *ErrorHandlerField // Info on the gosql.Filter field of the query struct type, or nil. Filter *FilterField // Info on the context.Context field of the query struct type, or nil. Context *ContextField // Info on the gosql.All directive field of the query struct type, or nil. All *AllDirective }
QueryStruct represents the result of the analysis of a target "query" struct type.
func (*QueryStruct) GetRelField ¶
func (s *QueryStruct) GetRelField() *RelField
GetRelField (implements TargetStruct) returns the RelField of the QueryStruct.
func (*QueryStruct) GetRelIdent ¶
func (s *QueryStruct) GetRelIdent() RelIdent
GetRelIdent (implements TargetStruct) returns the RelIdent of the QueryStruct.
func (*QueryStruct) HasNoErrorInfoHandler ¶
func (s *QueryStruct) HasNoErrorInfoHandler() bool
func (*QueryStruct) HasNoQualifier ¶
func (s *QueryStruct) HasNoQualifier() bool
func (*QueryStruct) HasQualifier ¶
func (s *QueryStruct) HasQualifier() bool
func (*QueryStruct) IsInsertOrUpdate ¶
func (s *QueryStruct) IsInsertOrUpdate() bool
func (*QueryStruct) IsInsertOrUpdateSlice ¶
func (s *QueryStruct) IsInsertOrUpdateSlice() bool
func (*QueryStruct) IsSelectCountOrExists ¶
func (s *QueryStruct) IsSelectCountOrExists() bool
func (*QueryStruct) IsSingleOutput ¶
func (s *QueryStruct) IsSingleOutput() bool
func (*QueryStruct) IsUpdateSlice ¶
func (s *QueryStruct) IsUpdateSlice() bool
func (*QueryStruct) IsUpdateWithPKeys ¶
func (s *QueryStruct) IsUpdateWithPKeys() bool
func (*QueryStruct) IsUpdateWithoutPKeys ¶
func (s *QueryStruct) IsUpdateWithoutPKeys() bool
func (*QueryStruct) IsWithoutOutput ¶
func (s *QueryStruct) IsWithoutOutput() bool
func (*QueryStruct) OutputIsAfterScanner ¶
func (s *QueryStruct) OutputIsAfterScanner() bool
OutputIsAfterScanner reports whether or not the QueryStruct's output type implements the AfterScanner interface.
func (*QueryStruct) OutputRelFieldName ¶
func (s *QueryStruct) OutputRelFieldName() string
func (*QueryStruct) OutputRelType ¶
func (s *QueryStruct) OutputRelType() RelType
OutputRelType returns the RelType representation of the QueryStruct's output.
type RangeBound ¶
type RangeBound interface {
// contains filtered or unexported methods
}
The RangeBound interface is implemented by the BetweenStructField and BetweenColumnDirective types.
type RelField ¶
type RelField struct { // Name of the field. FieldName string // The relation identifier parsed from the field's `rel` tag. Id RelIdent // The type information of the field. Type RelType // Indicates whether or not the gosql.Relation directive was used. IsDirective bool }
RelField is the primary, `rel`-tagged field of a "query" or "filter" struct type.
type RelIdent ¶
type RelIdent struct { // The name of the relation. Name string // The alias of the relation, or empty. Alias string // The schema qualifier of the relation, or empty. Qualifier string }
RelIdent represents a relation identifier as parsed from a `rel` or `sql` tag.
func (*RelIdent) QualifiedName ¶
type RelType ¶
type RelType struct { // Information on the "rel" field's base type. Base TypeInfo // Indicates whether or not the base type's a pointer type. IsPointer bool // Indicates whether or not the base type's a slice type. IsSlice bool // Indicates whether or not the base type's an array type. IsArray bool // If the base type's an array type, this field will hold the array's length. ArrayLen int64 // If set, indicates that the type is handled by an iterator. IsIter bool // If set the value will hold the method name of the iterator interface. IterMethod string // Indicates whether or not the type implements the gosql.AfterScanner interface. IsAfterScanner bool // fields holds the information on the type's struct fields. Fields []*FieldInfo // A map of FieldInfo pointers to source code information about the field. // Used only for error reporting, after analysis of the RelType instance // this map is merged into the fieldMap of the targetInfo instance. // // Use `cmp:"-"` to ignore the map's contents during testing since // the map as an intermediary container is of secondary importance, // plus initializing it for the comparison to succeed would be too // much work with little to no return. FieldMap map[FieldPtr]FieldVar `cmp:"-"` }
RelType holds the type information of the "rel" field of a "query" or "filter" struct type.
func (*RelType) HasFieldWithColumn ¶
HasFieldWithColumn reports whether or not the RelType has a field with a column identifier whose name matches the given colName.
type RelationDirective ¶
type RelationDirective struct { // The relation identifier as parsed from the `rel` tag of the directive. RelIdent RelIdent }
RelationDirective is the result of analyzing the "_ gosql.Relation" directive.
type ResultField ¶
type ResultField struct { // Name of the field (case preserved). FieldName string // The type information of the field. Type RelType }
ResultField is the result of analyzing a query struct's field named "result" (case insensitive).
type ReturnDirective ¶
type ReturnDirective struct { // The list of column identifiers as parsed from the `sql` tag of the directive. ColIdentList }
ReturnDirective is the result of analyzing the "_ gosql.Return" directive.
type RowsAffectedField ¶
type RowsAffectedField struct { // Name of the field (case preserved). Name string // The kind of the field's type. TypeKind TypeKind }
RowsAffectedField is the result of the analyzing a query struct's "rowsaffected" (case insensitive) field.
type TargetStruct ¶
type TargetStruct interface { // GetRelField should return the RelField of the target relation. GetRelField() *RelField // GetRelIdent should return the RelIdent of the target relation. GetRelIdent() RelIdent // contains filtered or unexported methods }
The TargetStruct interface is implemented by the QueryStruct and FilterStruct types.
type TextSearchDirective ¶
type TextSearchDirective struct { // The column identifier as parsed from the `sql` tag of the directive. ColIdent }
TextSearchDirective is the result of analyzing the "_ gosql.TextSearch" directive.
type TypeInfo ¶
type TypeInfo struct { // The name of a named type or empty string for unnamed types Name string // The kind of the go type. Kind TypeKind // The package import path. PkgPath string // The package's name. PkgName string // The local package name (including "."). PkgLocal string // Indicates whether or not the package is imported. IsImported bool // Indicates whether or not the type implements the sql.Scanner interface. IsScanner bool // Indicates whether or not the type implements the driver.Valuer interface. IsValuer bool // Indicates whether or not the type implements the json.Marshaler interface. IsJSONMarshaler bool // Indicates whether or not the type implements the json.Unmarshaler interface. IsJSONUnmarshaler bool // Indicates whether or not the type implements the xml.Marshaler interface. IsXMLMarshaler bool // Indicates whether or not the type implements the xml.Unmarshaler interface. IsXMLUnmarshaler bool // Indicates whether or not the type is an empty interface type. IsEmptyInterface bool // Indicates whether or not the type is the "byte" alias type. IsByte bool // Indicates whether or not the type is the "rune" alias type. IsRune bool // If kind is array, ArrayLen will hold the array's length. ArrayLen int64 // If kind is map, key will hold the info on the map's key type. Key *TypeInfo // If kind is map, elem will hold the info on the map's value type. // If kind is ptr, elem will hold the info on pointed-to type. // If kind is slice/array, elem will hold the info on slice/array element type. Elem *TypeInfo }
TypeInfo holds detailed information about a Go type.
func (*TypeInfo) GenericLiteral ¶
func (t *TypeInfo) GenericLiteral() LiteralType
func (*TypeInfo) ImplementsJSONMarshaler ¶
Indicates whether or not the MarshalJSON method can be called on the type.
func (*TypeInfo) ImplementsJSONUnmarshaler ¶
Indicates whether or not the UnmarshalJSON method can be called on the type.
func (TypeInfo) ImplementsScanner ¶ added in v0.0.3
func (TypeInfo) ImplementsValuer ¶ added in v0.0.3
func (*TypeInfo) ImplementsXMLMarshaler ¶
Indicates whether or not the MarshalXML method can be called on the type.
func (*TypeInfo) ImplementsXMLUnmarshaler ¶
Indicates whether or not the UnmarshalXML method can be called on the type.
func (*TypeInfo) Is ¶
Is reports whether or not t represents a type whose kind matches one of the provided TypeKinds or a pointer to one of the provided TypeKinds.
func (*TypeInfo) IsJSONIllegal ¶
Indicates whether or not an instance of the type's Kind is illegal to be used with encoding/json.
func (*TypeInfo) IsSequence ¶
IsSequence helper reports whether or not the type is of the slice or array kind.
func (*TypeInfo) IsSliceKind ¶
IsSliceKind reports whether or not t represents a slice type whose elem type is one of the provided TypeKinds.
func (*TypeInfo) IsXMLIllegal ¶
Indicates whether or not an instance of the type's Kind is illegal to be used with encoding/xml.
func (*TypeInfo) Literal ¶
func (t *TypeInfo) Literal() LiteralType
type TypeKind ¶
type TypeKind uint
TypeKind indicates the specific kind of a Go type.
const ( // basic TypeKindInvalid TypeKind = iota TypeKindBool TypeKindInt TypeKindInt8 TypeKindInt16 TypeKindInt32 TypeKindInt64 TypeKindUint TypeKindUint8 TypeKindUint16 TypeKindUint32 TypeKindUint64 TypeKindUintptr TypeKindFloat32 TypeKindFloat64 TypeKindComplex64 TypeKindComplex128 TypeKindString TypeKindUnsafePointer // non-basic TypeKindArray TypeKindInterface TypeKindMap TypeKindPtr TypeKindSlice TypeKindStruct TypeKindChan TypeKindFunc // alisases (basic) TypeKindByte = TypeKindUint8 TypeKindRune = TypeKindInt32 )
func (TypeKind) BasicString ¶
BasicString returns a string representation of k.
type UpdateDirective ¶
type UpdateDirective struct { // The list of column identifiers as parsed from the `sql` tag of the directive. ColIdentList }
UpdateDirective is the result of analyzing the "_ gosql.Update" directive.
type WhereBetweenStruct ¶
type WhereBetweenStruct struct { // The name of the field with the "between" tag. FieldName string // The column identifier as extracted from the "between" field. The ColIdent // identifies the column to be used as the primary predicand of the BETWEEN predicate. ColIdent ColIdent // The type of the "between" predicate extracted from the field's tag. Predicate Predicate // The lower-bound range predicand of the "between" predicate as extracted // from the BetweenStruct's sub-field tagged with "lower", or "x". LowerBound RangeBound // The upper-bound range predicand of the "between" predicate as extracted // from the BetweenStruct's sub-field tagged with "upper", or "y". UpperBound RangeBound }
WhereBetweenStruct is the result of analyzing a field whose `sql` tag contains one of the "between" predicates.
type WhereBoolTag ¶
type WhereBoolTag struct { // The boolean value. Value Boolean }
WhereBoolTag is the result of analyzing a `bool` tag inside a WhereStruct. The absence of a `bool` key in a WhereStruct's field tag produces an instance of WhereBoolTag with the default value.
type WhereColumnDirective ¶
type WhereColumnDirective struct { // The LHS column identifier parsed from the `sql` tag. LHSColIdent ColIdent // The RHS column identifier parsed from the `sql` tag, or empty. RHSColIdent ColIdent // The RHS literal value parsed from the `sql` tag, or empty. RHSLiteral string // The predicate type parsed from the `sql` tag, or 0. Predicate Predicate // The quantifier parsed from the `sql` tag, or 0. Quantifier Quantifier }
WhereColumnDirective is the result of analyzing a WhereStruct gosql.Column directive and its associated `sql` tag. The content of the `sql` tag is expected to be a predicate expression.
type WhereItem ¶
type WhereItem interface {
// contains filtered or unexported methods
}
The WhereItem interface is implemented by the WhereStruct, WhereBoolTag, WhereStructField, WhereColumnDirective, and WhereBetweenStruct types.
type WhereStruct ¶
type WhereStruct struct { // Name of the field (case preserved). FieldName string // List of different items specified by the WhereStruct. Items []WhereItem }
WhereStruct represents a struct analyzed from a QueryStruct's field named "where" (case insensitive).
type WhereStructField ¶
type WhereStructField struct { // The name of the field. Name string // The field's type information. Type TypeInfo // The column identifier parsed from the `sql` tag. ColIdent ColIdent // The predicate type parsed from the `sql` tag, or 0. Predicate Predicate // The quantifier parsed from the `sql` tag, or 0. Quantifier Quantifier // The name of the function parsed from the `sql` tag, or empty. FuncName FuncName }
WhereStructField is the result of analyzing a plain WhereStruct field and its associated `sql` tag.