In the event that things go wrong running a SQL query, I had imagined that Retool forms would generally set .initialData = null.
But .initialData seems to get one of three values: a valid data object {}, null, or undefined.
When using the Postgresql retool_db and running a SELECT that targets a single row,
Which we transform to make it the datasource of a Form:
We get the following behaviour:
- id = 0 or id = {{ 0 }} => undefined
- id = 99 or id = {{ 99 }} => undefined // if 99 is not an id in the recordset
- id = null or id = {{ null }} => null
- id = {{ undefined }} => undefined
Since Javascript treats undefined and null as both falsey, this is rarely a problem. But if you have code specifically evaluating .initialData then this might be of interest.
As an aside, .data will have the following contents:
- undefined or null => { id:0 }
- valid initialData => { id: n } // when n was the search id