forcedotcom / phoenix

BSD 3-Clause "New" or "Revised" License
558 stars 227 forks source link

Support UPSERT SET command #661

Open jtaylor-sfdc opened 10 years ago

jtaylor-sfdc commented 10 years ago

Support setting values in a table through a new UPSERT SET command like this:

UPSERT my_table SET title = 'CEO'
WHERE name = 'John Doe'

UPSERT my_table SET pay_by_quarter = ARRAY[25000,25000,27000,27000]
WHERE name = 'Carol';

UPSERT my_table SET pay_by_quarter[4] = 15000
WHERE name = 'Carol';

This would essentially be syntactic sugar and use the same UpsertCompiler, mapping to an UPSERT SELECT command that simply fills in the primary key columns like this:

UPSERT FROM my_table(name,title) 
SELECT name,'CEO' FROM my_table
WHERE name = 'John Doe'

UPSERT FROM my_table(name, pay_by_quarter[4]) 
SELECT name,15000 FROM my_table
WHERE name = 'Carol';