Sobes.tech
Middle

What will happen to the database record after calling PATCH (change the price to 70 thousand), and then PUT (brand not specified, color black, price not specified)?

sobes.tech AI

Answer from AI

When calling PATCH with a change of 70 thousand in the database record, only the price field will be updated, and the other fields will remain unchanged.

Then, when calling PUT, if the request body does not specify a brand but specifies a color (black), and the price is not specified, the record will be completely replaced with the data from the PUT request. This means that the brand field will become empty or null (depending on implementation), the color will be updated to black, and the price, since it is not specified, will be reset or set to a default value.

Result: PATCH partially updates the record, preserving other fields, while PUT replaces the entire record, so the absence of a field in PUT leads to its deletion or nullification in the database.