Interesting. This, however, seems to need some sort of SQL interpreter, and even if one is provided, it would have to be pretty darn smart. What if my SQL statement is a multi-statement SQL? What if in my multi-statement SQL I start with a SELECT but the next statement is an UPDATE? If the SQL interpreter/parser cannot cover things like this, I think I would just stick to layered programming and make the decision at the repository level based on the function call. Just my thoughts.
Slonik only allows you to execute one query at a time, so you cannot combine SELECT and UPDATE into one. In the context of the chosen stack, all you need to make a sane decision are the 3 criteria outlined in the post.
Yes, then it's not for me, unfortunately. All my REST API does UPDATE/INSERT then SELECT to return the most current version of the record to pick up database-inserted data like timestamps. I would need a different mechanism. Still, it is interesting for sure. Thanks for sharing.
Interesting. This, however, seems to need some sort of SQL interpreter, and even if one is provided, it would have to be pretty darn smart. What if my SQL statement is a multi-statement SQL? What if in my multi-statement SQL I start with a
SELECTbut the next statement is anUPDATE? If the SQL interpreter/parser cannot cover things like this, I think I would just stick to layered programming and make the decision at the repository level based on the function call. Just my thoughts.Slonik only allows you to execute one query at a time, so you cannot combine SELECT and UPDATE into one. In the context of the chosen stack, all you need to make a sane decision are the 3 criteria outlined in the post.
Yes, then it's not for me, unfortunately. All my REST API does UPDATE/INSERT then SELECT to return the most current version of the record to pick up database-inserted data like timestamps. I would need a different mechanism. Still, it is interesting for sure. Thanks for sharing.
You can use the 'returning' keyword to make update and insert return the filled in columns. You don't need a select for that.