[#3962] The H2 emulation of SHR might produce rounding errors
This commit is contained in:
parent
63e9522cb1
commit
c21dfd2f31
@ -171,10 +171,13 @@ class Expression<T> extends AbstractFunction<T> {
|
||||
|
||||
// Many dialects don't support shifts. Use multiplication/division instead
|
||||
else if (SHL == operator && asList(H2, HSQLDB).contains(family)) {
|
||||
return lhs.mul(DSL.power(two(), rhsAsNumber()));
|
||||
return lhs.mul((Field<? extends Number>) DSL.power(two(), rhsAsNumber()).cast(lhs));
|
||||
}
|
||||
|
||||
// [#3962] This emulation is expensive. If this is emulated, BitCount should
|
||||
// use division instead of SHR directly
|
||||
else if (SHR == operator && asList(H2, HSQLDB).contains(family)) {
|
||||
return lhs.div(DSL.power(two(), rhsAsNumber()));
|
||||
return lhs.div((Field<? extends Number>) DSL.power(two(), rhsAsNumber()).cast(lhs));
|
||||
}
|
||||
|
||||
// Some dialects support shifts as functions
|
||||
|
||||
Loading…
Reference in New Issue
Block a user