Ok, I have been reviewing Oracle docs, and simplified
my proposed changes. Oracle documents the following:
/*
* This is for Oracle, it may be valid for other DBs:
*
* NUMBER(p): fixed point (integer), precision p (p digits).
* NUMBER(p,s): floating point (real), precision p, scale s.
* NUMBER is the same as NUMBER(38,0) (and is floating point!).
* INT seems to be the same as NUMBER, except with scale 0,
* and is fixed point.
* FLOAT(x): it seems x is ignored, and is always (even with
* FLOAT) taken to be 22. This is documented as a
* floating point, precision 38. One would think
* this is the same as NUMBER, but I'm not sure.
* REAL: same as FLOAT.
* DECIMAL: same as FLOAT.
*/
Here's what I propose:
* Use either BigInteger or BigDecimal to begin with, until someone
provides the cutting values for int, long, float, double, etc.
(Who? [let me guess... me?], How?).
* Use this algorithm:
else if (tn.indexOf ("INT") != -1)
{
torqueType = "INTEGER";
columnType = new java.math.BigInteger (0);
}
else if (tn.indexOf ("FLOAT") != -1 ||
tn.indexOf ("REAL") != -1 ||
tn.indexOf ("DECIMAL") != -1)
{
torqueType = "FLOAT";
columnType = new java.math.BigDecimal (0);
}
else if (tn.indexOf ("NUMBER") != -1)
{
// If there is no "(x,y)", or there is one with a ',' in
// it, we assume this is a floating point value.
// We use BigDecimal always, it would be nice to be able
// to use Float, Double or BigDecimal depending on the
// values of x and y.
if (size.length() <= 0 ||
size.indexOf(",") != -1)
{
torqueType = "FLOAT";
columnType = new java.math.BigDecimal (0);
}
// There must be an "(x)" specification, we assume it is a
// fixed point value.
// We use BigInteger always, it would be nice to be able
// to use int, long or BigInteger depending on the values
// of x.
else
{
torqueType = "INTEGER";
columnType = new java.math.BigInteger (0);
}
}
Thoughts? I could commit this myself if there are no opposing
views on the way to handle this.
--
Gonzalo A. Diethelm
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]