Answered

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:

0
5 comments
Avatar
Joseph Hamdan

Hasib,

Thank you for taking the time to write to us. We are looking into your post and will provide a response as soon as possible.

Regards,

Subject7 Team

0
Comment actions Permalink
Avatar
Rex Feizi

Hasib, 

 

Would you please provide the complete compare commands as well as the queries. 

 

In short, there should be a way to change the output of the Postgres query. 

0
Comment actions Permalink
Avatar
Hasib Rostaiee

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):

0
Comment actions Permalink
Avatar
Jonathan Hotz

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:

  1. Replace "true" to "t" and "false" to "f" in your compare command
  2. 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.
0
Comment actions Permalink
Avatar
Hasib Rostaiee

Thank you, I placed #1 workaround by trimming the "TRUE" and "FASLE" values.

I can't use #2, as the query is a select * ...

1
Comment actions Permalink

Please sign in to leave a comment.