db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r997969 - /db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/
Date Fri, 17 Sep 2010 03:58:27 GMT
Author: tfischer
Date: Fri Sep 17 03:58:26 2010
New Revision: 997969

URL: http://svn.apache.org/viewvc?rev=997969&view=rev
Log:
Add a method for quoting and escaping text which can then be used in SQL generation

Modified:
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformAxionImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformCloudscapeImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformFactory.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformHypersonicImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformInterbaseImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMsaccessImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSapdbImpl.java
    db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSybaseImpl.java

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/Platform.java
Fri Sep 17 03:58:26 2010
@@ -96,4 +96,14 @@ public interface Platform
      *         "create table" statement.
      */
     boolean createNotNullBeforeAutoincrement();
+
+    /**
+     * Quotes and escapes a string such that it can be used
+     * as literal String value in SQL.
+     *
+     * @param value The string to escape, or null.
+     *
+     * @return the escaped String, not null.
+     */
+    String quoteAndEscape(String value);
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformAxionImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformAxionImpl.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformAxionImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformAxionImpl.java
Fri Sep 17 03:58:26 2010
@@ -60,4 +60,9 @@ public class PlatformAxionImpl extends P
                 SchemaType.VARBINARY,
                 new SqlType("BINARY"));
     }
+
+    protected boolean escapeBackslashes()
+    {
+        return true;
+    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformCloudscapeImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformCloudscapeImpl.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformCloudscapeImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformCloudscapeImpl.java
Fri Sep 17 03:58:26 2010
@@ -81,4 +81,8 @@ public class PlatformCloudscapeImpl exte
         return "DEFAULT AUTOINCREMENT";
     }
 
+    protected boolean escapeBackslashes()
+    {
+        return true;
+    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2400Impl.java
Fri Sep 17 03:58:26 2010
@@ -83,4 +83,9 @@ public class PlatformDb2400Impl extends 
     {
         return 30;
     }
+
+    protected boolean escapeBackslashes()
+    {
+        return true;
+    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDb2Impl.java
Fri Sep 17 03:58:26 2010
@@ -81,4 +81,8 @@ public class PlatformDb2Impl extends Pla
         return "GENERATED ALWAYS AS IDENTITY";
     }
 
+    protected boolean escapeBackslashes()
+    {
+        return true;
+    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDefaultImpl.java
Fri Sep 17 03:58:26 2010
@@ -158,4 +158,27 @@ public class PlatformDefaultImpl impleme
     {
         return true;
     }
+
+    /**
+     * @see Platform#quoteAndEscape(String)
+     */
+    public String quoteAndEscape(String text)
+    {
+        String result = text.replace("'", "''");
+        if (escapeBackslashes())
+        {
+            result = result.replace("\\", "\\\\");
+        }
+        return "'" + result + "'";
+    }
+
+    /**
+     * Returns whether backslashes must be escaped in string literals.
+     *
+     * @return true if backslashes bust be escaped, false otherwise.
+     */
+    protected boolean escapeBackslashes()
+    {
+        return true;
+    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformDerbyImpl.java
Fri Sep 17 03:58:26 2010
@@ -112,4 +112,9 @@ public class PlatformDerbyImpl extends P
             || "BINARY".equals(sqlType) || "VARBINARY".equals(sqlType)
             || "BLOB".equals(sqlType) || "CLOB".equals(sqlType);
     }
+
+    protected boolean escapeBackslashes()
+    {
+        return false;
+    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformFactory.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformFactory.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformFactory.java
Fri Sep 17 03:58:26 2010
@@ -114,4 +114,6 @@ public final class PlatformFactory
     {
         return platforms;
     }
+    
+    
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformHypersonicImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformHypersonicImpl.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformHypersonicImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformHypersonicImpl.java
Fri Sep 17 03:58:26 2010
@@ -85,4 +85,9 @@ public class PlatformHypersonicImpl exte
     {
         return false;
     }
+
+    protected boolean escapeBackslashes()
+    {
+        return false;
+    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformInterbaseImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformInterbaseImpl.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformInterbaseImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformInterbaseImpl.java
Fri Sep 17 03:58:26 2010
@@ -61,4 +61,8 @@ public class PlatformInterbaseImpl exten
                 new SqlType("BLOB"));
     }
 
+    protected boolean escapeBackslashes()
+    {
+        return false;
+    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMsaccessImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMsaccessImpl.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMsaccessImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMsaccessImpl.java
Fri Sep 17 03:58:26 2010
@@ -60,4 +60,9 @@ public class PlatformMsaccessImpl extend
                 SchemaType.LONGVARBINARY,
                 new SqlType("BINARY"));
     }
+
+    protected boolean escapeBackslashes()
+    {
+        return false;
+    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMssqlImpl.java
Fri Sep 17 03:58:26 2010
@@ -100,4 +100,9 @@ public class PlatformMssqlImpl extends P
     {
         return (notNull ? "NOT NULL" : "NULL");
     }
+
+    protected boolean escapeBackslashes()
+    {
+        return false;
+    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformMysqlImpl.java
Fri Sep 17 03:58:26 2010
@@ -87,4 +87,9 @@ public class PlatformMysqlImpl extends P
                 || "BLOB".equals(sqlType) || "MEDIUMBLOB".equals(sqlType)
                 || "LONGBLOB".equals(sqlType));
     }
+
+    protected boolean escapeBackslashes()
+    {
+        return true;
+    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformOracleImpl.java
Fri Sep 17 03:58:26 2010
@@ -114,4 +114,9 @@ public class PlatformOracleImpl extends 
     {
         return "";
     }
+
+    protected boolean escapeBackslashes()
+    {
+        return true;
+    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformPostgresqlImpl.java
Fri Sep 17 03:58:26 2010
@@ -131,4 +131,9 @@ public class PlatformPostgresqlImpl exte
         }
         return true;
     }
+
+    protected boolean escapeBackslashes()
+    {
+        return true;
+    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSapdbImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSapdbImpl.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSapdbImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSapdbImpl.java
Fri Sep 17 03:58:26 2010
@@ -104,4 +104,8 @@ public class PlatformSapdbImpl extends P
         return "DEFAULT SERIAL";
     }
 
+    protected boolean escapeBackslashes()
+    {
+        return false;
+    }
 }

Modified: db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSybaseImpl.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSybaseImpl.java?rev=997969&r1=997968&r2=997969&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSybaseImpl.java
(original)
+++ db/torque/torque4/trunk/torque-templates/src/main/java/org/apache/torque/templates/platform/PlatformSybaseImpl.java
Fri Sep 17 03:58:26 2010
@@ -91,4 +91,9 @@ public class PlatformSybaseImpl extends 
     {
         return (notNull ? "NOT NULL" : "NULL");
     }
+
+    protected boolean escapeBackslashes()
+    {
+        return true;
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message