Skip to content

Commit 1cb38a5

Browse files
committed
fix #244 - error when querying BLOB data
1 parent 9aa14a4 commit 1cb38a5

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/DatabaseLibrary/query.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,11 @@ def _log_query_results(self, col_names, result_rows, log_head: Optional[int] = N
827827
msg += f"<tr{row_style}>"
828828
msg += f'<th scope="row" style="color:{row_index_text_color}; background-color: {row_index_background_color};{cell_border_and_align}">{i}</th>'
829829
for cell in row:
830-
msg += f'<td style="{cell_border_and_align}">{cell}</td>'
830+
try:
831+
cell_string = str(cell)
832+
except TypeError as e:
833+
cell_string = f"Unable printing the value: {e}"
834+
msg += f'<td style="{cell_border_and_align}">{cell_string}</td>'
831835
msg += "</tr>"
832836
msg += "</table>"
833837
if table_truncated:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
*** Settings ***
2+
Documentation Tests for querying a table with BLOB data type.
3+
... The data type naming is DB specific, these tests are designed for Oracle DB only.
4+
5+
Resource ../../resources/common.resource
6+
7+
Suite Setup Connect To DB
8+
Suite Teardown Disconnect From Database
9+
Test Setup Execute Sql String
10+
... CREATE TABLE blob_table (id integer not null unique, data blob)
11+
Test Teardown Execute Sql String DROP TABLE blob_table
12+
13+
14+
*** Variables ***
15+
${DB_MODULE} oracledb
16+
${DB_HOST} 127.0.0.1
17+
${DB_PORT} 1521
18+
${DB_PASS} pass
19+
${DB_USER} db_user
20+
${DB_NAME} db
21+
${ORACLE_LIB_DIR} ${EMPTY}
22+
23+
24+
*** Test Cases ***
25+
Blob Data Type - Logging Results Causes No Error
26+
[Documentation] See https://github.com/MarketSquare/Robotframework-Database-Library/issues/244
27+
${binary_data}= Evaluate b'abc'
28+
Execute Sql String INSERT INTO blob_table VALUES(1, '${binary_data}')
29+
${result}= Query SELECT data FROM blob_table WHERE id=1

0 commit comments

Comments
 (0)