From b73dd6e65c096433b9d86f976cbca8b055ec0d4a Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Thu, 25 Feb 2021 15:51:19 +0100 Subject: [PATCH] [jOOQ/jOOQ#11043] NullPointerException when parsing WITH .. INSERT .. SELECT without explicit INSERT column list --- .../main/java/org/jooq/impl/InsertImpl.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/InsertImpl.java b/jOOQ/src/main/java/org/jooq/impl/InsertImpl.java index 217eafd789..67e73cfa8c 100644 --- a/jOOQ/src/main/java/org/jooq/impl/InsertImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/InsertImpl.java @@ -42,12 +42,11 @@ import static org.jooq.impl.DSL.exists; import static org.jooq.impl.DSL.not; import static org.jooq.impl.DSL.notExists; import static org.jooq.impl.Tools.EMPTY_FIELD; -import static org.jooq.impl.Tools.filterOne; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.Map; -import java.util.Optional; import org.jooq.Condition; import org.jooq.Configuration; @@ -196,13 +195,13 @@ final class InsertImpl into) { - super(new InsertQueryImpl<>(configuration, with, into)); - - this.into = into; + this(configuration, with, into, Collections.emptyList()); } InsertImpl(Configuration configuration, WithImpl with, Table into, Collection> fields) { - this(configuration, with, into); + super(new InsertQueryImpl<>(configuration, with, into)); + + this.into = into; columns(fields); } @@ -790,11 +789,11 @@ final class InsertImpl 0 && fields.length != values.length) + else if (!Tools.isEmpty(fields) && fields.length != values.length) throw new IllegalArgumentException("The number of values must match the number of fields"); getDelegate().newRecord(); - if (fields.length == 0) + if (Tools.isEmpty(fields)) for (int i = 0; i < values.length; i++) addValue(getDelegate(), null, i, values[i]); else @@ -944,13 +943,13 @@ final class InsertImpl 0 && fields.length != values.length) + else if (!Tools.isEmpty(fields) && fields.length != values.length) throw new IllegalArgumentException("The number of values must match the number of fields"); getDelegate().newRecord(); // javac has trouble when inferring Object for T. Use Void instead - if (fields.length == 0) + if (Tools.isEmpty(fields)) for (int i = 0; i < values.length; i++) addValue(getDelegate(), (Field) null, i, (Field) values[i]); else @@ -1094,7 +1093,7 @@ final class InsertImpl... f) { - this.fields = (f == null || f.length == 0) ? into.fields() : f; + this.fields = Tools.isEmpty(f) ? into.fields() : f; return this; }