sqltypes
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package sqltypes contains the types used to convert rego queries into SQL.The rego ast is converted into these types to better control the SQLgeneration. It allows writing the SQL generation for types in an easier toread way.
Index¶
- func IsPrimitive(n Node) bool
- func RegoVarPath(path []string, terms []*ast.Term) ([]*ast.Term, error)
- type ASTArray
- type AstBoolean
- type AstNumber
- type AstString
- type BooleanNode
- func And(source RegoSource, terms ...BooleanNode) BooleanNode
- func Bool(t bool) BooleanNode
- func BoolParenthesis(value BooleanNode) BooleanNode
- func Equality(notEquals bool, a, b Node) BooleanNode
- func MemberOf(needle, haystack Node) BooleanNode
- func Or(source RegoSource, terms ...BooleanNode) BooleanNode
- type Node
- type RegoSource
- type SQLGenerator
- type SupportsContainedIn
- type SupportsContains
- type SupportsEquality
- type VariableConverter
- type VariableMatcher
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcIsPrimitive¶
Types¶
typeASTArray¶
type ASTArray struct {SourceRegoSourceValue []Node}
func (ASTArray)ContainsSQL¶
func (aASTArray) ContainsSQL(cfg *SQLGenerator, needleNode) (string,error)
func (ASTArray)SQLString¶
func (aASTArray) SQLString(cfg *SQLGenerator)string
typeAstBoolean¶
type AstBoolean struct {SourceRegoSourceValuebool}
AstBoolean is a literal true/false value.
func (AstBoolean)EqualsSQLString¶
func (bAstBoolean) EqualsSQLString(cfg *SQLGenerator, notbool, otherNode) (string,error)
func (AstBoolean)IsBooleanNode¶
func (AstBoolean) IsBooleanNode()
func (AstBoolean)SQLString¶
func (bAstBoolean) SQLString(_ *SQLGenerator)string
func (AstBoolean)UseAs¶
func (AstBoolean) UseAs()Node
typeAstNumber¶
type AstNumber struct {SourceRegoSource// Value is intentionally vague as to if it's an integer or a float.// This defers that decision to the user. Rego keeps all numbers in this// type. If we were to source the type from something other than Rego,// we might want to make a Float and Int type which keep the original// precision.Valuejson.Number}
func (AstNumber)EqualsSQLString¶
func (AstNumber)SQLString¶
func (nAstNumber) SQLString(_ *SQLGenerator)string
typeAstString¶
type AstString struct {SourceRegoSourceValuestring}
func (AstString)EqualsSQLString¶
func (AstString)SQLString¶
func (sAstString) SQLString(_ *SQLGenerator)string
typeBooleanNode¶
type BooleanNode interface {NodeIsBooleanNode()}
BooleanNode is a node that returns a true/false when evaluated.
funcAnd¶
func And(sourceRegoSource, terms ...BooleanNode)BooleanNode
funcBool¶
func Bool(tbool)BooleanNode
funcBoolParenthesis¶
func BoolParenthesis(valueBooleanNode)BooleanNode
BoolParenthesis wraps the given boolean node in parens.This is useful for grouping and avoiding ambiguity. This does not work formathematical parenthesis to change order of operations.
funcEquality¶
func Equality(notEqualsbool, a, bNode)BooleanNode
funcMemberOf¶
func MemberOf(needle, haystackNode)BooleanNode
funcOr¶
func Or(sourceRegoSource, terms ...BooleanNode)BooleanNode
typeNode¶
type Node interface {SQLString(cfg *SQLGenerator)string// UseAs is a helper function to allow a node to be used as a different// Node in operators. For example, a variable is really just a "string", so// having the Equality operator check for "String" or "StringVar" is just// excessive. Instead, we can just have the variable implement this function.UseAs()Node}
funcAlwaysFalseNode¶
AlwaysFalseNode is mainly used for unit testing to make a Node immediately.
typeRegoSource¶
type RegoSourcestring
typeSQLGenerator¶
type SQLGenerator struct {// contains filtered or unexported fields}
funcNewSQLGenerator¶
func NewSQLGenerator() *SQLGenerator
func (*SQLGenerator)AddError¶
func (g *SQLGenerator) AddError(errerror)
func (*SQLGenerator)Errors¶
func (g *SQLGenerator) Errors() []error
typeSupportsContainedIn¶
type SupportsContainedIn interface {ContainedInSQL(cfg *SQLGenerator, otherNode) (string,error)}
SupportsContainedIn is the inverse of SupportsContains. It is implementedfrom the "needle" rather than the haystack.
typeSupportsContains¶
type SupportsContains interface {ContainsSQL(cfg *SQLGenerator, otherNode) (string,error)}
SupportsContains is an interface that can be implemented by types thatsupport "me.Contains(other)". This is `internal_member2` in the rego.
typeSupportsEquality¶
type SupportsEquality interface {// EqualsSQLString intentionally returns an error. This is so if// left = right is not supported, we can try right = left.EqualsSQLString(cfg *SQLGenerator, notbool, otherNode) (string,error)}
SupportsEquality is an interface that can be implemented by types thatsupport equality with other types. We defer to other types to implement thisas it is much easier to implement this in the context of the type.
typeVariableConverter¶
type VariableConverter struct {// contains filtered or unexported fields}
funcNewVariableConverter¶
func NewVariableConverter() *VariableConverter
func (*VariableConverter)ConvertVariable¶
func (vc *VariableConverter) ConvertVariable(regoast.Ref) (Node,bool)
func (*VariableConverter)RegisterMatcher¶
func (vc *VariableConverter) RegisterMatcher(m ...VariableMatcher) *VariableConverter
typeVariableMatcher¶
funcAlwaysFalse¶
func AlwaysFalse(mVariableMatcher)VariableMatcher
AlwaysFalse overrides the inner node with a constant "false".
funcStringVarMatcher¶
func StringVarMatcher(sqlStringstring, regoPath []string)VariableMatcher