Upsert


#1

The possibility to use ‘upsert’ into a database. Update when a record exists, and insert when it doesn’t exist.

I currently use a server side condition to achieve the same, but it would be much simpler to have just 1 step that does it.


#2

Is that even a real thing?


#3

(Update: sorry - I didn’t read your question carefully enough. What I described was related to your question but wasn’t the correct answer. Hopefully we’ll have options to do insert as you describe when we can create custom queries.)

I made essentially the same request here. It seems the issue is that the relevant SQL command is not standard so can’t be included as an option.

If you’re using MySQL, there is such an option (INSERT IGNORE) and a minor tweak to SqlBuilder.php makes INSERT work like this. Obviously it’s not ideal to modify these files, but that’s what I’m doing and as you say, it makes things simpler (and much faster).


#4

We are taking about an " INSERT ON DUPLICATE KEY UPDATE" clause here is assume. It is not currently supported in Wappler however the new proposed “Custom SQL server action” announced earlier this week may allow this to be done directly. Obviously until we see how i works can’t be certain. And yes, it would be a useful addition.

(Sorry @TomD, didn’t read your answer properly and just repeated what you said)


#5

That’s the right way to do it - using the condition in Server Connect.