mpoeschl 2003/11/02 22:37:27
Modified: src/generator/src/dtd database.dtd
src/generator/src/test/org/apache/torque/engine/database/model
DomainTest.java
src/generator/src/java/org/apache/torque/engine/database/model
Column.java
Log:
add scale to column
Revision Changes Path
1.3 +2 -1 db-torque/src/generator/src/dtd/database.dtd
Index: database.dtd
===================================================================
RCS file: /home/cvs/db-torque/src/generator/src/dtd/database.dtd,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- database.dtd 29 Oct 2003 01:19:10 -0000 1.2
+++ database.dtd 3 Nov 2003 06:37:27 -0000 1.3
@@ -111,6 +111,7 @@
) #IMPLIED
javaType (object|primitive) #IMPLIED
size CDATA #IMPLIED
+ scale CDATA #IMPLIED
default CDATA #IMPLIED
autoIncrement (true|false) "false"
inheritance (single|false) "false"
1.2 +3 -2
db-torque/src/generator/src/test/org/apache/torque/engine/database/model/DomainTest.java
Index: DomainTest.java
===================================================================
RCS file:
/home/cvs/db-torque/src/generator/src/test/org/apache/torque/engine/database/model/DomainTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DomainTest.java 29 Oct 2003 01:19:51 -0000 1.1
+++ DomainTest.java 3 Nov 2003 06:37:27 -0000 1.2
@@ -113,8 +113,9 @@
Column price = table.getColumn("price");
assertEquals("NUMERIC", price.getType());
assertEquals("10", price.getSize());
-// assertEquals("2", price.getScale());
+ assertEquals("2", price.getScale());
assertEquals("0", price.getDefaultValue());
+ assertEquals("(10,2)", price.printSize());
}
}
1.8 +33 -4
db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Column.java
Index: Column.java
===================================================================
RCS file:
/home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Column.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Column.java 29 Oct 2003 01:19:10 -0000 1.7
+++ Column.java 3 Nov 2003 06:37:27 -0000 1.8
@@ -89,6 +89,7 @@
private String javaNamingMethod;
private boolean isNotNull = false;
private String size;
+ private String scale;
/** type as defined in schema.xml */
private String torqueType;
private String javaType;
@@ -167,6 +168,7 @@
if (StringUtils.isNotEmpty(dom)) {
Domain domain = getTable().getDatabase().getDomain(dom);
size = domain.getSize();
+ scale = domain.getScale();
setType(domain.getType());
defaultValue = domain.getDefaultValue();
}
@@ -218,6 +220,7 @@
attrib.getValue("default"), defaultValue);
size = StringUtils.defaultString(attrib.getValue("size"), size);
+ scale = StringUtils.defaultString(attrib.getValue("scale"), scale);
setType(StringUtils.defaultString(attrib.getValue("type"), torqueType));
@@ -227,7 +230,6 @@
this.inputValidator = attrib.getValue("inputValidator");
description = attrib.getValue("description");
-
}
/**
@@ -688,12 +690,39 @@
}
/**
- * Return the size in brackets for use in an sql
+ * Returns the size of the column
+ */
+ public String getScale()
+ {
+ return scale;
+ }
+
+ /**
+ * Set the size of the column
+ */
+ public void setScale(String newScale)
+ {
+ scale = newScale;
+ }
+
+ /**
+ * Return the size and scale in brackets for use in an sql
* schema if the type is String. Otherwise return an empty string
*/
public String printSize()
{
- return (size == null ? "" : '(' + size + ')');
+ if (size != null && scale != null)
+ {
+ return '(' + size + ',' + scale + ')';
+ }
+ else if (size != null)
+ {
+ return '(' + size + ')';
+ }
+ else
+ {
+ return "";
+ }
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]