diff --git a/src/tap/data/ResultSetTableIterator.java b/src/tap/data/ResultSetTableIterator.java index 938e5acce23333925ffcc3bdd99211a6b6304a22..5bcbbfcabcb7936344123a68b7b6acb86aa6239b 100644 --- a/src/tap/data/ResultSetTableIterator.java +++ b/src/tap/data/ResultSetTableIterator.java @@ -706,9 +706,12 @@ public class ResultSetTableIterator implements TableIterator { // if the column value is a Timestamp object, format it in ISO8601: if (colValue instanceof Timestamp) colValue = ISO8601Format.format(((Timestamp)colValue).getTime()); + // if the type is Integer but it is declared as a SMALLINT cast the value (absolutely required for the FITS format): + else if (colValue instanceof Integer && colType != null && colValue != null && colType.type == DBDatatype.SMALLINT) + colValue = new Short(((Integer)colValue).shortValue()); // if the column value is a Boolean object, format it as a SMALLINT: else if (colValue instanceof Boolean) - colValue = ((Boolean)colValue) ? (short)1 : (short)0; + colValue = ((Boolean)colValue) ? new Short((short)1) : new Short((short)0); // if the column should be only a character: else if (colType != null && colValue != null && colType.type == DBDatatype.CHAR && (colType.length == 1 || colType.length <= 0) && colValue instanceof String) colValue = ((String)colValue).charAt(0);