empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From der...@apache.org
Subject [11/14] empire-db git commit: EMPIREDB-247
Date Wed, 09 Nov 2016 10:59:18 GMT
EMPIREDB-247

- automatically add WHERE PKs to cmd

Project: http://git-wip-us.apache.org/repos/asf/empire-db/repo
Commit: http://git-wip-us.apache.org/repos/asf/empire-db/commit/04cc588f
Tree: http://git-wip-us.apache.org/repos/asf/empire-db/tree/04cc588f
Diff: http://git-wip-us.apache.org/repos/asf/empire-db/diff/04cc588f

Branch: refs/heads/EMPIREDB-247
Commit: 04cc588fb171d079e057aecd65096de2860153ab
Parents: 16c3111
Author: Jan Glaubitz <jan@glaubitz.org>
Authored: Fri Aug 19 13:58:28 2016 +0200
Committer: Jan Glaubitz <jan@glaubitz.org>
Committed: Wed Nov 9 11:56:53 2016 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/empire/db/DBDatabase.java   | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/empire-db/blob/04cc588f/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
----------------------------------------------------------------------
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java b/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
index 5757b96..b9b7817 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
@@ -40,6 +40,7 @@ import org.apache.empire.db.exceptions.QueryFailedException;
 import org.apache.empire.db.exceptions.QueryNoResultException;
 import org.apache.empire.db.exceptions.StatementFailedException;
 import org.apache.empire.db.expr.column.DBValueExpr;
+import org.apache.empire.db.expr.set.DBSetExpr;
 import org.apache.empire.exceptions.InternalException;
 import org.apache.empire.exceptions.InvalidArgumentException;
 import org.apache.empire.exceptions.ItemExistsException;
@@ -1405,6 +1406,16 @@ public abstract class DBDatabase extends DBObject
     	}
     	else
     	{
+    		// Add WHERE (<all pks> to UPDATE
+    		DBTable table = (DBTable) cmd.set.get(0).getTable();
+    		for (DBSetExpr se : cmd.set)
+    		{
+    			DBColumn column = se.column;
+    			if (table.getPrimaryKey().contains(column))
+    			{
+    				cmd.where(column.is(se.value));
+    			}
+    		}
     		int count = executeUpdate(cmd, conn);
     		if (count < 1) {
     			// nothing updated -> INSERT


Mime
View raw message