Server Action - Condition based on Database Query not works as expected

Wappler 5.2.1
Windows 11
NodeJS
Experimental Feature on and off

Hi,

I always use to check if a Database Query is “true” set in a Condition the same Query and if not “true” use ELSE.

Like this:

Database Query: validation_codes
Condition {{validation_codes}}
THEN
Set Value codeMsg = Code Exist ->output
ELSE
Set Value codeMsg = Code Not Exist ->output

And for testing I only open the API in browser I can see the output base on the condition, but it doesn’t work…

The Database Query is a simple table with a WHERE static condition:

SELECT id_bm
FROM br_cars_general_address
WHERE id_bm = 2

WHERE id_bm = 2 in the database actually not exist, and the condition should have to output codeMsg = Code Not Exist but no, I always get codeMsg = Code Exist

Images:

Server Action

Database Query with WHERE condition.


Data in database:

image
As you can see only exist id_bm 1

And now the output in browser:

image

If change the static value in WHERE with 1

image

Now the new output:

image

The result should have to be codeMsg = Code Not Exist

My workaround is to use one column of the query inside the Condition to show the correct menssage:


image

And now browser output:
image

If I change id_bm = 1 I obtain in browser output:
image

using the same logic in a PHP project it works as it should, without the need to index the column in the Condition like this validacion_codes[0].id_bm, in php project is directly the condition. validacion_codes

Community Page
Last updated: