X-Git-Url: http://git.squeep.com/?p=squeep-indie-auther;a=blobdiff_plain;f=src%2Fdb%2Fsqlite%2Fsql%2Fscope-upsert.sql;fp=src%2Fdb%2Fsqlite%2Fsql%2Fscope-upsert.sql;h=cb2770f97284b3bdabf13738db5ad652b5fb6711;hp=0000000000000000000000000000000000000000;hb=b0103b0d496262c438b40bc20304081dbfe41e73;hpb=8ed81748bce7cea7904cac7225b20a60cafdfc16 diff --git a/src/db/sqlite/sql/scope-upsert.sql b/src/db/sqlite/sql/scope-upsert.sql new file mode 100644 index 0000000..cb2770f --- /dev/null +++ b/src/db/sqlite/sql/scope-upsert.sql @@ -0,0 +1,16 @@ +-- +INSERT INTO scope ( + scope, + description, + application, + is_manually_added +) VALUES ( + :scope, + CASE WHEN :application IS NULL THEN '' ELSE :application END, + CASE WHEN :description IS NULL THEN '' ELSE :description END, + COALESCE(:manuallyAdded, false) +) ON CONFLICT (scope) DO UPDATE +SET + application = COALESCE(:application, EXCLUDED.application), + description = COALESCE(:description, EXCLUDED.description), + is_manually_added = EXCLUDED.is_manually_added OR COALESCE(:manuallyAdded, false)