New Datatypes are few and far between nowadays, but yesterday we felt compelled to add one. It’s called Dynamic, and as its name implies, it is used to implement fields that capture values which datatypes are not known in advance and can change from one record to another for the very same field.
Who needs that are you asking? Well, not very many people indeed. Nevertheless, we had three perfectly valid use cases that called for it. First, the Default value field of the Fields object, which datatype should be the datatype of the field, which can be different from one record of the Fields object to another. Second, the Value field of the Settings object (Cf. previous post). Third, the Result field of the Functions object, which captures the expected result of a default automated test for a Formula.js function.
This datatype is defined with three options:
- Datatype, which references a field of the object defining the dynamic datatype
- Datatype reference, which stores a Formula.js expression to dynamically define the datatype
- Options, which references a field of the object defining the options of the datatype
Internally to the system, this datatype is implemented using the String primitive, which is the most generic one, and onto which any datatype can be mapped without any data loss. And from a user interface standpoint, we’ve added a new control that dynamically displays the right control for the datatype associated to a particular field value (the value of a field for a particular record).
This all might seem pretty complex, but the use cases that are using this new datatype could not be properly implemented in any simpler fashion. In fact, we’ve been trying to avoid the issue for a while, but as we’re getting closer to making our first beta release, we realized that Settings had to be improved. In the past, they were defined using the JSON datatype, for which no user-friendly control can be developed. We also realized that we needed to improve the way default values are defined for fields. And the straw that broke the camel’s back was when Hannes started to add test cases to the Functions object. So we decided to bite the bullet and do it right.
Florian should be done with the Dynamic Control later today…
We now have 66 datatypes…