reverse

package
v0.0.0-...-b9b2519 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotSupported = errors.New("feature not supported in OQL")
	ErrParseError   = errors.New("failed to parse query")
	ErrEmptyQuery   = errors.New("empty query")
)
View Source
var (
	SQLToOQLOperation map[string]map[string]string // dbType → sql_op → oql_op
	SQLToOQLOperator  map[string]map[string]string // dbType → sql_op → oql_op
	SQLToOQLType      map[string]map[string]string // dbType → sql_type → oql_type
)

Functions

func BinaryExpr

func BinaryExpr(left *models.Expression, op string, right *models.Expression) *models.Expression

func CaseExpr

func CaseExpr(conditions []*models.CaseCondition, elseExpr *models.Expression) *models.Expression

func ConvertCaseExpression

func ConvertCaseExpression(expr map[string]interface{}) *models.Expression

ConvertCaseExpression handles $cond and $switch

func ConvertExtendedRedisCommand

func ConvertExtendedRedisCommand(parts []string) (*models.Query, error)

ConvertExtendedRedisCommand handles additional Redis commands Called from main router when basic commands don't match

func ConvertRedisExists

func ConvertRedisExists(parts []string) (*models.Query, error)

ConvertRedisExists converts EXISTS to COUNT with condition

func ConvertRedisHDel

func ConvertRedisHDel(parts []string) (*models.Query, error)

ConvertRedisHDel converts HDEL to UPDATE with NULL

func ConvertRedisHGet

func ConvertRedisHGet(parts []string) (*models.Query, error)

ConvertRedisHGet converts HGET to GET specific field

func ConvertRedisKeys

func ConvertRedisKeys(parts []string) (*models.Query, error)

ConvertRedisKeys converts KEYS pattern to GET with LIKE

func ConvertRedisLPush

func ConvertRedisLPush(parts []string) (*models.Query, error)

ConvertRedisLPush converts LPUSH to array append operation

func ConvertRedisLRange

func ConvertRedisLRange(parts []string) (*models.Query, error)

ConvertRedisLRange converts LRANGE to GET with array slice

func ConvertRedisSAdd

func ConvertRedisSAdd(parts []string) (*models.Query, error)

ConvertRedisSAdd converts SADD to set add operation

func ConvertRedisSMembers

func ConvertRedisSMembers(parts []string) (*models.Query, error)

ConvertRedisSMembers converts SMEMBERS to GET set members

func ConvertRedisToReplace

func ConvertRedisToReplace(parts []string) (*models.Query, error)

ConvertRedisToReplace converts HMSET to REPLACE REPLACE = DELETE + INSERT (full document replacement)

func ConvertRedisToUpsert

func ConvertRedisToUpsert(parts []string) (*models.Query, error)

ConvertRedisToUpsert converts HMSET to UPSERT when detected Redis doesn't distinguish CREATE vs UPSERT - HMSET always upserts We detect UPSERT context from key pattern or explicit marker

func ConvertRedisZAdd

func ConvertRedisZAdd(parts []string) (*models.Query, error)

ConvertRedisZAdd converts ZADD to sorted set add

func ConvertRedisZRange

func ConvertRedisZRange(parts []string) (*models.Query, error)

ConvertRedisZRange converts ZRANGE to GET with ORDER BY

func ConvertSetExpression

func ConvertSetExpression(expr map[string]interface{}) (*models.SetOperation, string)

ConvertSetExpression handles $setIntersection, $setDifference in $project Mapping: INTERSECT, EXCEPT

func EntityToTable

func EntityToTable(entity string) string

EntityToTable: User → users, OrderItem → order_items

func ExtractTenantFromACL

func ExtractTenantFromACL(args []string) string

ExtractTenantFromACL extracts tenant pattern from ACL args Looks for ~tenant:XXX:* pattern

func ExtractTenantFromKey

func ExtractTenantFromKey(key string) string

ExtractTenantFromKey extracts tenant ID from Redis key

func FieldExpr

func FieldExpr(name string) *models.Expression

func FunctionExpr

func FunctionExpr(name string, args ...*models.Expression) *models.Expression

func GetOQLOperation

func GetOQLOperation(sqlOp, dbType string) string

func GetOQLOperator

func GetOQLOperator(sqlOp, dbType string) string

func GetOQLType

func GetOQLType(sqlType, dbType string) string

func LiteralExpr

func LiteralExpr(value string) *models.Expression

func MongoDBToQuery

func MongoDBToQuery(jsonStr string) (*models.Query, error)

func MySQLToQuery

func MySQLToQuery(sql string) (*models.Query, error)

func NewCondition

func NewCondition(field *models.Expression, op string, value *models.Expression) models.Condition

func NewConditionWithLogic

func NewConditionWithLogic(field *models.Expression, op string, value *models.Expression, logic string) models.Condition

func ParseComplexRedisValue

func ParseComplexRedisValue(value string) *models.Expression

ParseComplexRedisValue parses complex values including expressions

func ParseJSONToFields

func ParseJSONToFields(jsonStr string) []models.Field

ParseJSONToFields converts JSON string to Fields with type inference

func PostgreSQLToQuery

func PostgreSQLToQuery(sql string) (*models.Query, error)

func ProcessAdvancedPipelineStages

func ProcessAdvancedPipelineStages(query *models.Query, pipeline []interface{}) bool

ProcessAdvancedPipelineStages handles advanced aggregation stages

func RedisToQuery

func RedisToQuery(commandStr string) (*models.Query, error)

RedisToQuery converts a Redis command string to an OQL Query

func TableToEntity

func TableToEntity(table string) string

TableToEntity: users → User, order_items → OrderItem

func ToQuery

func ToQuery(query string, dbType string) (*models.Query, error)

ToQuery converts native query to models.Query (100% TrueAST)

func WindowExpr

func WindowExpr(partitionBy []*models.Expression, orderBy []models.OrderBy, offset, buckets int) *models.Expression

Types

type RedisKeyInfo

type RedisKeyInfo struct {
	TenantID   string
	Entity     string
	ID         string
	Field      string // For field:value pattern
	FieldValue string
	IsPattern  bool // true if key ends with *
}

RedisKeyInfo contains parsed information from a Redis key

type RedisKeyPattern

type RedisKeyPattern struct {
	TenantID    string
	Entity      string
	ID          string
	Segments    []string // All key segments
	IsPattern   bool
	PatternType string // "exact", "prefix", "suffix", "contains"
}

RedisKeyPattern represents advanced key pattern info

func ParseRedisKeyPattern

func ParseRedisKeyPattern(key string) *RedisKeyPattern

ParseRedisKeyPattern parses key with advanced pattern detection

func (*RedisKeyPattern) ToConditions

func (p *RedisKeyPattern) ToConditions() []models.Condition

ToConditions converts key pattern to OQL conditions

Jump to

Keyboard shortcuts

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