H2Engine, IndexOutOfBoundsException when translating an empty list
Opened this issue · 1 comments
jprafael commented
When using the in(column(...), L(values))
operator, translation crashes with the H2Engine if the values
list is empty.
java.lang.IndexOutOfBoundsException: index (0) must be less than size (0)
at com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:310) ~[guava-18.0.jar:na]
at com.google.common.base.Preconditions.checkElementIndex(Preconditions.java:292) ~[guava-18.0.jar:na]
at com.google.common.collect.RegularImmutableList.get(RegularImmutableList.java:65) ~[guava-18.0.jar:na]
at com.feedzai.commons.sql.abstraction.engine.impl.H2Translator.translate(H2Translator.java:125) ~[pdb-2.1.4.jar:na]
at com.feedzai.commons.sql.abstraction.dml.RepeatDelimiter.translate(RepeatDelimiter.java:148) ~[pdb-2.1.4.jar:na]
at com.feedzai.commons.sql.abstraction.engine.impl.H2Translator.translate(H2Translator.java:138) ~[pdb-2.1.4.jar:na]
at com.feedzai.commons.sql.abstraction.dml.RepeatDelimiter.translate(RepeatDelimiter.java:148) ~[pdb-2.1.4.jar:na]
at com.feedzai.commons.sql.abstraction.engine.AbstractTranslator.translate(AbstractTranslator.java:314) ~[pdb-2.1.4.jar:na]
at com.feedzai.commons.sql.abstraction.dml.Update.translate(Update.java:69) ~[pdb-2.1.4.jar:na]
at com.feedzai.commons.sql.abstraction.engine.AbstractDatabaseEngine.translate(AbstractDatabaseEngine.java:767) ~[pdb-2.1.4.jar:na]
at com.feedzai.commons.sql.abstraction.engine.AbstractDatabaseEngine.executeUpdate(AbstractDatabaseEngine.java:753) ~[pdb-2.1.4.jar:na]
HiuKwok commented
I think this can be fixed by either following:
With either for each
, see CockroachDB implementation:
Or Stream
, see MySql implementation: