File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 19
19
from typing import List , Optional , Tuple
20
20
21
21
from robot .api import logger
22
+ from robot .utils .dotdict import DotDict
22
23
23
24
from .connection_manager import Connection
24
25
from .params_decorator import renamed_args
@@ -91,7 +92,7 @@ def query(
91
92
col_names = [c [0 ] for c in cur .description ]
92
93
self ._log_query_results (col_names , all_rows )
93
94
if return_dict :
94
- return [dict (zip (col_names , row )) for row in all_rows ]
95
+ return [DotDict (zip (col_names , row )) for row in all_rows ]
95
96
return all_rows
96
97
except Exception as e :
97
98
self ._rollback_and_raise (db_connection , no_transaction , e )
Original file line number Diff line number Diff line change @@ -113,6 +113,19 @@ Verify Query - Get results as a list of dictionaries
113
113
Should Be Equal As Strings ${value 1 } Franz Allan
114
114
Should Be Equal As Strings ${value 2 } Jerry
115
115
116
+ Return As Dictionary - Dotted Syntax
117
+ ${output } = Query SELECT * FROM person return_dict=True
118
+ ${field_names } = Get Dictionary Keys ${output } [0 ]
119
+ IF "FIRST_NAME" in $field_names
120
+ VAR ${field_name } = FIRST_NAME
121
+ ELSE IF "first_name" in $field_names
122
+ VAR ${field_name } = first_name
123
+ ELSE
124
+ FAIL Unexpected field name in dictionary
125
+ END
126
+ Should Be Equal As Strings ${output[0].${field_name } } Franz Allan
127
+ Should Be Equal As Strings ${output[1].${field_name } } Jerry
128
+
116
129
Verify Execute SQL String - Row Count person table
117
130
${output } = Execute SQL String SELECT COUNT(*) FROM person
118
131
Log ${output }
You can’t perform that action at this time.
0 commit comments