joereynolds / joereynolds/sql-lint
Semicolon ";" at end of queries given error - [ER_PARSE_ERROR]
- Dominant language
- TypeScript
- Stars
- 459
- Forks
- 44
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
Using sql-lint on Mac & Linux (version 0.0.13).
I found that sql-lint gave [ER_PARSE_ERROR] when it found semicolon.
__With_semicolon__
```
$ /bin/cat create.sql
CREATE TABLE t1 (year YEAR(4), month INT(2) UNSIGNED ZEROFILL,
day INT(2) UNSIGNED ZEROFILL);
$ sql-lint -f create.sql
create.sql:1 [ER_PARSE_ERROR] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE t1 (year YEAR(4), month INT(2) UNSIGNED ZEROFILL, day I' at line 1
```
__Without_semicolon__
```
$ /bin/cat without_semicolon_create.sql
CREATE TABLE t1 (year YEAR(4), month INT(2) UNSIGNED ZEROFILL,
day INT(2) UNSIGNED ZEROFILL)
$ sql-lint -f without_semicolon_create.sql -v
```
Same for "--query/-q" option
__With_semicolon__
```
$ sql-lint -q "$(/bin/cat create.sql )"
query:1 [ER_PARSE_ERROR] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE t1 (year YEAR(4), month INT(2) UNSIGNED ZEROFILL, day I' at line 1
```
__Without_semicolon__
```
$ sql-lint -q "$(sed -e "s/;//" create.sql)" -v
```
Using sed, I have removed ";" from `create.sql`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the report with sql-lint -f create.sql and sql-lint -q using the shown create.sql examples. Trace the query parsing entry point for both options; done means valid MySQL queries ending in a semicolon no longer produce ER_PARSE_ERROR while the existing no-semicolon examples continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, typescript
- Domain
- cli, databases, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100