INSERT/UPDATE Strict Models Enhancements #85

Closed
opened 2022-10-02 03:53:23 +00:00 by jamie · 3 comments
jamie commented 2022-10-02 03:53:23 +00:00 (Migrated from git.hazaar.io)

Using strict models is a good way to normalise data on it's way to the database. Currently it is possible to pass a Model\Strict object to DBI and it will extract the data into a field object to send to the driver, all automatically.

What it doesn't do automatically, is to do with fields that have a default value. Currently for these fields I would set dbi: false so that DBI does not send them. This is fine for an INSERT if I want the database server to create the value. But with an update, we might want to update a value.

What I propose is, if possible, we can do away with dbi: false in the strict model field definition and get INSERT to check the column metadata for any field values that are NULL. This should allow the INSERT to succeed because the actual SQL field will not include the NULL values, but at the same time allow UPDATES to succeed because we are no longer disabling DBI on these fields.

Using strict models is a good way to normalise data on it's way to the database. Currently it is possible to pass a `Model\Strict` object to DBI and it will extract the data into a field object to send to the driver, all automatically. What it doesn't do automatically, is to do with fields that have a default value. Currently for these fields I would set `dbi: false` so that DBI does not send them. This is fine for an INSERT if I want the database server to create the value. But with an update, we might want to update a value. What I propose is, if possible, we can do away with `dbi: false` in the strict model field definition and get INSERT to check the column metadata for any field values that are NULL. This should allow the INSERT to succeed because the actual SQL field will not include the NULL values, but at the same time allow UPDATES to succeed because we are no longer disabling DBI on these fields.
jamie commented 2022-10-02 03:53:23 +00:00 (Migrated from git.hazaar.io)

assigned to @jamie

assigned to @jamie
jamie commented 2022-10-02 04:04:03 +00:00 (Migrated from git.hazaar.io)

created branch 85-insert-update-strict-models-enhancements to address this issue

created branch [`85-insert-update-strict-models-enhancements`](/hazaar/hazaar-dbi/-/compare/master...85-insert-update-strict-models-enhancements) to address this issue
jamie commented 2022-10-02 04:04:11 +00:00 (Migrated from git.hazaar.io)

mentioned in merge request !54

mentioned in merge request !54
jamie (Migrated from git.hazaar.io) closed this issue 2022-10-02 04:08:48 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: hazaar/hazaar-dbi#85
No description provided.