diff --git a/jOOQ/src/main/java/org/jooq/impl/JSONEntryImpl.java b/jOOQ/src/main/java/org/jooq/impl/JSONEntryImpl.java index 98c79519be..f30fc7c941 100644 --- a/jOOQ/src/main/java/org/jooq/impl/JSONEntryImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/JSONEntryImpl.java @@ -46,6 +46,7 @@ import static org.jooq.impl.Keywords.K_JSON; import static org.jooq.impl.Keywords.K_KEY; import static org.jooq.impl.Keywords.K_VALUE; import static org.jooq.impl.SQLDataType.VARCHAR; +import static org.jooq.impl.Tools.inlined; import java.util.UUID; @@ -129,7 +130,7 @@ final class JSONEntryImpl extends AbstractQueryPart implements JSONEntry, case MARIADB: case MYSQL: case POSTGRES: - ctx.visit(key).sql(", ").visit(value); + ctx.visit(key).sql(", ").visit(jsonCast(ctx, value)); break; default: @@ -159,6 +160,10 @@ final class JSONEntryImpl extends AbstractQueryPart implements JSONEntry, break; + // [#11025] These don't have boolean support outside of JSON + case MYSQL: + if (type.getType() == Boolean.class) + return inlined(field); diff --git a/jOOQ/src/main/java/org/jooq/impl/JSONValue.java b/jOOQ/src/main/java/org/jooq/impl/JSONValue.java index 21aa55cb21..9295363e42 100644 --- a/jOOQ/src/main/java/org/jooq/impl/JSONValue.java +++ b/jOOQ/src/main/java/org/jooq/impl/JSONValue.java @@ -50,6 +50,7 @@ import static org.jooq.impl.Names.N_JSON_EXTRACT; import static org.jooq.impl.Names.N_JSON_VALUE; import static org.jooq.impl.SQLDataType.JSONB; import static org.jooq.impl.Tools.castIfNeeded; +import static org.jooq.impl.Tools.inlined; import java.util.Set; diff --git a/jOOQ/src/main/java/org/jooq/impl/PositionalWindowFunction.java b/jOOQ/src/main/java/org/jooq/impl/PositionalWindowFunction.java index 324a56224c..47905955d9 100644 --- a/jOOQ/src/main/java/org/jooq/impl/PositionalWindowFunction.java +++ b/jOOQ/src/main/java/org/jooq/impl/PositionalWindowFunction.java @@ -38,6 +38,7 @@ package org.jooq.impl; import static org.jooq.impl.Keywords.K_COALESCE; +import static org.jooq.impl.Tools.inlined; import org.jooq.Context; import org.jooq.Field; diff --git a/jOOQ/src/main/java/org/jooq/impl/SQLInline.java b/jOOQ/src/main/java/org/jooq/impl/SQLInline.java deleted file mode 100644 index c09c8a83b1..0000000000 --- a/jOOQ/src/main/java/org/jooq/impl/SQLInline.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Other licenses: - * ----------------------------------------------------------------------------- - * Commercial licenses for this work are available. These replace the above - * ASL 2.0 and offer limited warranties, support, maintenance, and commercial - * database integrations. - * - * For more information, please visit: http://www.jooq.org/licenses - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */ -package org.jooq.impl; - -import static org.jooq.conf.ParamType.INLINED; - -import org.jooq.Context; -import org.jooq.QueryPart; -import org.jooq.SQL; -import org.jooq.conf.ParamType; - -/** - * @author Lukas Eder - */ -final class SQLInline extends AbstractQueryPart implements SQL { - - /** - * Generated UID - */ - private static final long serialVersionUID = 5352233054249655126L; - - private QueryPart sql; - - SQLInline(QueryPart part) { - this.sql = part; - } - - SQLInline(SQL sql) { - this.sql = sql; - } - - @Override - public final void accept(Context ctx) { - ParamType paramType = ctx.paramType(); - - ctx.paramType(INLINED) - .visit(sql) - .paramType(paramType); - } - - @Override - public String toString() { - return sql.toString(); - } -} diff --git a/jOOQ/src/main/java/org/jooq/impl/Tools.java b/jOOQ/src/main/java/org/jooq/impl/Tools.java index 8987fe9a6a..d424e4791e 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Tools.java +++ b/jOOQ/src/main/java/org/jooq/impl/Tools.java @@ -276,6 +276,7 @@ import org.jooq.UDTRecord; import org.jooq.UpdatableRecord; import org.jooq.XML; import org.jooq.conf.BackslashEscaping; +import org.jooq.conf.ParamType; import org.jooq.conf.ParseNameCase; import org.jooq.conf.RenderDefaultNullability; import org.jooq.conf.Settings; @@ -1960,6 +1961,20 @@ final class Tools { return result; } + @SuppressWarnings("serial") + static final Field inlined(final Field field) { + return new CustomField(field.getQualifiedName(), field.getDataType()) { + @Override + public void accept(Context ctx) { + ParamType previous = ctx.paramType(); + + ctx.paramType(INLINED); + ctx.visit(field); + ctx.paramType(previous); + } + }; + } + static final IllegalArgumentException indexFail(Row row, Field field) { return new IllegalArgumentException("Field (" + field + ") is not contained in Row " + row); } diff --git a/jOOQ/src/main/java/org/jooq/impl/XMLTable.java b/jOOQ/src/main/java/org/jooq/impl/XMLTable.java index bd20f34671..c41e8a1663 100644 --- a/jOOQ/src/main/java/org/jooq/impl/XMLTable.java +++ b/jOOQ/src/main/java/org/jooq/impl/XMLTable.java @@ -56,6 +56,7 @@ import static org.jooq.impl.Keywords.K_VALUE; import static org.jooq.impl.Keywords.K_XMLTABLE; import static org.jooq.impl.Names.N_XMLTABLE; import static org.jooq.impl.SQLDataType.XML; +import static org.jooq.impl.Tools.inlined; import static org.jooq.impl.Tools.visitSubquery; import static org.jooq.impl.XMLPassingMechanism.BY_REF; import static org.jooq.impl.XMLPassingMechanism.BY_VALUE;