sqlparse icon indicating copy to clipboard operation
sqlparse copied to clipboard

`DIV` should be Operator

Open chezou opened this issue 3 years ago • 0 comments

DIV should be treated as Operator, but it isn't. https://www.w3schools.com/sql/func_mysql_div.asp

This behavior prevents to get_alias with DIV operator.

Actual behavior

>>> sqlparse.parse('col1 DIV 5')[0]._pprint_tree()
|- 0 Identifier 'col1 D...'
|  |- 0 Name 'col1'
|  |- 1 Whitespace ' '
|  `- 2 Identifier 'DIV'
|     `- 0 Name 'DIV'
|- 1 Whitespace ' '
`- 2 Integer '5'

Expected behavior

>>> sqlparse.parse('col1 DIV 5')[0]._pprint_tree()
`- 0 Operation 'col1 D...'
   |- 0 Identifier 'col1'
   |  `- 0 Name 'col1'
   |- 1 Whitespace ' '
   |- 2 Operator 'DIV'
   |- 3 Whitespace ' '
   `- 4 Integer '5'

chezou avatar May 04 '22 03:05 chezou