diff --git a/jOOQ/src/main/java/org/jooq/impl/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index b4d9cf677a..bc85c599a5 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -18206,6 +18206,38 @@ public class DSL { return new XMLAttributesImpl(attributes); } + /** + * The XML processing instruction constructor. + */ + @Support({ POSTGRES }) + public static Field xmlpi(String target) { + return xmlpi(name(target), null); + } + + /** + * The XML processing instruction constructor. + */ + @Support({ POSTGRES }) + public static Field xmlpi(Name target) { + return xmlpi(target, null); + } + + /** + * The XML processing instruction constructor. + */ + @Support({ POSTGRES }) + public static Field xmlpi(String target, Field content) { + return xmlpi(name(target), content); + } + + /** + * The XML processing instruction constructor. + */ + @Support({ POSTGRES }) + public static Field xmlpi(Name target, Field content) { + return new XMLPI(target, content); + } + // ------------------------------------------------------------------------- // XXX JSON functions // ------------------------------------------------------------------------- diff --git a/jOOQ/src/main/java/org/jooq/impl/Keywords.java b/jOOQ/src/main/java/org/jooq/impl/Keywords.java index 63827ed4e1..9de9138532 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Keywords.java +++ b/jOOQ/src/main/java/org/jooq/impl/Keywords.java @@ -236,6 +236,7 @@ final class Keywords { static final Keyword K_MODIFY = keyword("modify"); static final Keyword K_MONTH = keyword("month"); static final Keyword K_MULTISET = keyword("multiset"); + static final Keyword K_NAME = keyword("name"); static final Keyword K_NEW_TABLE = keyword("new table"); static final Keyword K_NEXT_VALUE_FOR = keyword("next value for"); static final Keyword K_NEXTVAL = keyword("nextval"); diff --git a/jOOQ/src/main/java/org/jooq/impl/Names.java b/jOOQ/src/main/java/org/jooq/impl/Names.java index b8ecfb6133..d730885eb5 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Names.java +++ b/jOOQ/src/main/java/org/jooq/impl/Names.java @@ -110,7 +110,6 @@ final class Names { static final Name N_MEDIAN = DSL.unquotedName("median"); static final Name N_MOD = DSL.unquotedName("mod"); static final Name N_MODE = DSL.unquotedName("mode"); - static final Name N_NAME = DSL.unquotedName("name"); static final Name N_NEXTVAL = DSL.unquotedName("nextval"); static final Name N_NOT = DSL.unquotedName("not"); static final Name N_NTILE = DSL.unquotedName("ntile"); diff --git a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java index 67fc391dad..9f12787780 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java @@ -295,6 +295,7 @@ import static org.jooq.impl.DSL.xmlattributes; import static org.jooq.impl.DSL.xmlcomment; import static org.jooq.impl.DSL.xmlconcat; import static org.jooq.impl.DSL.xmlelement; +import static org.jooq.impl.DSL.xmlpi; import static org.jooq.impl.DSL.year; import static org.jooq.impl.DSL.zero; import static org.jooq.impl.JSONNullClause.ABSENT_ON_NULL; @@ -6400,6 +6401,8 @@ final class ParserImpl implements Parser { return field; else if ((field = parseFieldXMLElementIf(ctx)) != null) return field; + else if ((field = parseFieldXMLPIIf(ctx)) != null) + return field; break; @@ -6762,6 +6765,24 @@ final class ParserImpl implements Parser { return null; } + private static final Field parseFieldXMLPIIf(ParserContext ctx) { + if (parseFunctionNameIf(ctx, "XMLPI")) { + parse(ctx, '('); + parseKeyword(ctx, "NAME"); + Name target = parseIdentifier(ctx); + Field content = null; + + if (parseIf(ctx, ',')) { + content = parseField(ctx); + } + + parse(ctx, ')'); + return content == null ? xmlpi(target) : xmlpi(target, content); + } + + return null; + } + private static final Field parseFieldJSONArrayConstructorIf(ParserContext ctx) { if (parseFunctionNameIf(ctx, "JSON_ARRAY")) { parse(ctx, '('); diff --git a/jOOQ/src/main/java/org/jooq/impl/XMLElement.java b/jOOQ/src/main/java/org/jooq/impl/XMLElement.java index c215f0e965..4a23549aa0 100644 --- a/jOOQ/src/main/java/org/jooq/impl/XMLElement.java +++ b/jOOQ/src/main/java/org/jooq/impl/XMLElement.java @@ -37,7 +37,7 @@ */ package org.jooq.impl; -import static org.jooq.impl.Names.N_NAME; +import static org.jooq.impl.Keywords.K_NAME; import static org.jooq.impl.Names.N_XMLCONCAT; import static org.jooq.impl.Names.N_XMLELEMENT; @@ -73,7 +73,7 @@ final class XMLElement extends AbstractField { @Override public final void accept(Context ctx) { ctx.visit(N_XMLELEMENT).sql('('); - ctx.visit(N_NAME).sql(' ').visit(elementName); + ctx.visit(K_NAME).sql(' ').visit(elementName); if (attributes != null && !((XMLAttributesImpl) attributes).attributes.isEmpty()) ctx.sql(',').formatSeparator().visit(attributes); diff --git a/jOOQ/src/main/java/org/jooq/impl/XMLPI.java b/jOOQ/src/main/java/org/jooq/impl/XMLPI.java new file mode 100644 index 0000000000..b267aa9a63 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/XMLPI.java @@ -0,0 +1,77 @@ +/* + * 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.impl.Keywords.K_NAME; +import static org.jooq.impl.Names.N_XMLPI; + +import org.jooq.Context; +import org.jooq.Field; +import org.jooq.Name; +import org.jooq.XML; + +/** + * @author Lukas Eder + */ +final class XMLPI extends AbstractField { + + /** + * Generated UID + */ + private static final long serialVersionUID = 4505809303211506197L; + + private final Name target; + private final Field content; + + XMLPI(Name target, Field content) { + super(N_XMLPI, SQLDataType.XML); + + this.target = target; + this.content = content; + } + + @Override + public final void accept(Context ctx) { + ctx.visit(N_XMLPI).sql('(').visit(K_NAME).sql(' ').visit(target.unquotedName()); + + if (content != null) + ctx.sql(", ").visit(content); + + ctx.sql(')'); + } +}