3
0

Add INSTR ql ref for all drivers

This commit is contained in:
Vivek Patel
2022-12-19 17:57:13 +05:30
parent a2af386f6a
commit 5b653178b6
2 changed files with 17 additions and 0 deletions

View File

@@ -149,6 +149,12 @@ var (
},
OutType: &TypeText{},
},
"instr": {
Handler: func(args ...string) string {
return fmt.Sprintf("instr(%s, %s)", args[0], args[1])
},
OutType: &TypeNumber{},
},
// @todo implement; the commented versions are not good enough
// "like": {

View File

@@ -21,6 +21,17 @@ var (
return exp.NewSQLFunctionExpression("CONCAT", aa...)
},
},
"instr": {
Handler: func(args ...exp.Expression) exp.Expression {
// need to force text type on all arguments
aa := make([]any, len(args))
for a := range args {
aa[a] = exp.NewCastExpression(exp.NewLiteralExpression("?", args[a]), "TEXT")
}
return exp.NewSQLFunctionExpression("INSTR", args[0], args[1])
},
},
// filtering
"now": {