mirror of
https://github.com/turbot/steampipe.git
synced 2026-04-14 07:00:08 -04:00
ignore error parsing a prepared statement - just treat query as raw sql
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user