bug in SFieldDouble

Noel Grandin <[email protected]> Fri, 21 May 2010 11:52:22 +0200
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <[email protected]>
Hi

Thanks for a great tool! Using it has been a pleasure.

There is a small bug in SFieldDouble which occurs when you pass a Float
down the call chain
  SRecordInstance#setObject(SFieldMeta field, Object value, boolean
fieldValidate)
  ->convertToDataSetFieldType(Object)

    protected Object convertToDataSetFieldType(Object raw) throws
Exception {
        if (raw instanceof Double)
            return raw;
        if (raw == null)
            return null; // Follows JDBC
        if (raw instanceof Number)
>>            return new Double(((Number) raw).intValue());
        if (raw instanceof String) {
            return Double.parseDouble((String) raw);
        }
        throw new SException.Data("Cannot convert " + raw + " to Double.");
    }

The line I have marked with >> should read
            return new Double(((Number) raw).doubleValue());


Regards, Noel Grandin

Disclaimer: http://www.peralex.com/disclaimer.html