pdb
pdb copied to clipboard
H2Engine, IndexOutOfBoundsException when translating an empty list
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]
I think this can be fixed by either following: https://github.com/feedzai/pdb/blob/e7364e267518182ecab5da9e6fdc5659fee630f8/src/main/java/com/feedzai/commons/sql/abstraction/engine/impl/H2Translator.java#L126
With either for each
, see CockroachDB implementation:
https://github.com/feedzai/pdb/blob/e7364e267518182ecab5da9e6fdc5659fee630f8/src/main/java/com/feedzai/commons/sql/abstraction/engine/impl/CockroachDBTranslator.java#L114
Or Stream
, see MySql implementation:
https://github.com/feedzai/pdb/blob/e7364e267518182ecab5da9e6fdc5659fee630f8/src/main/java/com/feedzai/commons/sql/abstraction/engine/impl/MySqlTranslator.java#L119