Tinyint field set to true in condition

Looks like an older bug is back. When I add a condition equal == 1 in Query builder, Wappler is saving it as true.

I think this is the way it works - and the bug is fixed, eg as discussed in this thread:

But 1 is not true, it’s 1. Why should it be converted? I thought that this has been fixes so for tinyint it shows 1 not true

I think it’s just a UI issue - perhaps to be compatible with the way other databases handle boolean data types. Eg you can define a column as a tinyint which you can compare to a value of 1, and it will work as expected. It’s a slight anomaly that query builder show ‘true’ instead of 1, but I don’t think this affects anything.

Or perhaps it is still a bug and it will show ‘1’ when fixed. However, as it stands, it works; previously it didn’t (the column would be compared to ‘true’ when the query was executed - so the query failed).

I think it’s (again) an ui issue. If I remember right this hass been fixed, but now seems to be back.

Sorry - I’ve just realised you mentioned you were on the latest version 3.9.7; I’m still using 3.9.6.

Doing some more testing with 3.9.6, in most cases it seems completely fixed. It may be that the ‘true’ only appears in specific cases - eg with existing API files - and even then, it’s only a UI issue.

So, if whatever was changed between these two versions can be fixed/reverted, hopefully the bug will be gone for good. I’ll stay with 3.9.6 for now.

1 Like

The TinyInt field in MySQL is only seen as boolean when it was defined as tinyint(1), when using tinyint(4) it will be treated as an integer field.

HI Patrick. Is this new? We have all 1/0 database fields as tinyint(1). I don’t want this to be changed.

Well this has been forever like this:

The data is all the same but the number between braces just indicates type.

So you should change it if it gives you problems.

Well in the UI I always saw == 1 and not equal true…

The questions, is: is this new and does that lead to problems?!

Now, is equal true working in Wappler the same as == 1 does?

Assuming there weren’t any changes after v3.9.6, it is just a UI matter. I checked the actual queries executed and they were correct: using ‘==1’, not ‘true’. Previously tinyint was compared to ‘true’ , in the UI and in the query as executed. This (the latter) was the problem, and it was fixed.

1 Like

In Wappler an TinyInt(1) is handled as a Boolean. For the database it is converted to the correct format the database understands, in databases that do not support native boolean fields this is often 1 and 0.