Hi @freetool, I found a workaround for this issue. It takes an extra step but it should work like a charm.
We'll need a JS query to format the data from the form. In other words, change the "" to null when needed.
To keep this example simple, I added an age column to my sample_users table:
Note: I'm also allowing
null at the db level to simulate your use case.
Here, I've selected the row with the id of 72011 (pardon the mess, long story). As we can see in the form below, the form gets populated with the data of the selectedRow.
The query that is open on the left panel, formatFormData, is what we will run on submit of the form. On success of formatFormData, we'll run the actual update query, passing the output of the former query as the "Changeset object".
Once I clear the value of age on the form and submit it:
The JS query runs, and returns an object where the value of the key age is either the new number on the form, or null if it was cleared (no more ""
).
Here is the new output:
YAY!
On success, we now run the update query, passing the output of formatFormData as mentioned above:
Here is the new data on the table:
I also tested it a few times by adding and removing the age:
You may have to set up your version of the formatFormData to include all columns that are numerical and you allow null:
const obj = form1.data
let ageVal = age.value ? age.value : null
let columnNameVal = formInput.value ? formInput.value : null // repeat this line for each one of those columns
return {...obj, age: ageVal, colName: columnNameVal} //add each k-v pair here