Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,12 @@ default void visit(JsonFunction jsonFunction) {
this.visit(jsonFunction, null);
}

<S> T visit(JsonTable jsonTable, S context);

default void visit(JsonTable jsonTable) {
this.visit(jsonTable, null);
}

<S> T visit(ConnectByRootOperator connectByRootOperator, S context);

default void visit(ConnectByRootOperator connectByRootOperator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,12 @@ public <S> T visit(JsonFunction jsonFunction, S context) {
return visitExpressions(jsonFunction, context, subExpressions);
}

@Override
public <S> T visit(JsonTable jsonTable, S context) {
// TODO: Implement
return null;
}

@Override
public <S> T visit(ConnectByRootOperator connectByRootOperator, S context) {
return connectByRootOperator.getColumn().accept(this, context);
Expand Down
48 changes: 48 additions & 0 deletions src/main/java/net/sf/jsqlparser/expression/JsonOnEmptyType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*-
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2021 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
/*
* Copyright (C) 2021 JSQLParser.
*
* This library is free software; you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the Free Software Foundation; either version
* 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library;
* if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/

package net.sf.jsqlparser.expression;

/**
*
*/
public enum JsonOnEmptyType {
ERROR("ERROR"), NULL("NULL"), EMPTY("EMPTY"), EMPTY_ARRAY("EMPTY ARRAY"), EMPTY_OBJECT(
"EMPTY OBJECT"), TRUE("TRUE"), FALSE("FALSE"), DEFAULT("DEFAULT");

private final String value;

JsonOnEmptyType(String value) {
this.value = value;
}

public String getValue() {
return value;
}

public static JsonOnEmptyType from(String type) {
return Enum.valueOf(JsonOnEmptyType.class, type.toUpperCase());
}
}
48 changes: 48 additions & 0 deletions src/main/java/net/sf/jsqlparser/expression/JsonOnErrorType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*-
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2021 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
/*
* Copyright (C) 2021 JSQLParser.
*
* This library is free software; you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the Free Software Foundation; either version
* 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library;
* if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/

package net.sf.jsqlparser.expression;

/**
*
*/
public enum JsonOnErrorType {
ERROR("ERROR"), NULL("NULL"), EMPTY("EMPTY"), EMPTY_ARRAY("EMPTY ARRAY"), EMPTY_OBJECT(
"EMPTY OBJECT"), TRUE("TRUE"), FALSE("FALSE"), DEFAULT("DEFAULT");

private final String value;

JsonOnErrorType(String value) {
this.value = value;
}

public String getValue() {
return value;
}

public static JsonOnErrorType from(String type) {
return Enum.valueOf(JsonOnErrorType.class, type.toUpperCase());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*-
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2021 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
/*
* Copyright (C) 2021 JSQLParser.
*
* This library is free software; you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the Free Software Foundation; either version
* 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library;
* if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/

package net.sf.jsqlparser.expression;

/**
*
*/
public enum JsonQueryWrapperType {
WITHOUT_WRAPPER("WITHOUT WRAPPER"), WITHOUT_ARRAY_WRAPPER(
"WITHOUT ARRAY WRAPPER"), WITH_WRAPPER("WITH WRAPPER"), WITH_ARRAY_WRAPPER(
"WITH ARRAY WRAPPER"), WITH_UNCONDITIONAL_WRAPPER(
"WITH UNCONDITIONAL WRAPPER"), WITH_UNCONDITIONAL_ARRAY_WRAPPER(
"WITH UNCONDITIONAL ARRAY WRAPPER"), WITH_CONDITIONAL_WRAPPER(
"WITH CONDITIONAL WRAPPER"), WITH_CONDITIONAL_ARRAY_WRAPPER(
"WITH CONDITIONAL ARRAY WRAPPER");

private final String value;

JsonQueryWrapperType(String value) {
this.value = value;
}

public String getValue() {
return value;
}

public static JsonQueryWrapperType from(String type) {
return Enum.valueOf(JsonQueryWrapperType.class, type.toUpperCase());
}

public static JsonQueryWrapperType fromWithParts(boolean isArray, boolean isConditional,
boolean isUnconditional) {
if (isArray) {
if (isConditional) {
return JsonQueryWrapperType.WITH_CONDITIONAL_ARRAY_WRAPPER;
} else if (isUnconditional) {
return JsonQueryWrapperType.WITH_UNCONDITIONAL_ARRAY_WRAPPER;
} else {
return JsonQueryWrapperType.WITH_ARRAY_WRAPPER;
}
} else {
if (isConditional) {
return JsonQueryWrapperType.WITH_CONDITIONAL_WRAPPER;
} else if (isUnconditional) {
return JsonQueryWrapperType.WITH_UNCONDITIONAL_WRAPPER;
} else {
return JsonQueryWrapperType.WITH_WRAPPER;
}
}
}
}
71 changes: 71 additions & 0 deletions src/main/java/net/sf/jsqlparser/expression/JsonReturnClause.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package net.sf.jsqlparser.expression;

import net.sf.jsqlparser.parser.ASTNodeAccessImpl;

public class JsonReturnClause extends ASTNodeAccessImpl {

private JsonReturnType type;

private Long varcharSize;

public JsonReturnClause() {}

public JsonReturnClause(JsonReturnType type) {
this.type = type;
}

public JsonReturnType getType() {
return type;
}

public void setType(JsonReturnType type) {
this.type = type;
}

public JsonReturnClause withType(JsonReturnType type) {
setType(type);
return this;
}

public Long getVarcharSize() {
return varcharSize;
}

public void setVarcharSize(Long varcharSize) {
this.varcharSize = varcharSize;
}

public JsonReturnClause withVarcharSize(Long varcharSize) {
setVarcharSize(varcharSize);
return this;
}

public StringBuilder append(StringBuilder builder) {
builder.append(" ");
builder.append(type.getValue());
switch (type) {
case VARCHAR2:
case VARCHAR2_BYTE:
case VARCHAR2_CHAR:
if (varcharSize != null) {
builder.append("(");
builder.append(varcharSize);
switch (type) {
case VARCHAR2_BYTE:
builder.append(" BYTE");
break;
case VARCHAR2_CHAR:
builder.append(" CHAR");
break;
}
builder.append(")");
}
break;
default:
// Nothing to do
break;
}
return builder;
}

}
73 changes: 73 additions & 0 deletions src/main/java/net/sf/jsqlparser/expression/JsonReturnType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*-
* #%L
* JSQLParser library
* %%
* Copyright (C) 2004 - 2021 JSQLParser
* %%
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
* #L%
*/
/*
* Copyright (C) 2021 JSQLParser.
*
* This library is free software; you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the Free Software Foundation; either version
* 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this library;
* if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/

package net.sf.jsqlparser.expression;

/**
*
*/
public enum JsonReturnType {
VARCHAR2("VARCHAR2"), CLOB("CLOB"), BLOB("BLOB"), NUMBER("NUMBER"), DATE("DATE"), TIMESTAMP(
"TIMESTAMP"), TIMESTAMP_WITH_TIMEZONE(
"TIMESTAMP WITH TIMEZONE"), BOOLEAN("BOOLEAN"), VECTOR("VECTOR"), JSON("JSON"),

// VARCHAR2( x BYTE)
VARCHAR2_BYTE("VARCHAR2"),

// VARCHAR2( x CHAR)
VARCHAR2_CHAR("VARCHAR2"),
;

private final String value;

JsonReturnType(String value) {
this.value = value;
}

public String getValue() {
return value;
}

public static JsonReturnType from(String type) {
return Enum.valueOf(JsonReturnType.class, type.toUpperCase());
}

/**
* @see "https://docs.oracle.com/en/database/oracle/oracle-database/26/sqlrf/JSON_QUERY.html#GUID-6D396EC4-D2AA-43D2-8F5D-08D646A4A2D9__CJADJIIJ"
*/
public boolean isValidForJsonQueryReturnType() {
switch (this) {
case VARCHAR2:
case CLOB:
case BLOB:
case JSON:
case VECTOR:
return true;
default:
return false;
}
}

}
Loading
Loading