Default mapping for numeric types are incorrect #1194

Closed
robertandrewbain opened this Issue Feb 10, 2015 · 10 comments

Projects

None yet

4 participants

@robertandrewbain
Member

NUMERIC and DECIMAL should map to BigDecimal by default, rather than the current mapping of

17-...,? -> BigDecimal
0-16,? -> Double

which causes non-floating pointing numbers to be mapped to floating points number, which should never be used to represent exact values. See
http://stackoverflow.com/questions/28371179/floating-point-types-returned-in-orm-dsl, http://docs.oracle.com/cd/B19306_01/java.102/b14188/datamap.htm, http://www.cs.mun.ca/~michael/java/jdk1.1.5-docs/guide/jdbc/getstart/mapping.doc.html

@timowest
Member

I agree that this would be valid change and could be applied to the default mappings for numeric types with fractional digits.

@Shredder121 What do you think?

@Shredder121
Member

I also think it is a valid change.
As seen in the second link, NUMERIC and DECIMAL should be mapped to BigDecimal.

@timowest
Member

Ok. I'd still check for the decimal digits though, so the change would be only to get rid of the Double mapping.

@robertandrewbain @Shredder121 Is that ok with you?

@robertandrewbain
Member

@timowest yes, that sounds good.

@Shredder121
Member

Yes that sounds good indeed.

@timowest timowest added this to the 4.0.0 milestone Feb 11, 2015
@timowest timowest added the progress label Feb 12, 2015
@Shredder121 Shredder121 closed this in #1200 Feb 17, 2015
@borislubimov

Hi! In querydsl version 3.2.4 oracle raw NUMBER datatype (without precision and scale) was mapped to Double, but since version 3.3.0 it maps to BigInteger. Current behavior is incorrect because NUMBER datatype stores fixed and floating-point numbers (http://docs.oracle.com/cd/B28359_01/server.111/b28318/datatype.htm#CNCPT1832)
Could you tell, please, if this behavior will be fixed after this update?

@timowest
Member

@borislubimov The behaviour will be fixed in the 3.6.2 and 4.0.0 releases. 3.6.2 will be out at the end of month.

@borislubimov

Thank you for quick reply!

@robertandrewbain
Member

@timowest I've just used querydsl-maven-plugin version 3.6.2 (all querydsl packages are at 3.6.2) to generate-sources against an Oracle database. A NUMBER(13,6) is still mapping to a Double. I believed that the changes made to resolve this bug would have meant that a NUMBER(13,6) would map to a BigDecimal. Am I missing anything obvious?

@timowest
Member
timowest commented Mar 9, 2015

Sorry, the notice above was incorrect, there was only a PR for the 4.* line. Since this change breaks backwards compatibility and the mapping can be easily overriden it was only included in the 4 line.

@timowest timowest removed the progress label Mar 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment