@@ -70,12 +70,17 @@ func callCmd() *cobra.Command {
70
70
return display .PrintErr (cmd , fmt .Errorf ("error getting selected action or procedure: %w" , err ))
71
71
}
72
72
73
+ allScalar , err := getAllScalarsFlag (cmd )
74
+ if err != nil {
75
+ return display .PrintErr (cmd , fmt .Errorf ("error getting all scalar flag: %w" , err ))
76
+ }
77
+
73
78
inputs , err := parseInputs (args )
74
79
if err != nil {
75
80
return display .PrintErr (cmd , fmt .Errorf ("error getting inputs: %w" , err ))
76
81
}
77
82
78
- tuples , err := buildExecutionInputs (ctx , clnt , dbid , action , inputs )
83
+ tuples , err := buildExecutionInputs (ctx , clnt , dbid , action , inputs , allScalar )
79
84
if err != nil {
80
85
return display .PrintErr (cmd , fmt .Errorf ("error creating action/procedure inputs: %w" , err ))
81
86
}
@@ -144,15 +149,17 @@ func (r *respCall) MarshalText() (text []byte, err error) {
144
149
145
150
// buildProcedureInputs will build the inputs for either
146
151
// an action or procedure executon/call.
147
- func buildExecutionInputs (ctx context.Context , client clientType.Client , dbid string , proc string , inputs []map [string ]string ) ([][]any , error ) {
152
+ // If skipArr is true, it will treat all values as a scalar value if it can't detect
153
+ // what the expected type is (which is the case for an action).
154
+ func buildExecutionInputs (ctx context.Context , client clientType.Client , dbid string , proc string , inputs []map [string ]string , skipArr bool ) ([][]any , error ) {
148
155
schema , err := client .GetSchema (ctx , dbid )
149
156
if err != nil {
150
157
return nil , fmt .Errorf ("error getting schema: %w" , err )
151
158
}
152
159
153
160
for _ , a := range schema .Actions {
154
161
if strings .EqualFold (a .Name , proc ) {
155
- return buildActionInputs (a , inputs )
162
+ return buildActionInputs (a , inputs , skipArr )
156
163
}
157
164
}
158
165
@@ -189,7 +196,10 @@ func decodeMany(inputs []string) ([][]byte, bool) {
189
196
return b64Arr , b64Ok
190
197
}
191
198
192
- func buildActionInputs (a * types.Action , inputs []map [string ]string ) ([][]any , error ) {
199
+ // buildActionInputs will build the inputs for an action execution/call.
200
+ // if skipArr is true, it will treat all values as a scalar value.
201
+ // This is useful within CSV, where we do not expected arrays
202
+ func buildActionInputs (a * types.Action , inputs []map [string ]string , skipArr bool ) ([][]any , error ) {
193
203
tuples := [][]any {}
194
204
for _ , input := range inputs {
195
205
newTuple := []any {}
@@ -199,15 +209,20 @@ func buildActionInputs(a *types.Action, inputs []map[string]string) ([][]any, er
199
209
200
210
val , ok := input [inputField ]
201
211
if ! ok {
202
- fmt .Println (len (newTuple ))
203
212
// if not found, we should just add nil
204
213
newTuple = append (newTuple , nil )
205
214
continue
206
215
}
207
216
208
- split , err := splitIgnoringQuotedCommas (val )
209
- if err != nil {
210
- return nil , err
217
+ var split []string
218
+ if ! skipArr {
219
+ var err error
220
+ split , err = splitIgnoringQuotedCommas (val )
221
+ if err != nil {
222
+ return nil , err
223
+ }
224
+ } else {
225
+ split = []string {val }
211
226
}
212
227
213
228
// attempt to decode base64 encoded values
0 commit comments