Boolean fields used in Query Builder cause queries to fail

Wappler Version : 3.9.2
Operating System : Windows 10
Server Model: PHP
Database Type: MySQL
Hosting Type: custom

Expected behavior

What do you think should happen?

Having defined a column as tinyint, it should be possible to include this column in a query - eg with a condition such tinyintColumn = 1

Actual behavior

What actually happens?

Having enter '1' in the query condition, Wappler converts this to 'true' and the query fails.

How to reproduce

Create a column and define it as Boolean (using Wappler's Database Manager) or as a tinyint (eg in Navicat). The result is the same in either case. Include the column in a query, comparing the value to 1. Wappler converts this to 'true' and the query will fail. Wappler seems to treat the field as a text field.

This issue has been raised quite a few times. Although some changes/fixes have been made, the issue seems the same as raised here in v.3.7.8. (I think it was working in some versions since then.)

There are various ways round this, eg editing the code and changing 'true' to '1':

image
.. but Wappler will change this back if the Save button is used (not with Ctrl+S), or if the SA is edited.

I can confirm this. I have the same issue.

This is still a problem with 3.9.5.

Just to clarify, entering ‘1’ in a query is changed to ‘true’:

image

If for example, you’re using a tinyint column in MySQL for a boolean field, this query will fail. This wasn’t a problem until a few versions ago. I raised the issue in relation to 3.7.8.

Given this causes queries to fail, I would have thought this would be quite an important bug. I hope it can be fixed soon. It’s easy to reproduce. There are workarounds - perhaps defining a variable with a value of 1 is the most reliable.

How is your tinyint defined in MySQL? Booleans should be defined as tinyint(1)

Yes, that’s exactly how I define them.

Please test with the following update, it should work with the boolean value. Unzip file to dmxConnectLib/lib/db.

Connection.zip (1.7 KB)

Hi @patrick

it does not work for me.

image

In the json it will put a boolean for the tinyint(1) field, but it should not throw an error anymore on the server.

1 Like

Thank you for the information. I will test this.

Hmm, I tested it and now I get a blank page and a blank website.

No errors? What does the server connect action return?

Thats what I get:

HTTP ERROR 500

Then there is a PHP error, could you turn on debug, it should then return the error.

Already see the error, here an update. Sorry for that.

Connection.zip (1.7 KB)

I still get the following error:

"message":"Undefined index: isRead","trace"

Is the isRead the database fieldname with the boolean?

Yes

Which database version do you use?

Sorry for the delay: