db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r488098 - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/platform/ java/org/apache/ddlutils/platform/postgresql/ test/org/apache/ddlutils/io/
Date Mon, 18 Dec 2006 01:43:45 GMT
Author: tomdz
Date: Sun Dec 17 17:43:44 2006
New Revision: 488098

URL: http://svn.apache.org/viewvc?view=rev&rev=488098
Log:
Fixed PostgreSQL character unescaping
Fixed a small bug in the handling of escaped single quote characters
Made misc tests more robust
Simplified datatype tests using the new DatabaseDataIO class

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/JdbcModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlModelReader.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatatypes.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestMisc.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/JdbcModelReader.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/JdbcModelReader.java?view=diff&rev=488098&r1=488097&r2=488098
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/JdbcModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/JdbcModelReader.java Sun Dec 17
17:43:44 2006
@@ -1096,7 +1096,7 @@
         {
             if (escaped.equals("''"))
             {
-                if ((result.length() >= 2) && result.startsWith("'") &&
result.endsWith("'"))
+                if ((result.length() > 2) && result.startsWith("'") &&
result.endsWith("'"))
                 {
                     result = "'" + StringUtils.replace(result.substring(1, result.length()
- 1), escaped, unescaped) + "'";
                 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlModelReader.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlModelReader.java?view=diff&rev=488098&r1=488097&r2=488098
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlModelReader.java
(original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlModelReader.java
Sun Dec 17 17:43:44 2006
@@ -153,7 +153,7 @@
                 }
                 if (TypeMap.isTextType(column.getTypeCode()))
                 {
-                    defaultValue = unescape(defaultValue, "'", "\\'");
+                    defaultValue = unescape(defaultValue, "'", "''");
                 }
             }
             column.setDefaultValue(defaultValue);

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatatypes.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatatypes.java?view=diff&rev=488098&r1=488097&r2=488098
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatatypes.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestDatatypes.java Sun Dec 17 17:43:44
2006
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import java.io.Reader;
 import java.io.StringReader;
 import java.io.StringWriter;
 import java.math.BigDecimal;
@@ -30,11 +31,10 @@
 import java.util.List;
 import java.util.TreeSet;
 
-import org.apache.ddlutils.model.Database;
-import org.apache.ddlutils.model.Table;
-
 import junit.framework.Test;
 
+import org.apache.ddlutils.model.Database;
+
 /**
  * Performs roundtrip datatype tests.
  * 
@@ -118,17 +118,10 @@
         assertEquals("",
         		     alterTablesSql);
 
-        StringWriter stringWriter = new StringWriter();
-        DataWriter   dataWriter   = new DataWriter(stringWriter, "UTF-8");
+        StringWriter   stringWriter = new StringWriter();
+        DatabaseDataIO dataIO       = new DatabaseDataIO();
 
-        dataWriter.writeDocumentStart();
-        for (int idx = 0; idx < getModel().getTableCount(); idx++)
-        {
-            Table table = getModel().getTable(idx);
-
-            dataWriter.write(getPlatform().query(getModel(), getSelectQueryForAllString(table),
new Table[] { table }));
-        }
-        dataWriter.writeDocumentEnd();
+        dataIO.writeDataToXML(getPlatform(), stringWriter, "UTF-8");
 
         String dataSql = stringWriter.toString();
         
@@ -138,26 +131,7 @@
 
         createDatabase(modelXml);
 
-        DataToDatabaseSink sink   = new DataToDatabaseSink(getPlatform(), getModel());
-        DataReader         reader = new DataReader();
-
-        sink.setEnsureForeignKeyOrder(true);
-        sink.setUseBatchMode(false);
-        reader.setModel(getModel());
-        reader.setSink(sink);
-        sink.start();
-        try
-        {
-            reader.parse(new StringReader(dataSql));
-        }
-        catch (Exception ex)
-        {
-            throw new RuntimeException(ex);
-        }
-        finally
-        {
-            sink.end();
-        }
+        dataIO.writeDataToDatabase(getPlatform(), new Reader[] { new StringReader(dataSql)
});
 
         beans = getRows("roundtrip");
 

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestMisc.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestMisc.java?view=diff&rev=488098&r1=488097&r2=488098
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestMisc.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestMisc.java Sun Dec 17 17:43:44 2006
@@ -94,11 +94,11 @@
         SAXReader reader    = new SAXReader();
         Document  testDoc   = reader.read(new InputSource(new StringReader(dataAsXml)));
 
-        if (getPlatform().isDelimitedIdentifierModeOn())
-        {
-            List misc1Rows = testDoc.selectNodes("//misc1");
-            List misc2Rows = testDoc.selectNodes("//misc2");
+        List misc1Rows = testDoc.selectNodes("//misc1");
+        List misc2Rows = testDoc.selectNodes("//misc2");
 
+        if (misc1Rows.size() > 0)
+        {
             assertEquals(3, misc1Rows.size());
             assertEquals("10", ((Element)misc1Rows.get(0)).attributeValue("pk"));
             assertEquals("1",  ((Element)misc1Rows.get(0)).attributeValue("avalue"));
@@ -114,8 +114,8 @@
         }
         else
         {
-            List misc1Rows = testDoc.selectNodes("//MISC1");
-            List misc2Rows = testDoc.selectNodes("//MISC2");
+            misc1Rows = testDoc.selectNodes("//MISC1");
+            misc2Rows = testDoc.selectNodes("//MISC2");
 
             assertEquals(3, misc1Rows.size());
             assertEquals("10", ((Element)misc1Rows.get(0)).attributeValue("PK"));
@@ -202,11 +202,11 @@
         SAXReader reader    = new SAXReader();
         Document  testDoc   = reader.read(new InputSource(new StringReader(dataAsXml)));
 
-        if (getPlatform().isDelimitedIdentifierModeOn())
-        {
-            List misc1Rows = testDoc.selectNodes("//misc1");
-            List misc2Rows = testDoc.selectNodes("//misc2");
+        List misc1Rows = testDoc.selectNodes("//misc1");
+        List misc2Rows = testDoc.selectNodes("//misc2");
 
+        if (misc1Rows.size() > 0)
+        {
             assertEquals(3, misc1Rows.size());
             assertEquals("10", ((Element)misc1Rows.get(0)).attributeValue("pk"));
             assertEquals("1",  ((Element)misc1Rows.get(0)).attributeValue("avalue"));
@@ -222,8 +222,8 @@
         }
         else
         {
-            List misc1Rows = testDoc.selectNodes("//MISC1");
-            List misc2Rows = testDoc.selectNodes("//MISC2");
+            misc1Rows = testDoc.selectNodes("//MISC1");
+            misc2Rows = testDoc.selectNodes("//MISC2");
 
             assertEquals(3, misc1Rows.size());
             assertEquals("10", ((Element)misc1Rows.get(0)).attributeValue("PK"));



Mime
View raw message