Documentation
¶
Index ¶
- Constants
- type AndExpression
- type Comparison
- type ConditionResult
- type EntityMappingFunctions
- type EntityPropertyMap
- type EntityType
- type EqualityExpander
- type Expression
- type FilterExpression
- type OrExpression
- type PropertyDefinition
- type PropertyLocation
- type PropertyRef
- type PropertyReference
- type QueryBuilder
- func (qb *QueryBuilder) BuildConditionString(expr *FilterExpression) ConditionResult
- func (qb *QueryBuilder) BuildPropertyReference(expr *FilterExpression) *PropertyReference
- func (qb *QueryBuilder) BuildQuery(db *gorm.DB, expr *FilterExpression) *gorm.DB
- func (qb *QueryBuilder) ConvertStateValue(propertyName string, value any) any
- func (qb *QueryBuilder) EntityType() EntityType
- func (qb *QueryBuilder) RestEntityType() RestEntityType
- func (qb *QueryBuilder) TablePrefix() string
- type RelatedEntityType
- type RestEntityType
- type SingleValue
- type Term
- type Value
- type ValueList
- type WhereClause
Constants ¶
const ( StringValueType = "string_value" DoubleValueType = "double_value" IntValueType = "int_value" BoolValueType = "bool_value" ArrayValueType = "array_value" )
Constants for property value types
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AndExpression ¶
type Comparison ¶
type Comparison struct {
Left *PropertyRef `@@`
Operator string `@("=" | "!=" | "<>" | ">=" | "<=" | ">" | "<" | "LIKE" | "ILIKE" | "IN")`
Right *Value `@@`
}
type ConditionResult ¶
type EntityMappingFunctions ¶
type EntityMappingFunctions interface {
GetMLMDEntityType(restEntityType RestEntityType) EntityType
GetPropertyDefinitionForRestEntity(restEntityType RestEntityType, propertyName string) PropertyDefinition
IsChildEntity(entityType RestEntityType) bool
}
EntityMappingFunctions defines the interface for entity type mapping functions. This allows different packages (like catalog) to provide their own entity mappings.
type EntityPropertyMap ¶
type EntityPropertyMap map[string]PropertyDefinition
EntityPropertyMap maps property names to their definitions for each entity type
type EntityType ¶
type EntityType string
EntityType represents the type of entity for proper query building
const ( EntityTypeContext EntityType = "context" EntityTypeArtifact EntityType = "artifact" EntityTypeExecution EntityType = "execution" )
type EqualityExpander ¶
type EqualityExpander interface {
GetEqualityExpansion(restEntityType RestEntityType, propertyName string, value any) (likeArg any, useExpansion bool)
}
EqualityExpander is an optional interface that EntityMappingFunctions may implement to expand equality conditions.
type Expression ¶
type Expression struct {
Or *OrExpression `@@`
}
type FilterExpression ¶
type FilterExpression struct {
Left *FilterExpression
Right *FilterExpression
Operator string
Property string
Value any
IsLeaf bool
}
func Parse ¶
func Parse(input string) (*FilterExpression, error)
type OrExpression ¶
type OrExpression struct {
Left *AndExpression `@@`
Right []*AndExpression `("OR" @@)*`
}
type PropertyDefinition ¶
type PropertyDefinition struct {
Location PropertyLocation
ValueType string
Column string
RelatedEntityType RelatedEntityType
RelatedProperty string
JoinTable string
}
PropertyDefinition defines how a property should be handled
func GetPropertyDefinition ¶
func GetPropertyDefinition(entityType EntityType, propertyName string) PropertyDefinition
GetPropertyDefinition returns the property definition for a given entity type and property name
type PropertyLocation ¶
type PropertyLocation int
PropertyLocation indicates where a property is stored
const ( EntityTable PropertyLocation = iota // Property is a column in the main entity table PropertyTable // Property is stored in the entity's property table Custom // Property is a custom property in the property table RelatedEntity // Property is in a related entity (requires JOIN) )
type PropertyRef ¶
type PropertyReference ¶
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
QueryBuilder builds GORM queries from filter expressions
func NewQueryBuilderForRestEntity ¶
func NewQueryBuilderForRestEntity(restEntityType RestEntityType, mappingFuncs EntityMappingFunctions) *QueryBuilder
NewQueryBuilderForRestEntity creates a new query builder for the specified REST entity type. mappingFuncs must not be nil - callers must provide their own EntityMappingFunctions.
func (*QueryBuilder) BuildConditionString ¶
func (qb *QueryBuilder) BuildConditionString(expr *FilterExpression) ConditionResult
BuildConditionString builds a SQL condition string from a FilterExpression.
func (*QueryBuilder) BuildPropertyReference ¶
func (qb *QueryBuilder) BuildPropertyReference(expr *FilterExpression) *PropertyReference
BuildPropertyReference is exported for test use.
func (*QueryBuilder) BuildQuery ¶
func (qb *QueryBuilder) BuildQuery(db *gorm.DB, expr *FilterExpression) *gorm.DB
func (*QueryBuilder) ConvertStateValue ¶
func (qb *QueryBuilder) ConvertStateValue(propertyName string, value any) any
ConvertStateValue converts string state values to integers based on entity type
func (*QueryBuilder) EntityType ¶
func (qb *QueryBuilder) EntityType() EntityType
EntityType returns the entity type for the query builder (exported for test use).
func (*QueryBuilder) RestEntityType ¶
func (qb *QueryBuilder) RestEntityType() RestEntityType
RestEntityType returns the REST entity type for the query builder (exported for test use).
func (*QueryBuilder) TablePrefix ¶
func (qb *QueryBuilder) TablePrefix() string
TablePrefix returns the table prefix for the query builder (exported for test use).
type RelatedEntityType ¶
type RelatedEntityType string
RelatedEntityType indicates the type of related entity
const ( RelatedEntityArtifact RelatedEntityType = "artifact" RelatedEntityContext RelatedEntityType = "context" RelatedEntityExecution RelatedEntityType = "execution" )
type RestEntityType ¶
type RestEntityType string
RestEntityType represents the specific REST API entity type
type SingleValue ¶
type Term ¶
type Term struct {
Group *Expression `"(" @@ ")"`
Comparison *Comparison `| @@`
}
type ValueList ¶
type ValueList struct {
Values []*SingleValue `"(" (@@ ("," @@)*)? ")"`
}
type WhereClause ¶
type WhereClause struct {
Expression *Expression `@@`
}