[jOOQ/jOOQ#9925] Added support for xmlpi
This commit is contained in:
parent
8a70d87a99
commit
b4abf5ada9
@ -18206,6 +18206,38 @@ public class DSL {
|
||||
return new XMLAttributesImpl(attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* The XML processing instruction constructor.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
public static Field<XML> xmlpi(String target) {
|
||||
return xmlpi(name(target), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* The XML processing instruction constructor.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
public static Field<XML> xmlpi(Name target) {
|
||||
return xmlpi(target, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* The XML processing instruction constructor.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
public static Field<XML> xmlpi(String target, Field<?> content) {
|
||||
return xmlpi(name(target), content);
|
||||
}
|
||||
|
||||
/**
|
||||
* The XML processing instruction constructor.
|
||||
*/
|
||||
@Support({ POSTGRES })
|
||||
public static Field<XML> xmlpi(Name target, Field<?> content) {
|
||||
return new XMLPI(target, content);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX JSON functions
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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, '(');
|
||||
|
||||
@ -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<XML> {
|
||||
@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);
|
||||
|
||||
77
jOOQ/src/main/java/org/jooq/impl/XMLPI.java
Normal file
77
jOOQ/src/main/java/org/jooq/impl/XMLPI.java
Normal file
@ -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<XML> {
|
||||
|
||||
/**
|
||||
* 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(')');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user