Event sync with streams, type bool from the contract - string in the database

Hi, in the migration to a self hosted server Iā€™ve noticed an issue, a different behavior by how itā€™s currently working in the moralis instance.

I created a stream for an event sync from a contract. The type of a field of the event is ā€œboolā€ in the event signature, but when the table is created (when the event is triggered) the column is created not as Boolean but as String.

This impacted the behavior of the cloud functions (e.g. equalTo(ā€œfieldā€, true) is no more working because it doesnā€™t recognize the field as Boolean.

Why is happening that? The contract field type is a boolean, Iā€™d expect to have in the database column a Boolean type, not a String.

A change in beforeSave or afterSave could solve, yes, but it would be another change required to the logic and I would like to avoid it.

Hi, there is a function in the self hosted server that processes the event and sets the types, you could try to modify that function too.

you can also update this code to make a string comparison

Hello, what function are you referring to?

Iā€™ve this event in the stream
SaleUpdate(address,uint256,uint256,address,uint256,bool,bool,uint256)

the two ā€œboolā€ are saved as String type in the database Column.

As mentioned, changing the logic in the Cloud functions for all the comparisons from bool to string would have a huge impact and would not be a proper solution, they are type boolean and a true/false comparison, why should I change it to string? The boolean is also dual with the frontend and I would prefer to avoid to change the logic.

I would just expect from the event sync with the streams that a bool type is converted in a Boolean type in the database.

There is a function that parses the received event data from the streams webhook request and prepares it to be inserted in the database. You can find it in other forum posts or I can point you to it later.

Yes please if you can point the forum post would be highly appreciated, Iā€™m searching for it but I donā€™t find it.
Thanks

I was referring to this

You can also try to use beforeSave

With beforeSave I should change the name of the field, or I can just use set with the same name of the field, and changing the type?

I think that you can create a separate column of type bool and use that new name, or if you can create the table again from the start you could use the same name and set the column type to bool

Iā€™ve tried the second approach, changing the type of the column with the same name of the column, but when a new event is triggered, it fails because it tries to add a string in a bool fieldā€¦

Is expected a fix to this issue? A bool field should be saved as boolean column, is not a bug?

I think that the problem is that the column type is string now and you can not change it easily without deleting the entire table and creating the table again

But who decided that the column type boolean is string now? In the previous behavior of event sync, a bool value from the contract was a Boolean value in the column of the database, this is creating an impact in the changeā€¦ seriously the solution proposed is to make a comparison among strings instead of boolean?

As I mentioned, creating the table from scratch with the same name of the column canā€™t be done, it fails. At the same time, with a new name of the column, I should to an absurd logic like if the string is true, then put boolean true in the new columnā€¦guys really, arenā€™t you planning to fix this issue to create a boolean column type for a boolean value from the contract?

You can change the name of the column in the abi and then create a new column with the expected name that you set with beforeSave.

Or you change the logic that adds the data in the database in the first place similar to the function that I posted.

You can also create manually in the parse dashboard interface a new table with a different name and with the expected column types and then add data in that table with beforeSave.

You have full control over the code.