empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From der...@apache.org
Subject empire-db git commit: EMPIREDB-184
Date Fri, 22 Jul 2016 09:11:37 GMT
Repository: empire-db
Updated Branches:
  refs/heads/master 94d5807b9 -> 9543cebfa


EMPIREDB-184

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

Branch: refs/heads/master
Commit: 9543cebfa0fa0cc9272dba0fa36ed41c3c95eced
Parents: 94d5807
Author: Jan Glaubitz <jan@glaubitz.org>
Authored: Fri Jul 22 11:02:57 2016 +0200
Committer: Jan Glaubitz <jan@glaubitz.org>
Committed: Fri Jul 22 11:02:57 2016 +0200

----------------------------------------------------------------------
 .../empire/db/mysql/DBDatabaseDriverMySQL.java  | 34 ++++++++++++++++++++
 1 file changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/empire-db/blob/9543cebf/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
----------------------------------------------------------------------
diff --git a/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
b/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
index e2517ab..994c67b 100644
--- a/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
+++ b/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
@@ -716,4 +716,38 @@ public class DBDatabaseDriverMySQL extends DBDatabaseDriver
         ddlGenerator.getDDLScript(type, dbo, script); 
     }
 
+    /** 
+     * this helper function doubles up single quotes for SQL 
+     */
+    @Override
+    protected void appendSQLTextValue(StringBuilder buf, String value)
+    {
+        if (value.indexOf('\'') >= 0)
+        { // a routine to double up single quotes for SQL
+            int len = value.length();
+            for (int i = 0; i < len; i++)
+            {
+                if (value.charAt(i) == '\'')
+                    buf.append("''");
+                else
+                    buf.append(value.charAt(i));
+            }
+        }
+        if (value.indexOf('\\') >= 0)
+        { // a routine to double up backslashes for MySQL
+            int len = value.length();
+            for (int i = 0; i < len; i++)
+            {
+                if (value.charAt(i) == '\\')
+                    buf.append("\\\\");
+                else
+                    buf.append(value.charAt(i));
+            }
+        }
+        else
+        {
+            buf.append(value);
+        }
+    }
+    
 }


Mime
View raw message