Skip to content

Commit 5b85507

Browse files
authored
Merge pull request #641 from ted-johnson/teradata_sel
support teradata shortcut for Select
2 parents 62bfda7 + 340dcaa commit 5b85507

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
258258
| <K_RIGHT:"RIGHT">
259259
| <K_ROW: "ROW">
260260
| <K_ROWS: "ROWS">
261-
| <K_SELECT:"SELECT">
261+
| <K_SELECT: ("SELECT" | "SEL")>
262262
| <K_SEMI : "SEMI">
263263
| <K_SEPARATOR:"SEPARATOR">
264264
| <K_SET:"SET">

src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3228,7 +3228,17 @@ public void testMultiPartNamesIssue163() throws JSQLParserException {
32283228
public void testMultiPartNamesIssue608() throws JSQLParserException {
32293229
assertSqlCanBeParsedAndDeparsed("SELECT @@session.tx_read_only");
32303230
}
3231-
3231+
3232+
// Teradata allows SEL to be used in place of SELECT
3233+
// Deparse to the non-contracted form
3234+
@Test
3235+
public void testSelContraction() throws JSQLParserException {
3236+
final String statementSrc = "SEL name, age FROM person";
3237+
final String statementTgt = "SELECT name, age FROM person";
3238+
Select select = (Select) parserManager.parse(new StringReader(statementSrc));
3239+
assertStatementCanBeDeparsedAs(select, statementTgt);
3240+
}
3241+
32323242
@Test
32333243
public void testMultiPartNamesIssue643() throws JSQLParserException {
32343244
assertSqlCanBeParsedAndDeparsed("SELECT id, bid, pid, devnum, pointdesc, sysid, zone, sort FROM fault ORDER BY id DESC LIMIT ?, ?");

0 commit comments

Comments
 (0)