Updating Postgres db without changing unaffected column

Hi I want to update my db using Postgres node with update operation. In this db there’s 3 types of data type which is text, array and boolean. The problem is that if I only wants to update the one or certain columns the column with boolean data type is always going to be affected and change to false. Is there a way to use Postgres node with update operation to only updating the affected column and retain all the value from the unaffected one (only happening in boolean data type column)?

Hi,

I assume you have created an update node to update the column. Without the workflow or screenshot it’s hard to guess what’s going on.

My first guess would be that the mapping tot the columns is set to automatic. If not check wich mappings are done and if your boolean column is filled with the proper input to update.

If that is all okay. I would check what the input to your update node looks like. The json var that fills the boolean field, what is the input for that and where does it come from. If it’s always set tot true, well than it’s working as disigned. If it’s not always true, then check the output on what the update node writes to the database.

Just the first things that pop-up in my mind.

Regards

Hi @Michiel_Slik thanks for your reply, Here’s part where the problem occurred:

If I want to update the content or summary database and leaving the other untouched, every column with boolean data type will change to false because the postgres node default value of boolean is false. As of now I use query to update the column that I want but I just want to make sure with postgres node update operation can handle this issue.

  • Mapping: Ensure you are only mapping the columns you want to update in the node configuration.

  • Empty Values: If you map a boolean column and leave its value empty, it may default to false(may its setting itself to 0). To avoid this, do not map the boolean column at all if you do not want to update it.

1 Like

Hi @Parintele_Damaskin thanks for your reply, I just realize that there’s a garbage bin icon to remove the column I don’t need to update. Thanks this helps me a lot.

1 Like

I have so many questions. But I see you found a solution. But to be honest, this can be an anoance in the future. So my question is first, you let the AI agent generate code, but I don’t see in your update node no connection to it apparent from json.id. So where is it getting its data from?

Next, you have your boolean on fixed not on expression. With expression you can generate code to that field (or let the AI agent do it automatically) so when in the future you have to update the booeleans or any other field, you can manipulate it correctly.

If it’s solved, it’s solved. But I suspect in the future if you want to extend, your gonna run into the same problem.

HI @Michiel_Slik, regarding your questions I use postgres node with "‘Execute Query’ operation, I don’t add this node in the example I use above since the problem I faced is with ‘Update’ operation.
And for the second question I don’t really sure on how to answer it because the problem is already solve if in the future I want to update the booleans I just need to use ‘Update’ operation and only select the booleans that I need to update.

1 Like