How to do partial update via rest api

Hello everyone,

I wonder how to do a partial update via rest API?
I’ve read through the documentation and noticed the update endpoint will override the existing data, and as such important API capability, I couldn’t believe there is none at the moment !!

is there any plan for when to implement it? or is there any community effort for such functionality

thanks

Not at the moment, nor have we found any usecases that couldn’t be solved by the endpoints we currently have.

If you wish to do a partial modification you can:

  1. Fetch the original record
  2. update the value in the fetched record
  3. update the record.

Since you’re probably displaying that record somewhere you already have the record fetched and you don’t even need to do the first step.

hi @tjerman ,

I have some points here

  • I have a lot of fields in the module, so it wouldn’t be efficient to fetch all of them
  • some of the fields have a very high frequency of change (within a few seconds), so if the integration fetches the record and do some kink of complex logic it gonna override the changes
  • lastly, could you kindly direct me to how this could be implemented?

thanks

Can the integration be tweaked to send over all of the fields instead of just the changed fields?
This would allow you to replace the original record since the other fields remain the same.
Under the assumption of the worst-case that all of the fields would change, this should be fine.

Another thought in regards to the frequent changing – if the changes don’t need to be real-time you could consider increasing the pool window to remove the number of changes to the same record.

This is quite a bit for me to write down right now, but TL;DR would be:

The rest (RBAC, DB, logging, …) should already be reusable.
Hopefully, this is enough to get you started.
Feel free to come back with questions if any arise.

Do note that if you do decide to implement this on your own you will need to handle all of the release related stuff on your own.

1 Like

@tjerman this is very helpful, thanks for sharing

1 Like

@tjerman I think I have found a bug related to this partial update

I have a checkbox field that has a default value of false.
when I enter the record and edit the value of a different field and save the record it will override the checkbox field and make it null!
so when I filter the fields based on that boolean value to be false it wouldn’t work

Default values are only applied when records are being created, and since we don’t natively support partial record updates, you only modifying field F2 resulted in field F1 being treated as value removed so it was removed.
Unless I’m missing something I’ll write this off as a feature :dark_sunglasses:

@tjerman :sweat_smile:
the feature would turns to bug if I made a default value for boolean as false

Everything can be written off as a feature if you squint hard enough.

I’m not entirely sure on the concrete issue you’re facing now; if you give me some more context I’ll be able to help more.

If a boolean field doesn’t have a value (is NULL) you’ll need to compare it against NULL, like discussed here.
The same applies to all fields, but booleans are the usual culprits of confusion.

1 Like