sql-parser icon indicating copy to clipboard operation
sql-parser copied to clipboard

Use of certain keywords in SELECT field list

Open stevenwdv opened this issue 8 years ago • 1 comments

Some queries with keywords in the SELECT field list are marked as invalid by the SQL parser. Examples:

  • SELECT NULL IS NULL
  • SELECT NOT 1
  • SELECT 1 BETWEEN 0 AND 2

Wrapping the expression in parentheses avoids the errors, eg. SELECT (NULL IS NULL).

phpMyAdmin version: 4.7.4

stevenwdv avatar Sep 08 '17 11:09 stevenwdv

Reproduced with current master:

./bin/lint-query --query 'SELECT NULL IS NULL'
#1: Unrecognized keyword. (near "IS" at position 12)
#2: Unrecognized keyword. (near "NULL" at position 15)
./bin/lint-query --query 'SELECT NOT 1'
#1: An expression was expected. (near "NOT" at position 7)
#2: Unrecognized keyword. (near "NOT" at position 7)
#3: Unexpected token. (near "1" at position 11)
./bin/lint-query --query 'SELECT 1 BETWEEN 0 AND 2'
#1: Unrecognized keyword. (near "BETWEEN" at position 9)
#2: Unexpected token. (near "0" at position 17)
#3: Unrecognized keyword. (near "AND" at position 19)
#4: Unexpected token. (near "2" at position 23)

Not sure if those are not three separate issues...

nijel avatar Sep 08 '17 12:09 nijel