ignore error parsing a prepared statement - just treat query as raw sql

This commit is contained in:
kai
2021-09-01 11:11:29 +01:00
parent b0060b910d
commit cbffa40642
3 changed files with 8 additions and 23 deletions

View File

@@ -206,10 +206,7 @@ func (e *ExecutionTree) getExecutionRootFromArg(arg string) ([]modconfig.ModTree
func (e *ExecutionTree) getControlMapFromWhereClause(ctx context.Context, whereClause string) (map[string]bool, error) {
// query may either be a 'where' clause, or a named query
// in case of a named query call with params, parse the where clause
queryName, paramsString, err := parse.ParsePreparedStatementInvocation(whereClause)
if err != nil {
return nil, err
}
queryName, paramsString := parse.ParsePreparedStatementInvocation(whereClause)
query, err := e.workspace.GetQueryFromArg(queryName, paramsString)
if err != nil {
return nil, err

View File

@@ -9,7 +9,7 @@ import (
type parsePreparedStatementInvocationTest struct {
input string
expected interface{}
expected parsePreparedStatementInvocationResult
}
type parsePreparedStatementInvocationResult struct {
@@ -116,23 +116,14 @@ var testCasesParsePreparedStatementInvocation = map[string]parsePreparedStatemen
func TestParsePreparedStatementInvocation(t *testing.T) {
for name, test := range testCasesParsePreparedStatementInvocation {
queryName, params, err := ParsePreparedStatementInvocation(test.input)
if err != nil {
if test.expected != "ERROR" {
t.Errorf("Test: '%s'' FAILED : \nunexpected error %v", name, err)
}
return
}
if test.expected == "ERROR" {
t.Errorf("Test: '%s'' FAILED - expected error", name)
}
expected := test.expected.(parsePreparedStatementInvocationResult)
if queryName != expected.queryName || !expected.params.Equals(params) {
queryName, params := ParsePreparedStatementInvocation(test.input)
if queryName != test.expected.queryName || !test.expected.params.Equals(params) {
fmt.Printf("")
t.Errorf("Test: '%s'' FAILED : expected:\nquery: %s params: %s\n\ngot:\nquery: %s params: %s",
name,
expected.queryName,
expected.params,
test.expected.queryName,
test.expected.params,
queryName, params)
}
}

View File

@@ -483,10 +483,7 @@ func (w *Workspace) GetQueriesFromArgs(args []string) ([]string, error) {
var queries []string
for _, arg := range args {
// in case of a named query call with params, parse the where clause
queryName, params, err := parse.ParsePreparedStatementInvocation(arg)
if err != nil {
return nil, err
}
queryName, params := parse.ParsePreparedStatementInvocation(arg)
query, err := w.GetQueryFromArg(queryName, params)
if err != nil {
return nil, err