Closed gavinking closed 12 months ago
Please see proposal https://github.com/jakartaee/persistence/pull/427, which clarifies section 4.6.1, and introduces proper support for BigInteger
and BigDecimal
literals.
does "use numeric promotion" mean that this is an integer division or is it promoted to float? Or to double?
Actually I guess this is sort of covered by section 4.8.6, though that section should be generalized to apply not only to the select
clause.
The specification leaves the implementor guessing as to the semantics of numeric expression, and the type assigned to numeric literals.
§4.6.17.1 lists the arithmetic operators and says:
§4.6.1 says:
But this leaves a lot unspecified. For example, what type does the following query return:
Double
?Float
?BigDecimal
?Worse, what value does this query return:
That is, does "use numeric promotion" mean that this is an integer division or is it promoted to float? Or to double? (Note that different SQL databases disagree on this question.)
I propose that we nail this stuff down by simply saying that:
1/2
is integer division),BigInteger
orBigDecimal
, (b)BigInteger
may be widened toBigDecimal
, and (c) floating point types may be widened toBigDecimal
.Actually, I'm not completely clear on whether FP types should be widened to
BigDecimal
, but I'm thinking they should be, simply because that's something every SQL database allows.