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 1919from typing import List , Optional , Tuple
2020
2121from robot .api import logger
22+ from robot .utils .dotdict import DotDict
2223
2324from .connection_manager import Connection
2425from .params_decorator import renamed_args
@@ -91,7 +92,7 @@ def query(
9192 col_names = [c [0 ] for c in cur .description ]
9293 self ._log_query_results (col_names , all_rows )
9394 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 ]
9596 return all_rows
9697 except Exception as e :
9798 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
113113 Should Be Equal As Strings ${value 1 } Franz Allan
114114 Should Be Equal As Strings ${value 2 } Jerry
115115
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+
116129Verify Execute SQL String - Row Count person table
117130 ${output } = Execute SQL String SELECT COUNT(*) FROM person
118131 Log ${output }
You can’t perform that action at this time.
0 commit comments