Skip to content

Commit e976696

Browse files
committed
Added SELECT parsing and JUnit test
1 parent 666cac2 commit e976696

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
<artifactId>maven-compiler-plugin</artifactId>
2929
<version>2.0.2</version>
3030
<configuration>
31-
<source>1.6</source>
32-
<target>1.6</target>
31+
<source>1.5</source>
32+
<target>1.5</target>
3333
</configuration>
3434
</plugin>
3535
<plugin>

src/main/javacc/net/sf/jsqlparser/parser/JSqlParserCC.jj

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ Update Update():
278278
Table table = null;
279279
Expression where = null;
280280
Column tableColumn = null;
281-
List expList = new ArrayList();
282-
List columns = new ArrayList();
281+
List<Expression> expList = new ArrayList<Expression>();
282+
List<Column> columns = new ArrayList<Column>();
283283
Expression value = null;
284284

285285
}
@@ -304,8 +304,8 @@ Replace Replace():
304304
Column tableColumn = null;
305305
Expression value = null;
306306

307-
List columns = new ArrayList();
308-
List expList = new ArrayList();
307+
List<Column> columns = new ArrayList<Column>();
308+
List<Expression> expList = new ArrayList<Expression>();
309309
ItemsList itemsList = null;
310310
Expression exp = null;
311311

@@ -355,8 +355,8 @@ Insert Insert():
355355
Insert insert = new Insert();
356356
Table table = null;
357357
Column tableColumn = null;
358-
List columns = new ArrayList();
359-
List primaryExpList = new ArrayList();
358+
List<Column> columns = new ArrayList<Column>();
359+
List<Expression> primaryExpList = new ArrayList<Expression>();
360360
ItemsList itemsList = null;
361361
Expression exp = null;
362362
}
@@ -482,7 +482,7 @@ Select Select():
482482
{
483483
Select select = new Select();
484484
SelectBody selectBody = null;
485-
List with = null;
485+
List<WithItem> with = null;
486486
}
487487
{
488488
[ with=WithList() { select.setWithItemsList(with); } ]
@@ -510,10 +510,10 @@ PlainSelect PlainSelect():
510510
PlainSelect plainSelect = new PlainSelect();
511511
List selectItems = null;
512512
FromItem fromItem = null;
513-
List joins = null;
513+
List<Join> joins = null;
514514
List distinctOn = null;
515515
Expression where = null;
516-
List orderByElements;
516+
List<OrderByElement> orderByElements;
517517
List groupByColumnReferences = null;
518518
Expression having = null;
519519
Limit limit = null;
@@ -562,10 +562,10 @@ PlainSelect PlainSelect():
562562
Union Union():
563563
{
564564
Union union = new Union();
565-
List orderByElements = null;
565+
List<OrderByElement> orderByElements = null;
566566
Limit limit = null;
567567
PlainSelect select = null;
568-
ArrayList selects = new ArrayList();
568+
ArrayList<PlainSelect> selects = new ArrayList<PlainSelect>();
569569
/*
570570
this is not 100% right, since multiple UNION could have different ALL/DISTINCT clauses...
571571
*/
@@ -599,7 +599,7 @@ this is not 100% right, since multiple UNION could have different ALL/DISTINCT c
599599

600600
List WithList():
601601
{
602-
ArrayList withItemsList = new ArrayList();
602+
ArrayList<WithItem> withItemsList = new ArrayList<WithItem>();
603603
WithItem with = null;
604604
}
605605
{
@@ -612,7 +612,7 @@ WithItem WithItem():
612612
{
613613
WithItem with = new WithItem();
614614
String name = null;
615-
List selectItems = null;
615+
List<SelectItem> selectItems = null;
616616
SelectBody selectBody = null;
617617
}
618618
{
@@ -625,7 +625,7 @@ WithItem WithItem():
625625

626626
List SelectItemsList():
627627
{
628-
ArrayList selectItemsList = new ArrayList();
628+
ArrayList<SelectItem> selectItemsList = new ArrayList<SelectItem>();
629629
SelectItem selectItem = null;
630630
}
631631
{
@@ -730,7 +730,7 @@ FromItem SubJoin():
730730

731731
List JoinsList():
732732
{
733-
ArrayList joinsList = new ArrayList();
733+
ArrayList<Join> joinsList = new ArrayList<Join>();
734734
Join join = null;
735735
}
736736
{
@@ -746,7 +746,7 @@ Join JoinerExpression():
746746
FromItem right = null;
747747
Expression onExpression = null;
748748
Column tableColumn;
749-
List columns = null;
749+
List<Column> columns = null;
750750
}
751751
{
752752

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,12 @@ public void testSelectFunction() throws JSQLParserException {
633633
String statement = "SELECT 1+2 AS sum";
634634
parserManager.parse( new StringReader( statement ) );
635635
}
636+
637+
638+
public void testWeirdSelect() throws JSQLParserException {
639+
String sql = "select r.reviews_id, substring(rd.reviews_text, 100) as reviews_text, r.reviews_rating, r.date_added, r.customers_name from reviews r, reviews_description rd where r.products_id = '19' and r.reviews_id = rd.reviews_id and rd.languages_id = '1' and r.reviews_status = 1 order by r.reviews_id desc limit 0, 6";
640+
parserManager.parse( new StringReader( sql ) );
641+
}
636642

637643
public static void main(String[] args) {
638644
junit.swingui.TestRunner.run(SelectTest.class);

0 commit comments

Comments
 (0)