Custom query with IF

Wappler Version : v.4.1.1
Operating System : Win 10 Pro
Server Model: NodeJS
Database Type: MySQL
Hosting Type: Docker

Custom query is very simple:

SELECT id, make, IF (:P1 = 2, model, null)
FROM cars

Steps to recreate:

  1. Define Set Value:

  2. Create a parameter with a binding:

  3. Get an error:

For some reason, query does not see the binding of the parameter, which is why it cannot check the condition.

Make sure you pop a test value into your parameters. When you run the test to get the schema, this is what it’s trying to use.

If you set a test value, query will work. But always, only with this test value. However, this does not solve the problem I pointed out above. The problem is that data binding does not work in the query. There are simply no values transmitted. Therefore, it is not possible to get dynamic data for the parameter.

When you test the query you need to pass a test value for it! You cannot test it without test data entered.


I agree, dynamic values are transmitted. Judging by the console, errors occur at the expression parsing stage when the table is rendered.

What I was doing:

  1. With help the generation of tables, I created a table:

  2. If you look at the request data, you can see that the check is correct and the data for the field is also received correctly:

  3. However, the data is not displayed in the table itself and the console screams an error:

@Teodor, any ideas on the problem?

I found the reason why I get the error. I’ll leave a solution here, for those who need to get something similar.

In order for the field to have a correct appearance on the client side and no errors occur, it is necessary to assign alias to the conditional IF in a custom query:

SELECT id, make, IF (:P1 = 2, model, null) AS zzz
FROM cars