Boolean values are trimmed to first character when returned from db query
When running SQL queries ( in POSTGRESQL), for the fields which ave Boolean values (true or false), the db query only return the first character not the whole field.
This cause our compare steps to fail:
See below screenshots:
Hi Rex,
I’m saving the query results into as SET_LIST (it’s a select *… ) query and compare the desired field with the expected value (from the data-set). I also tried to get only those Boolean field values through “GET_DB_VALUE” (select a, b, c from table....) and it returned me the values as only first character.The other data fields works fine.
For now, I put a work-around by trimming my expected to the first character so it can match the value returned from query.
Here is a sample compare step, the left value is the data_set value (expected value) which is (TRUE” or “FALSE”), the right value is the data returned from query (which returns as t or f):
Hasib,
we represent all query result values as strings for future usage in all other commands. It's default JDBC logic to convert boolean into string saving first letter only.
Could you please use one of solutions below to avoid your problem:
- Replace "true" to "t" and "false" to "f" in your compare command
- Use type cast from boolean to string in your SQL query.
For example, you have boolean active_flag in table accounts.
Instead of
Select active_flag from accounts
use query
Select active_flag::TEXT from accounts.
Please sign in to leave a comment.