From 82c73931eb70295f8e30ad2ac2e3118bd4d4c500 Mon Sep 17 00:00:00 2001 From: Matthew Lilius Date: Tue, 19 May 2020 17:17:48 -0400 Subject: [PATCH 1/4] Handle comments at the end without a trailing newline --- src/sqlParser.jison | 2 +- test/main.test.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/sqlParser.jison b/src/sqlParser.jison index 7cff3e8..15e0907 100644 --- a/src/sqlParser.jison +++ b/src/sqlParser.jison @@ -7,7 +7,7 @@ %% [/][*](.|\n)*?[*][/] /* skip comments */ -[-][-]\s.*\n /* skip sql comments */ +[-][-]\s.*\n? /* skip sql comments */ [#]\s.*\n /* skip sql comments */ \s+ /* skip whitespace */ diff --git a/test/main.test.js b/test/main.test.js index 834d3f1..6597c1f 100644 --- a/test/main.test.js +++ b/test/main.test.js @@ -411,4 +411,8 @@ describe('select grammar support', function() { it('bugfix table alias2', function() { testParser('select a.* from a t1 join b t2 on t1.a = t2.a') }) + + it('query with comment at then end without a newline', function() { + testParser('select a.* from "table name"\n-- comment') + }) }); From f8549eaf8b3901e0b514136f7a29b4aafc5f6de8 Mon Sep 17 00:00:00 2001 From: mlilius Date: Tue, 19 May 2020 17:34:52 -0400 Subject: [PATCH 2/4] fixed test --- test/main.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/main.test.js b/test/main.test.js index 6597c1f..fc3d957 100644 --- a/test/main.test.js +++ b/test/main.test.js @@ -413,6 +413,6 @@ describe('select grammar support', function() { }) it('query with comment at then end without a newline', function() { - testParser('select a.* from "table name"\n-- comment') + testParser('select a.* from a\n-- comment') }) }); From cf272f4f96c76b8619f21869dde29ab811505f5a Mon Sep 17 00:00:00 2001 From: mlilius Date: Tue, 19 May 2020 19:54:40 -0400 Subject: [PATCH 3/4] Simplified test --- test/main.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/main.test.js b/test/main.test.js index fc3d957..1ae8ffb 100644 --- a/test/main.test.js +++ b/test/main.test.js @@ -413,6 +413,6 @@ describe('select grammar support', function() { }) it('query with comment at then end without a newline', function() { - testParser('select a.* from a\n-- comment') + testParser('select a from b\n-- comment') }) }); From 00def87f53d60c1c6715a86b3b884c668d70dd02 Mon Sep 17 00:00:00 2001 From: Matthew Lilius Date: Tue, 19 May 2020 19:56:34 -0400 Subject: [PATCH 4/4] Fixed a typo --- test/main.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/main.test.js b/test/main.test.js index 1ae8ffb..552a5c8 100644 --- a/test/main.test.js +++ b/test/main.test.js @@ -412,7 +412,7 @@ describe('select grammar support', function() { testParser('select a.* from a t1 join b t2 on t1.a = t2.a') }) - it('query with comment at then end without a newline', function() { + it('query with comment at the end without a trailing newline', function() { testParser('select a from b\n-- comment') }) });