@@ -279,34 +279,7 @@ func (s *SQL) readExec(ctx context.Context, col, sqlString string, args []interf
279
279
280
280
return 0 , nil , nil , nil , errors .New ("unknown error occurred" )
281
281
282
- case utils .One :
283
- mapping := make (map [string ]interface {})
284
- if ! rows .Next () {
285
- return 0 , nil , nil , nil , errors .New ("SQL: No response from db" )
286
- }
287
-
288
- err := rows .MapScan (mapping )
289
- if err != nil {
290
- return 0 , nil , nil , nil , err
291
- }
292
-
293
- switch s .GetDBType () {
294
- case model .MySQL , model .Postgres , model .SQLServer :
295
- mysqlTypeCheck (ctx , s .GetDBType (), rowTypes , mapping )
296
- }
297
-
298
- processAggregate (mapping , mapping , col , isAggregate )
299
- if req .PostProcess != nil {
300
- _ = authHelpers .PostProcessMethod (ctx , s .aesKey , req .PostProcess [col ], mapping )
301
- }
302
-
303
- if req .Options .Debug {
304
- mapping ["_dbFetchTs" ] = time .Now ().Format (time .RFC3339Nano )
305
- }
306
-
307
- return 1 , mapping , make (map [string ]map [string ]string ), metaData , nil
308
-
309
- case utils .All , utils .Distinct :
282
+ case utils .All , utils .Distinct , utils .One :
310
283
array := make ([]interface {}, 0 )
311
284
mapping := make (map [string ]map [string ]interface {})
312
285
jointMapping := make (map [string ]map [string ]string )
@@ -341,6 +314,13 @@ func (s *SQL) readExec(ctx context.Context, col, sqlString string, args []interf
341
314
s .processRows (ctx , req .Options .Debug , []string {col }, isAggregate , row , req .Options .Join , mapping , & array , req .PostProcess , jointMapping )
342
315
}
343
316
317
+ if operation == utils .One {
318
+ if count == 0 {
319
+ return 0 , nil , nil , nil , errors .New ("SQL: No response from db" )
320
+ }
321
+ return 1 , array [0 ], jointMapping , metaData , nil
322
+ }
323
+
344
324
return count , array , jointMapping , metaData , nil
345
325
346
326
default :
0 commit comments