tjmoses / postgraphile-plugin-batch-create-update-delete

A postgraphile plugin that allows for batch create, update, & delete mutations in a single transaction.
https://www.npmjs.com/package/postgraphile-plugin-many-create-update-delete
MIT License
37 stars 9 forks source link

Curious on implementation here #16

Closed markhalonen closed 2 years ago

markhalonen commented 2 years ago

Hey @tjmoses, was just looking through the code and the CASE statements in the UPDATE stuck out to me:

https://github.com/tjmoses/postgraphile-plugin-batch-create-update-delete/blob/433049b4d4741f7db4143e5a65759f8d91cec501/src/PostGraphileManyUpdatePlugin.ts#L370

Would it be possible to only include the used SQL columns in the UPDATE statement? could it be something like UPDATE t1 SET {...usedSqlColumns}=t2.val and avoid the CASE statement? We haven't noticed any issues in behavior, just curious if there was a reason for all columns to be involved in the SQL statement.

tjmoses commented 2 years ago

Go here for more info. It's mainly around if the values can be null, then it can skip them to perform the inline update using the temporary table.