I reviewed the way torque is supposed to handle a numeric field
with decimals, and either I don't understand it or it is wrong...
This is on SQLToAppData.java:417:

         Column col = new Column (columnName);
         if (columnPrecision != null)
            columnSize = columnSize + columnPrecision;

>From what I read, if the field is specified as NUMBER(10,2),
columnSize will end up being "102". Which doesn't really make
much of a difference, since Column.java:651 doesn't really
pay much attention to columnSize... I'm attaching my patch
for someone to check it before I commit it into cvs. Any
comments? Thanks,



Index: model/Column.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/engine/database
/model/Column.java,v
retrieving revision 1.3.10.7
diff -u -w -r1.3.10.7 Column.java
--- model/Column.java   2001/06/04 23:53:28     1.3.10.7
+++ model/Column.java   2001/07/04 17:27:50
@@ -648,11 +648,25 @@
             torqueType = "VARCHAR";
             columnType = "";
         }
-        else if (tn.indexOf ("INT") != -1)
+        else if (tn.indexOf ("INT") != -1 ||
+                 tn.indexOf ("NUMBER") != -1)
         {
+            if (size.indexOf(",") != -1)
+            {
+                torqueType = "FLOAT";
+                columnType = new Float (0);
+            }
+            else if (size.length() > 1)
+            {
+                torqueType = "NUMERIC";
+                columnType = new java.math.BigDecimal (0);
+            }
+            else
+            {
             torqueType = "INTEGER";
             columnType = new Integer (0);
         }
+        }
         else if (tn.indexOf ("FLOAT") != -1)
         {
             torqueType = "FLOAT";
Index: transform/SQLToAppData.java
===================================================================
RCS file:
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/engine/database
/transform/SQLToAppData.java,v
retrieving revision 1.3.10.8
diff -u -w -r1.3.10.8 SQLToAppData.java
--- transform/SQLToAppData.java 2001/06/04 23:53:29     1.3.10.8
+++ transform/SQLToAppData.java 2001/07/04 17:27:51
@@ -415,7 +415,7 @@
 
         Column col = new Column (columnName);
         if (columnPrecision != null)
-            columnSize = columnSize + columnPrecision;
+            columnSize = (columnSize + "," + columnPrecision);
         col.setTypeFromString (columnType,columnSize);
         tbl.addColumn (col);
         



-- 
Gonzalo A. Diethelm
[EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to