Strict model: Add new field at runtime #224
Labels
No labels
bug
confirmed
critical
discussion
documentation
Doing
enhancement
experiment
suggestion
support
Testing
To Do
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: hazaar/framework#224
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I have an instance where I want to add a new field at runtime. Normally this isn't allowed as it goes against the principles of strict models in the the strict part is that it's supposed to restrict what can be added to a model and the data type. To do this, we need to define the field and it's type.
However it should be OK to add a new field definition at runtime. The case I'm thinking of is using DBI to get a row from a table using
Hazaar\Table::findOneRow()
which returns aHazaar\DBI\Row
object which itself extendsHazaar\Model\Strict
and automatically defines all the fields in the model using the returned columns, including their type and any custom features/functions for those types that are provided by the row class. In a REST API, I want to return this row as is, allowing the Row class to do it's thing, but I want to add a field to the returned object (in this case, a URL).created merge request !114 to address this issue
mentioned in merge request !114
mentioned in commit 8a5eacbdb2d743d0fd5f4b944f3ef406f7d8d01f