You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2021/05/19 21:09:43 UTC
[empire-db] branch master updated: EMPIREDB-353 DBCommand delete
with joins implementation (default syntax taken from SQL Server)
This is an automated email from the ASF dual-hosted git repository.
doebele pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/empire-db.git
The following commit(s) were added to refs/heads/master by this push:
new e4d6b4a EMPIREDB-353 DBCommand delete with joins implementation (default syntax taken from SQL Server)
new d2baf68 Merge branch 'master' of https://gitbox.apache.org/repos/asf/empire-db
e4d6b4a is described below
commit e4d6b4aacd1f48d88954de6ce114b626cdeb8399
Author: Rainer Döbele <do...@apache.org>
AuthorDate: Wed May 19 23:08:58 2021 +0200
EMPIREDB-353
DBCommand delete with joins implementation (default syntax taken from SQL Server)
---
.../main/java/org/apache/empire/db/DBCommand.java | 23 +++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBCommand.java b/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
index 96feebe..5311311 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
@@ -1270,13 +1270,22 @@ public abstract class DBCommand extends DBCommandExpr
public synchronized String getDelete(DBTable table)
{
resetParamUsage();
- StringBuilder buf = new StringBuilder("DELETE FROM ");
- table.addSQL(buf, CTX_FULLNAME);
- // Set Expressions
- if (where!=null && !where.isEmpty())
- { // add where condition
- buf.append("\r\nWHERE ");
- addListExpr(buf, where, CTX_NAME|CTX_VALUE, " AND ");
+ StringBuilder buf = new StringBuilder("DELETE ");
+ // joins or simple
+ if (joins!=null && !joins.isEmpty())
+ { // delete with joins
+ table.addSQL(buf, CTX_FULLNAME);
+ // From clause
+ addFrom(buf);
+ // Add Where
+ addWhere(buf, CTX_DEFAULT);
+ }
+ else
+ { // Simple Statement
+ buf.append("FROM ");
+ table.addSQL(buf, CTX_FULLNAME);
+ // where
+ addWhere(buf, CTX_NAME|CTX_VALUE);
}
return buf.toString();
}