Skip to content

Commit 6e3dce2

Browse files
committed
- corrected S_DOUBLE parsing
1 parent 5136523 commit 6e3dce2

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ TOKEN : /* Numeric Constants */
245245
{
246246
< S_DOUBLE: ((<S_INTEGER>)? "." <S_INTEGER> ( ["e","E"] ([ "-","+"])? <S_INTEGER> )?
247247
|
248-
(<S_INTEGER>)+ (".")? ["e","E"] ([ "-","+"])? (<S_INTEGER>)+
248+
<S_INTEGER> "." (["e","E"] ([ "-","+"])? <S_INTEGER>)?
249+
|
250+
<S_INTEGER> ["e","E"] ([ "-","+"])? <S_INTEGER>
249251
)>
250252
| < S_INTEGER: ( <DIGIT> )+ >
251253
| < #DIGIT: ["0" - "9"] >

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.IOException;
44
import java.io.StringReader;
5+
import static junit.framework.Assert.assertEquals;
56
import junit.framework.TestCase;
67
import net.sf.jsqlparser.JSQLParserException;
78
import net.sf.jsqlparser.expression.BinaryExpression;
@@ -502,6 +503,30 @@ public void testDouble() throws JSQLParserException {
502503
.getRightExpression()).getValue(), 0);
503504
assertStatementCanBeDeparsedAs(select, statement);
504505
}
506+
507+
public void testDouble2() throws JSQLParserException {
508+
String statement = "SELECT 1.e22 FROM mytable";
509+
Select select = (Select) parserManager.parse(new StringReader(statement));
510+
511+
assertEquals(1e22, ((DoubleValue) ((SelectExpressionItem) ((PlainSelect) select.getSelectBody())
512+
.getSelectItems().get(0)).getExpression()).getValue(), 0);
513+
}
514+
515+
public void testDouble3() throws JSQLParserException {
516+
String statement = "SELECT 1. FROM mytable";
517+
Select select = (Select) parserManager.parse(new StringReader(statement));
518+
519+
assertEquals(1.0, ((DoubleValue) ((SelectExpressionItem) ((PlainSelect) select.getSelectBody())
520+
.getSelectItems().get(0)).getExpression()).getValue(), 0);
521+
}
522+
523+
public void testDouble4() throws JSQLParserException {
524+
String statement = "SELECT 1.2e22 FROM mytable";
525+
Select select = (Select) parserManager.parse(new StringReader(statement));
526+
527+
assertEquals(1.2e22, ((DoubleValue) ((SelectExpressionItem) ((PlainSelect) select.getSelectBody())
528+
.getSelectItems().get(0)).getExpression()).getValue(), 0);
529+
}
505530

506531
public void testWith() throws JSQLParserException {
507532
String statement = "WITH DINFO (DEPTNO, AVGSALARY, EMPCOUNT) AS "

0 commit comments

Comments
 (0)