diff --git a/control/controlexecute/execution_tree.go b/control/controlexecute/execution_tree.go index e5dd36555..2154ddfe8 100644 --- a/control/controlexecute/execution_tree.go +++ b/control/controlexecute/execution_tree.go @@ -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 diff --git a/steampipeconfig/parse/prepared_statement_test.go b/steampipeconfig/parse/prepared_statement_test.go index 7bc231fae..41f5d39a6 100644 --- a/steampipeconfig/parse/prepared_statement_test.go +++ b/steampipeconfig/parse/prepared_statement_test.go @@ -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) } } diff --git a/workspace/workspace.go b/workspace/workspace.go index c4294b967..5da0bbe0d 100644 --- a/workspace/workspace.go +++ b/workspace/workspace.go @@ -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