forked from JSQLParser/JSqlParser
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
9 changed files
with
296 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/net/sf/jsqlparser/statement/select/ForClause.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package net.sf.jsqlparser.statement.select; | ||
|
||
import net.sf.jsqlparser.parser.ASTNodeAccessImpl; | ||
|
||
public class ForClause extends ASTNodeAccessImpl { | ||
public enum ForOption { | ||
BROWSE, XML, JSON; | ||
|
||
public static ForOption from(String option) { | ||
return Enum.valueOf(ForOption.class, option.toUpperCase()); | ||
} | ||
} | ||
|
||
private ForOption forOption; | ||
|
||
public ForOption getForOption() { | ||
return forOption; | ||
} | ||
|
||
public ForClause setForOption(String forOption) { | ||
this.forOption = ForOption.from(forOption); | ||
return this; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return appendTo(new StringBuilder()).toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
181 changes: 138 additions & 43 deletions
181
src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
Large diffs are not rendered by default.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
src/test/java/net/sf/jsqlparser/statement/select/ForClauseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package net.sf.jsqlparser.statement.select; | ||
|
||
import net.sf.jsqlparser.JSQLParserException; | ||
import net.sf.jsqlparser.test.TestUtils; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class ForClauseTest { | ||
|
||
@Test | ||
void testForBrowse() throws JSQLParserException { | ||
String sqlStr = "SELECT * FROM table FOR BROWSE"; | ||
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true); | ||
} | ||
|
||
@Test | ||
void testForXMLPath() throws JSQLParserException { | ||
String sqlStr = | ||
"SELECT * " + | ||
" FROM table " + | ||
" FOR XML PATH('something'), ROOT('trkseg'), TYPE, BINARY BASE64, ELEMENTS ABSENT "; | ||
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true); | ||
} | ||
|
||
@Test | ||
void testForXMLRaw() throws JSQLParserException { | ||
String sqlStr = | ||
"SELECT * " + | ||
" FROM table " + | ||
" FOR XML RAW('something'), ROOT('trkseg'), TYPE, BINARY BASE64, XMLDATA "; | ||
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true); | ||
} | ||
|
||
@Test | ||
void testForXMLAuto() throws JSQLParserException { | ||
String sqlStr = | ||
"SELECT * " + | ||
" FROM table " + | ||
" FOR XML AUTO, ROOT('trkseg'), TYPE, BINARY BASE64, XMLDATA "; | ||
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true); | ||
} | ||
|
||
@Test | ||
void testForXMLExplicit() throws JSQLParserException { | ||
String sqlStr = | ||
"SELECT * " + | ||
" FROM table " + | ||
" FOR XML EXPLICIT, ROOT('trkseg'), TYPE, BINARY BASE64, XMLDATA "; | ||
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true); | ||
} | ||
|
||
@Test | ||
void testForXML() throws JSQLParserException { | ||
String sqlStr = | ||
"SELECT * " + | ||
" FROM table " + | ||
" FOR XML EXPLICIT, ROOT('trkseg'), TYPE, BINARY BASE64, XMLDATA " + | ||
"UNION ALL " + | ||
"SELECT * " + | ||
" FROM table " + | ||
" FOR XML EXPLICIT, ROOT('trkseg'), TYPE, BINARY BASE64, XMLDATA " + | ||
"UNION ALL " + | ||
"SELECT * " + | ||
" FROM table " + | ||
" FOR XML AUTO, ROOT('trkseg'), TYPE, BINARY BASE64, XMLDATA " + | ||
"UNION ALL " + | ||
"SELECT * " + | ||
" FROM table " + | ||
" FOR XML RAW('something'), ROOT('trkseg'), TYPE, BINARY BASE64, XMLDATA "; | ||
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true); | ||
} | ||
|
||
@Test | ||
void testForJSON() throws JSQLParserException { | ||
String sqlStr = | ||
"SELECT * " + | ||
" FROM table " + | ||
" FOR JSON AUTO, ROOT('trkseg'), WITHOUT_ARRAY_WRAPPER, INCLUDE_NULL_VALUES " | ||
+ | ||
"UNION ALL " + | ||
"SELECT * " + | ||
" FROM table " + | ||
" FOR JSON PATH, ROOT('trkseg'), INCLUDE_NULL_VALUES, WITHOUT_ARRAY_WRAPPER "; | ||
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true); | ||
} | ||
|
||
@Test | ||
void testIssue1800() throws JSQLParserException { | ||
String sqlStr = | ||
"SELECT (SELECT '1.0' AS '@Version', (SELECT 'Test' AS 'name', (SELECT (SELECT DISTINCT 51.64315 AS '@lat', 14.31709 AS '@lon' FOR XML PATH('trkpt'), TYPE) FOR XML PATH(''), ROOT('trkseg'), TYPE) FOR XML PATH('trk'), TYPE) FOR XML PATH('gpx'), TYPE) FOR XML PATH('')"; | ||
TestUtils.assertSqlCanBeParsedAndDeparsed(sqlStr, true); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters