From ed8e7545578b7fc9e33a39f3635e6f0286198d10 Mon Sep 17 00:00:00 2001 From: Redkale <8730487+redkale@users.noreply.github.com> Date: Sat, 24 Nov 2018 14:20:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9ColumnValue...=E5=90=ABnull?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/org/redkale/source/DataSqlSource.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/org/redkale/source/DataSqlSource.java b/src/org/redkale/source/DataSqlSource.java index 6151c7660..53129346a 100644 --- a/src/org/redkale/source/DataSqlSource.java +++ b/src/org/redkale/source/DataSqlSource.java @@ -785,6 +785,7 @@ public abstract class DataSqlSource extends AbstractService implement List blobs = null; int index = 0; for (ColumnValue col : values) { + if (col == null) continue; Attribute attr = info.getUpdateAttribute(col.getColumn()); if (attr == null) throw new RuntimeException(info.getType() + " cannot found column " + col.getColumn()); if (setsql.length() > 0) setsql.append(", "); @@ -797,6 +798,7 @@ public abstract class DataSqlSource extends AbstractService implement setsql.append(c).append(" = ").append(info.formatSQLValue(c, col)); } } + if (setsql.length() < 1) return CompletableFuture.completedFuture(0); String sql = "UPDATE " + info.getTable(id) + " SET " + setsql + " WHERE " + info.getPrimarySQLColumn() + " = " + FilterNode.formatToString(id); if (blobs == null) return updateDB(info, null, sql, false); return updateDB(info, null, sql, true, blobs.toArray()); @@ -865,6 +867,7 @@ public abstract class DataSqlSource extends AbstractService implement int index = 0; String alias = "postgresql".equals(writePool.dbtype) ? null : "a"; //postgresql的BUG, UPDATE的SET中不能含别名 for (ColumnValue col : values) { + if (col == null) continue; Attribute attr = info.getUpdateAttribute(col.getColumn()); if (attr == null) continue; if (setsql.length() > 0) setsql.append(", "); @@ -877,6 +880,7 @@ public abstract class DataSqlSource extends AbstractService implement setsql.append(c).append(" = ").append(info.formatSQLValue(c, col)); } } + if (setsql.length() < 1) return CompletableFuture.completedFuture(0); Map joinTabalis = node.getJoinTabalis(); CharSequence join = node.createSQLJoin(this, true, joinTabalis, new HashSet<>(), info); CharSequence where = node.createSQLExpress(info, joinTabalis); @@ -1060,6 +1064,7 @@ public abstract class DataSqlSource extends AbstractService implement final List> attrs = new ArrayList<>(); final List cols = new ArrayList<>(); for (ColumnValue col : values) { + if (col == null) continue; Attribute attr = info.getUpdateAttribute(col.getColumn()); if (attr == null) continue; attrs.add(attr); @@ -1076,6 +1081,7 @@ public abstract class DataSqlSource extends AbstractService implement final List> attrs = new ArrayList<>(); final List cols = new ArrayList<>(); for (ColumnValue col : values) { + if (col == null) continue; Attribute attr = info.getUpdateAttribute(col.getColumn()); if (attr == null) continue; attrs.add(attr);