revig / revigniter

Framework for people who build websites using LiveCode
https://revigniter.com/
Apache License 2.0
28 stars 9 forks source link

ActiveRecord routines set columns to empty string if they have no value in the data array. #10

Closed soapdog closed 5 years ago

soapdog commented 5 years ago

Summary

When using the ActiveRecord implementation, if the developer passes an array with empty elements, RevIgniter sets them to empty strings when saving/updating. So if a developer fetches a record with some null columns, they are coerced into empty by LC, then saves the record, those NULL values are overwritten with empty which is not the same value.

Expected result: [What you expect to happen]

Set them to null or ignore them.

Observed result: [What actually happens]

Values are set to empty string.

Recipe to Reproduce

Versions

Latest

Additional Information

This causes MySQL 5.7 to abort transactions. So users who are happily developing with RevIgniter and upgrade their database server might start seeing their database break and their system unstable before realizing what is happening.

I think the best practice would be for the ActiveRecord implementation to ignore columns with empty values, as in, not add them to either update or insert.

revig commented 5 years ago

@soapdog I modified function rigDbValuesSet() in DBactiveRec.livecodescript according to your report. Could you please replace your library with the new one and check if everything works as expected?