How is your experience with the OutSystems Community?
Support Partial Entity Updates Without Retrieving the Entire Record
98
Views
3
Comments
New
Database

Currently, updating a single entity attribute in OutSystems often involves retrieving the entire record, modifying the required attribute, and calling the Update Entity action.

It would be useful to have native partial update (PATCH-like) functionality, allowing developers to update specific attributes using the Entity ID without retrieving the complete record or writing Advanced SQL.

Benefits:

  • Reduce unnecessary database reads.

  • Simplify development and improve maintainability.

  • Prevent accidental overwriting of unrelated attributes.

  • Potentially improve database performance.

It is intriguing to imagine what a visual representation of that partial update would look like. Off the top of my head, it is difficult to imagine what an action added to the other CRUD actions on the entity would look like in a way that would be easier to use than the Advanced SQL. You would need to pass the Identity field as required, then a list of the attributes you want to change and their new values. A simple structure with text attributes Name and Value could be used, but that would require some data type conversion behind the scenes. 

Just curious, did you already have a visual design in mind?

@Joseph Marlin 

Thanks for your feedback!

I was thinking of adding a Partial Update mode to the existing Update Entity action, where developers can specify the Entity ID and only the attributes to update, similar to an Assign node.

Since the attributes are selected from the entity definition, their data types would already be known.

I've attached a simple UI mockup for reference. Would this approach work? 

@Shradha nair - just to be clear, I no longer work at Outsystems, so I have no real pull to get this done. I like your idea, and that is a beautiful UI design you created, but I still struggle to see it fitting into the existing Service Studio visual Entity action interface. 

For example, look at the system entity, User, and the Entity Action UpdateUser.

The input parameter for the Update action is the entity record. You fill the entity record's attributes with values, either existing or new, and Outsystems writes the full UPDATE script behind the scenes - sometimes using a partial statement if you have set the Update Behavior on the Entity as Changed Attributes, or a full UPDATE if the behavior is all attributes.

So behind the scenes on a "Changed Entity" it compares the values to see if they have changed, and only scripts a partial UPDATE to address those changed attributes. But it still requires a full copy of the record with all attributes.

Still brainstorming. The properties of an entity attribute are stored in the Entity_Attr system entity. There you can see the Name, Description, Type, Length, etc., that make up the definition of the individual attributes of an entity. To create a standard Entity action, the input would be, not an entity record, but a List of your chosen Attributes, plus their updated value.

In ODC, for example, the additional Entity action UpdateSome accepts a list of Entity records.

In your ODC code, you do whatever you need to do to build the list of records you want to update.

In this case, in O11, you would need to, in code, do something like you so beautifully illustrated to select which attributes to add to the list for the input parameter of attributes to be updated, plus the value of each attribute. The tricky bit is enforcing the data type of each attribute when you are assigning variables as values.

Oh well - food for thought. This will probably keep me awake at night for a bit.