You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hugegraph.apache.org by je...@apache.org on 2022/07/07 11:11:29 UTC

[incubator-hugegraph] branch pg-where-comma-fix created (now f44b5bc3a)

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

jermy pushed a change to branch pg-where-comma-fix
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git


      at f44b5bc3a resume

This branch includes the following new commits:

     new 23dbc300a fix: possible extra comma before where statement
     new f44b5bc3a resume

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-hugegraph] 02/02: resume

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jermy pushed a commit to branch pg-where-comma-fix
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git

commit f44b5bc3a28e9bef1924933967f3cf822851ed6d
Author: Zhangmei Li <li...@baidu.com>
AuthorDate: Thu Jul 7 16:18:51 2022 +0800

    resume
    
    Change-Id: Ic36ee61dbeb420abbd7881196e323a3997c3385b
---
 .../java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java
index 71cc158dd..1de121a11 100644
--- a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java
+++ b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java
@@ -27,7 +27,6 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.function.BiFunction;
 
 import org.apache.logging.log4j.util.Strings;
@@ -53,7 +52,6 @@ import com.baidu.hugegraph.iterator.ExtendableIterator;
 import com.baidu.hugegraph.iterator.WrappedIterator;
 import com.baidu.hugegraph.type.HugeType;
 import com.baidu.hugegraph.type.define.HugeKeys;
-import com.baidu.hugegraph.util.CollectionUtil;
 import com.baidu.hugegraph.util.E;
 import com.baidu.hugegraph.util.Log;
 import com.google.common.collect.ImmutableList;
@@ -293,13 +291,12 @@ public abstract class MysqlTable
         update.append(" SET ");
 
         List<HugeKeys> idNames = this.idColumnName();
-        Set<HugeKeys> columns = entry.columns().keySet();
-        int idColumnsSize = CollectionUtil.intersect(columns, idNames).size();
 
         int i = 0;
-        int size = columns.size() - idColumnsSize;
-        for (HugeKeys key : columns) {
+        int size = entry.columns().size();
+        for (HugeKeys key : entry.columns().keySet()) {
             if (idNames.contains(key)) {
+                size--;
                 continue;
             }
             update.append(formatKey(key));


[incubator-hugegraph] 01/02: fix: possible extra comma before where statement

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jermy pushed a commit to branch pg-where-comma-fix
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git

commit 23dbc300a170c5ce5f3e00a75f99d6e26129eb0d
Author: Zhangmei Li <li...@baidu.com>
AuthorDate: Thu Jul 7 15:45:21 2022 +0800

    fix: possible extra comma before where statement
    
    fix #1923
    Change-Id: I095311942c3633a5978930e35fecd9fd47b08796
---
 .../hugegraph/backend/store/mysql/MysqlTable.java      | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java
index 69efd96bd..71cc158dd 100644
--- a/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java
+++ b/hugegraph-mysql/src/main/java/com/baidu/hugegraph/backend/store/mysql/MysqlTable.java
@@ -27,6 +27,7 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.function.BiFunction;
 
 import org.apache.logging.log4j.util.Strings;
@@ -52,6 +53,7 @@ import com.baidu.hugegraph.iterator.ExtendableIterator;
 import com.baidu.hugegraph.iterator.WrappedIterator;
 import com.baidu.hugegraph.type.HugeType;
 import com.baidu.hugegraph.type.define.HugeKeys;
+import com.baidu.hugegraph.util.CollectionUtil;
 import com.baidu.hugegraph.util.E;
 import com.baidu.hugegraph.util.Log;
 import com.google.common.collect.ImmutableList;
@@ -235,18 +237,18 @@ public abstract class MysqlTable
         insert.append(" (");
 
         int i = 0;
-        int n = entry.columns().size();
+        int size = entry.columns().size();
         for (HugeKeys key : entry.columns().keySet()) {
             insert.append(formatKey(key));
-            if (++i != n) {
+            if (++i != size) {
                 insert.append(", ");
             }
         }
         insert.append(") VALUES (");
         // Fill with '?' as a placeholder
-        for (i = 0; i < n; i++) {
+        for (i = 0; i < size; i++) {
             insert.append("?");
-            if (i != n - 1) {
+            if (i != size - 1) {
                 insert.append(", ");
             }
         }
@@ -286,18 +288,18 @@ public abstract class MysqlTable
     }
 
     protected String buildUpdateIfPresentTemplate(MysqlBackendEntry.Row entry) {
-
         StringBuilder update = new StringBuilder();
         update.append("UPDATE ").append(this.table());
         update.append(" SET ");
 
         List<HugeKeys> idNames = this.idColumnName();
+        Set<HugeKeys> columns = entry.columns().keySet();
+        int idColumnsSize = CollectionUtil.intersect(columns, idNames).size();
 
         int i = 0;
-        int size = entry.columns().size();
-        for (HugeKeys key : entry.columns().keySet()) {
+        int size = columns.size() - idColumnsSize;
+        for (HugeKeys key : columns) {
             if (idNames.contains(key)) {
-                size--;
                 continue;
             }
             update.append(formatKey(key));