MCPcopy Create free account
hub / github.com/PostHog/duckgres / createRegexFuncCall

Method createRegexFuncCall

transpiler/transform/operators.go:954–996  ·  view source on GitHub ↗

createRegexFuncCall creates a regexp_matches function call node For negated operators, wraps in NOT

(left, right *pg_query.Node, caseInsensitive, negated bool)

Source from the content-addressed store, hash-verified

952// createRegexFuncCall creates a regexp_matches function call node
953// For negated operators, wraps in NOT
954func (t *OperatorTransform) createRegexFuncCall(left, right *pg_query.Node, caseInsensitive, negated bool) *pg_query.Node {
955 // Build function arguments
956 args := []*pg_query.Node{left, right}
957
958 // Add 'i' flag for case-insensitive matching
959 if caseInsensitive {
960 args = append(args, &pg_query.Node{
961 Node: &pg_query.Node_AConst{
962 AConst: &pg_query.A_Const{
963 Val: &pg_query.A_Const_Sval{
964 Sval: &pg_query.String{Sval: "i"},
965 },
966 },
967 },
968 })
969 }
970
971 // Create the function call node
972 funcCallNode := &pg_query.Node{
973 Node: &pg_query.Node_FuncCall{
974 FuncCall: &pg_query.FuncCall{
975 Funcname: []*pg_query.Node{
976 {Node: &pg_query.Node_String_{String_: &pg_query.String{Sval: "regexp_matches"}}},
977 },
978 Args: args,
979 },
980 },
981 }
982
983 // Wrap in NOT for negated operators (!~ and !~*)
984 if negated {
985 return &pg_query.Node{
986 Node: &pg_query.Node_BoolExpr{
987 BoolExpr: &pg_query.BoolExpr{
988 Boolop: pg_query.BoolExprType_NOT_EXPR,
989 Args: []*pg_query.Node{funcCallNode},
990 },
991 },
992 }
993 }
994
995 return funcCallNode
996}
997
998// OperatorMappingNote documents the operator mappings for reference:
999//

Callers 1

transformExpressionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected