@@ -99,8 +99,8 @@ void testExistsColumns(String jsonTableStr) throws JSQLParserException {
9999 "JSON_TABLE(document COLUMNS( val VARCHAR2(240) FORMAT JSON PATH '$.pathTest'))" ,
100100
101101 // These would require adapting ColDataType in Line 10176
102- // "JSON_TABLE(document COLUMNS( val VARCHAR2(500 BYTE) PATH '$.pathTest'))",
103- // "JSON_TABLE(document COLUMNS( val VARCHAR2(100 CHAR) PATH '$.pathTest'))",
102+ // "JSON_TABLE(document COLUMNS( val VARCHAR2(500 BYTE) PATH '$.pathTest'))",
103+ // "JSON_TABLE(document COLUMNS( val VARCHAR2(100 CHAR) PATH '$.pathTest'))",
104104 "JSON_TABLE(document COLUMNS( val VARCHAR2 FORMAT JSON DISALLOW SCALARS WITH UNCONDITIONAL ARRAY WRAPPER PATH '$.pathTest' EMPTY OBJECT ON ERROR))" ,
105105 })
106106 void testQueryColumns (String jsonTableStr ) throws JSQLParserException {
@@ -130,148 +130,158 @@ void testNullOnError() throws JSQLParserException {
130130 String expression = "JSON_TABLE(document NULL ON ERROR COLUMNS( id FOR ORDINALITY))" ;
131131 JsonTableFunction table = parseTable (expression );
132132
133- assertThat (table .getOnErrorClause ().getType ()).isEqualTo (JsonTableFunction .JsonTableOnErrorType .NULL );
133+ assertThat (table .getOnErrorClause ().getType ())
134+ .isEqualTo (JsonTableFunction .JsonTableOnErrorType .NULL );
134135 }
135136
136137 @ Test
137138 void testErrorOnError () throws JSQLParserException {
138139 String expression = "JSON_TABLE(document ERROR ON ERROR COLUMNS( id FOR ORDINALITY))" ;
139- JsonTableFunction table = parseTable (expression );
140+ JsonTableFunction table = parseTable (expression );
140141
141- assertThat (table .getOnErrorClause ().getType ()).isEqualTo (JsonTableFunction .JsonTableOnErrorType .ERROR );
142+ assertThat (table .getOnErrorClause ().getType ())
143+ .isEqualTo (JsonTableFunction .JsonTableOnErrorType .ERROR );
142144 }
143145
144146 @ Test
145147 void testNullOnEmpty () throws JSQLParserException {
146148 String expression = "JSON_TABLE(document NULL ON EMPTY COLUMNS( id FOR ORDINALITY))" ;
147- JsonTableFunction table = parseTable (expression );
149+ JsonTableFunction table = parseTable (expression );
148150
149- assertThat (table .getOnEmptyClause ().getType ()).isEqualTo (JsonTableFunction .JsonTableOnEmptyType .NULL );
151+ assertThat (table .getOnEmptyClause ().getType ())
152+ .isEqualTo (JsonTableFunction .JsonTableOnEmptyType .NULL );
150153 }
151154
152155 @ Test
153156 void testErrorOnEmpty () throws JSQLParserException {
154157 String expression = "JSON_TABLE(document ERROR ON EMPTY COLUMNS( id FOR ORDINALITY))" ;
155158 JsonTableFunction table = parseTable (expression );
156159
157- assertThat (table .getOnEmptyClause ().getType ()).isEqualTo (JsonTableFunction .JsonTableOnEmptyType .ERROR );
160+ assertThat (table .getOnEmptyClause ().getType ())
161+ .isEqualTo (JsonTableFunction .JsonTableOnEmptyType .ERROR );
158162 }
159163
160164 @ Test
161165 void testParsingTypeLax () throws JSQLParserException {
162166 String expression = "JSON_TABLE(document TYPE(LAX) COLUMNS( id FOR ORDINALITY))" ;
163167 JsonTableFunction table = parseTable (expression );
164168
165- assertThat (table .getParsingTypeClause ().getType ()).isEqualTo (JsonTableFunction .JsonTableParsingType .LAX );
169+ assertThat (table .getParsingTypeClause ().getType ())
170+ .isEqualTo (JsonTableFunction .JsonTableParsingType .LAX );
166171 }
167172
168173 @ Test
169174 void testParsingTypeStrict () throws JSQLParserException {
170175 String expression = "JSON_TABLE(document TYPE(STRICT) COLUMNS( id FOR ORDINALITY))" ;
171176 JsonTableFunction table = parseTable (expression );
172177
173- assertThat (table .getParsingTypeClause ().getType ()).isEqualTo (JsonTableFunction .JsonTableParsingType .STRICT );
178+ assertThat (table .getParsingTypeClause ().getType ())
179+ .isEqualTo (JsonTableFunction .JsonTableParsingType .STRICT );
174180 }
175181
176- // @Test
177- // void testColumnTypeExists() throws JSQLParserException {
178- // String expression = "JSON_TABLE(document COLUMNS( hasValue EXISTS PATH '$.pathTest'))";
179- // JsonTableFunction table = parseTable(expression);
180- //
181- // assertThat(table.getColumnsClause().getColumnDefinitions()).hasSize(1);
182- //
183- // JsonTableFunction.JsonTableColumnDefinition col = table.getColumnsClause().getColumnDefinitions().get(0);
184- // assertThat(col.getType()).isEqualTo(JsonTableColumnType.JSON_EXISTS);
185- // }
186-
187- // @Test
188- // void testBuilder() {
189- // Column c = new Column("document");
190- //
191- // JsonTable table = new JsonTable().withExpression(c)
192- // .withPathExpression("$.subPath")
193- // .withFormatJson(true)
194- // .withType(JsonTableType.STRICT)
195- // .withOnEmptyType(JsonOnEmptyType.NULL)
196- // .withOnErrorType(JsonOnErrorType.ERROR)
197- // .withColumn(new JsonTableColumn().withName("id")
198- // .withType(JsonTableColumnType.ORDINALITY));
199- //
200- // assertThat(table.toString()).isEqualTo(
201- // "JSON_TABLE(document FORMAT JSON, '$.subPath' ERROR ON ERROR TYPE(STRICT) NULL ON EMPTY COLUMNS(id FOR ORDINALITY))");
202- // }
203-
204- // @Test
205- // void testValidSetters() {
206- // JsonTableFunction table = new JsonTableFunction();
207- //
208- // JsonTableFunction.JsonTableOnEmptyClause onEmptyClause = new JsonTableFunction.JsonTableOnEmptyClause();
209- // JsonTableFunction.JsonTableOnErrorClause onErrorClause = new JsonTableFunction.JsonTableOnErrorClause(true);
210- //
211- // assertThatNoException().isThrownBy(() -> {
212- // table.setOnEmptyClause(null);
213- // onEmptyClause.setType(JsonTableFunction.JsonTableOnEmptyType.NULL);
214- // onEmptyClause.setType(JsonTableFunction.JsonTableOnEmptyType.ERROR);
215- //
216- // onErrorClause.setOnErrorType(null);
217- // onErrorClause.setOnErrorType(JsonTableFunction.JsonTableOnErrorType);
218- // onErrorClause.setOnErrorType(JsonOnErrorType.ERROR);
219- //
220- // table.setType(null);
221- // table.setType(JsonTableType.LAX);
222- // table.setType(JsonTableType.STRICT);
223- // });
224- // }
225-
226- // @Test
227- // void testInvalidSetters() {
228- // JsonTableFunction table = new JsonTable();
229- //
230- // assertThatThrownBy(() -> table.setOnEmptyType(JsonOnEmptyType.EMPTY))
231- // .isInstanceOf(IllegalArgumentException.class);
232- // assertThatThrownBy(() -> table.setOnEmptyType(JsonOnEmptyType.EMPTY_ARRAY))
233- // .isInstanceOf(IllegalArgumentException.class);
234- // assertThatThrownBy(() -> table.setOnEmptyType(JsonOnEmptyType.EMPTY_OBJECT))
235- // .isInstanceOf(IllegalArgumentException.class);
236- // assertThatThrownBy(() -> table.setOnEmptyType(JsonOnEmptyType.FALSE))
237- // .isInstanceOf(IllegalArgumentException.class);
238- // assertThatThrownBy(() -> table.setOnEmptyType(JsonOnEmptyType.TRUE))
239- // .isInstanceOf(IllegalArgumentException.class);
240- // assertThatThrownBy(() -> table.setOnEmptyType(JsonOnEmptyType.DEFAULT))
241- // .isInstanceOf(IllegalArgumentException.class);
242- //
243- // assertThatThrownBy(() -> table.setOnErrorType(JsonOnErrorType.EMPTY))
244- // .isInstanceOf(IllegalArgumentException.class);
245- // assertThatThrownBy(() -> table.setOnErrorType(JsonOnErrorType.EMPTY_ARRAY))
246- // .isInstanceOf(IllegalArgumentException.class);
247- // assertThatThrownBy(() -> table.setOnErrorType(JsonOnErrorType.EMPTY_OBJECT))
248- // .isInstanceOf(IllegalArgumentException.class);
249- // assertThatThrownBy(() -> table.setOnErrorType(JsonOnErrorType.FALSE))
250- // .isInstanceOf(IllegalArgumentException.class);
251- // assertThatThrownBy(() -> table.setOnErrorType(JsonOnErrorType.TRUE))
252- // .isInstanceOf(IllegalArgumentException.class);
253- // assertThatThrownBy(() -> table.setOnErrorType(JsonOnErrorType.DEFAULT))
254- // .isInstanceOf(IllegalArgumentException.class);
255- //
256- // JsonTableColumn column = new JsonTableColumn();
257- //
258- // assertThatThrownBy(() -> {
259- // column.setType(JsonTableColumnType.JSON_EXISTS);
260- // column.setFormatJson(true);
261- // }).isInstanceOf(IllegalArgumentException.class);
262- // assertThatThrownBy(() -> {
263- // column.setType(JsonTableColumnType.JSON_VALUE);
264- // column.setFormatJson(true);
265- // }).isInstanceOf(IllegalArgumentException.class);
266- // assertThatThrownBy(() -> {
267- // column.setType(JsonTableColumnType.ORDINALITY);
268- // column.setFormatJson(true);
269- // }).isInstanceOf(IllegalArgumentException.class);
270- // assertThatThrownBy(() -> {
271- // column.setType(JsonTableColumnType.JSON_NESTED_PATH);
272- // column.setFormatJson(true);
273- // }).isInstanceOf(IllegalArgumentException.class);
274- // }
182+ // @Test
183+ // void testColumnTypeExists() throws JSQLParserException {
184+ // String expression = "JSON_TABLE(document COLUMNS( hasValue EXISTS PATH '$.pathTest'))";
185+ // JsonTableFunction table = parseTable(expression);
186+ //
187+ // assertThat(table.getColumnsClause().getColumnDefinitions()).hasSize(1);
188+ //
189+ // JsonTableFunction.JsonTableColumnDefinition col =
190+ // table.getColumnsClause().getColumnDefinitions().get(0);
191+ // assertThat(col.getType()).isEqualTo(JsonTableColumnType.JSON_EXISTS);
192+ // }
193+
194+ // @Test
195+ // void testBuilder() {
196+ // Column c = new Column("document");
197+ //
198+ // JsonTable table = new JsonTable().withExpression(c)
199+ // .withPathExpression("$.subPath")
200+ // .withFormatJson(true)
201+ // .withType(JsonTableType.STRICT)
202+ // .withOnEmptyType(JsonOnEmptyType.NULL)
203+ // .withOnErrorType(JsonOnErrorType.ERROR)
204+ // .withColumn(new JsonTableColumn().withName("id")
205+ // .withType(JsonTableColumnType.ORDINALITY));
206+ //
207+ // assertThat(table.toString()).isEqualTo(
208+ // "JSON_TABLE(document FORMAT JSON, '$.subPath' ERROR ON ERROR TYPE(STRICT) NULL ON EMPTY
209+ // COLUMNS(id FOR ORDINALITY))");
210+ // }
211+
212+ // @Test
213+ // void testValidSetters() {
214+ // JsonTableFunction table = new JsonTableFunction();
215+ //
216+ // JsonTableFunction.JsonTableOnEmptyClause onEmptyClause = new
217+ // JsonTableFunction.JsonTableOnEmptyClause();
218+ // JsonTableFunction.JsonTableOnErrorClause onErrorClause = new
219+ // JsonTableFunction.JsonTableOnErrorClause(true);
220+ //
221+ // assertThatNoException().isThrownBy(() -> {
222+ // table.setOnEmptyClause(null);
223+ // onEmptyClause.setType(JsonTableFunction.JsonTableOnEmptyType.NULL);
224+ // onEmptyClause.setType(JsonTableFunction.JsonTableOnEmptyType.ERROR);
225+ //
226+ // onErrorClause.setOnErrorType(null);
227+ // onErrorClause.setOnErrorType(JsonTableFunction.JsonTableOnErrorType);
228+ // onErrorClause.setOnErrorType(JsonOnErrorType.ERROR);
229+ //
230+ // table.setType(null);
231+ // table.setType(JsonTableType.LAX);
232+ // table.setType(JsonTableType.STRICT);
233+ // });
234+ // }
235+
236+ // @Test
237+ // void testInvalidSetters() {
238+ // JsonTableFunction table = new JsonTable();
239+ //
240+ // assertThatThrownBy(() -> table.setOnEmptyType(JsonOnEmptyType.EMPTY))
241+ // .isInstanceOf(IllegalArgumentException.class);
242+ // assertThatThrownBy(() -> table.setOnEmptyType(JsonOnEmptyType.EMPTY_ARRAY))
243+ // .isInstanceOf(IllegalArgumentException.class);
244+ // assertThatThrownBy(() -> table.setOnEmptyType(JsonOnEmptyType.EMPTY_OBJECT))
245+ // .isInstanceOf(IllegalArgumentException.class);
246+ // assertThatThrownBy(() -> table.setOnEmptyType(JsonOnEmptyType.FALSE))
247+ // .isInstanceOf(IllegalArgumentException.class);
248+ // assertThatThrownBy(() -> table.setOnEmptyType(JsonOnEmptyType.TRUE))
249+ // .isInstanceOf(IllegalArgumentException.class);
250+ // assertThatThrownBy(() -> table.setOnEmptyType(JsonOnEmptyType.DEFAULT))
251+ // .isInstanceOf(IllegalArgumentException.class);
252+ //
253+ // assertThatThrownBy(() -> table.setOnErrorType(JsonOnErrorType.EMPTY))
254+ // .isInstanceOf(IllegalArgumentException.class);
255+ // assertThatThrownBy(() -> table.setOnErrorType(JsonOnErrorType.EMPTY_ARRAY))
256+ // .isInstanceOf(IllegalArgumentException.class);
257+ // assertThatThrownBy(() -> table.setOnErrorType(JsonOnErrorType.EMPTY_OBJECT))
258+ // .isInstanceOf(IllegalArgumentException.class);
259+ // assertThatThrownBy(() -> table.setOnErrorType(JsonOnErrorType.FALSE))
260+ // .isInstanceOf(IllegalArgumentException.class);
261+ // assertThatThrownBy(() -> table.setOnErrorType(JsonOnErrorType.TRUE))
262+ // .isInstanceOf(IllegalArgumentException.class);
263+ // assertThatThrownBy(() -> table.setOnErrorType(JsonOnErrorType.DEFAULT))
264+ // .isInstanceOf(IllegalArgumentException.class);
265+ //
266+ // JsonTableColumn column = new JsonTableColumn();
267+ //
268+ // assertThatThrownBy(() -> {
269+ // column.setType(JsonTableColumnType.JSON_EXISTS);
270+ // column.setFormatJson(true);
271+ // }).isInstanceOf(IllegalArgumentException.class);
272+ // assertThatThrownBy(() -> {
273+ // column.setType(JsonTableColumnType.JSON_VALUE);
274+ // column.setFormatJson(true);
275+ // }).isInstanceOf(IllegalArgumentException.class);
276+ // assertThatThrownBy(() -> {
277+ // column.setType(JsonTableColumnType.ORDINALITY);
278+ // column.setFormatJson(true);
279+ // }).isInstanceOf(IllegalArgumentException.class);
280+ // assertThatThrownBy(() -> {
281+ // column.setType(JsonTableColumnType.JSON_NESTED_PATH);
282+ // column.setFormatJson(true);
283+ // }).isInstanceOf(IllegalArgumentException.class);
284+ // }
275285
276286 private JsonTableFunction parseTable (String jsonTableStr ) throws JSQLParserException {
277287 String sql = "SELECT * FROM " + jsonTableStr ;
0 commit comments