Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H2Engine, IndexOutOfBoundsException when translating an empty list #38

Open
jprafael opened this issue Jun 22, 2016 · 1 comment
Open

Comments

@jprafael
Copy link

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
Copy link

HiuKwok commented Apr 21, 2020

I think this can be fixed by either following:

With either for each, see CockroachDB implementation:

for (final Expression expression : rd.getExpressions()) {

Or Stream, see MySql implementation:

final List<Object> all = rd.getExpressions().stream()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants