This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch add-pg-support
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git


The following commit(s) were added to refs/heads/add-pg-support by this push:
     new dbcb61046 Fix conflict
dbcb61046 is described below

commit dbcb61046a61ed10566ac004135635d5a667a282
Author: Xuanwo <[email protected]>
AuthorDate: Wed Aug 9 17:15:15 2023 +0800

    Fix conflict
    
    Signed-off-by: Xuanwo <[email protected]>
---
 core/src/services/postgresql/backend.rs | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/core/src/services/postgresql/backend.rs 
b/core/src/services/postgresql/backend.rs
index 9cb1ca998..7600a5bde 100644
--- a/core/src/services/postgresql/backend.rs
+++ b/core/src/services/postgresql/backend.rs
@@ -280,9 +280,14 @@ impl kv::Adapter for Adapter {
     }
 
     async fn set(&self, path: &str, value: &[u8]) -> Result<()> {
+        let table = &self.table;
+        let key_field = &self.key_field;
+        let value_field = &self.value_field;
         let query = format!(
-            "INSERT INTO {} ({}, {}) VALUES ($1, $2)",
-            self.table, self.key_field, self.value_field,
+            "INSERT INTO {table} ({key_field}, {value_field}) \
+                VALUES ($1, $2) \
+                ON CONFLICT ({key_field}) \
+                    DO UPDATE SET {value_field} = EXCLUDED.{value_field}",
         );
         let statement = self
             .statement_set

Reply via email to