summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki Ariga <chezou+github@gmail.com>2022-05-03 20:27:17 -0700
committerAndi Albrecht <albrecht.andi@gmail.com>2022-08-08 10:39:55 +0200
commit36687995cfd8d2f674c31f967512a6b17858ca0f (patch)
tree8ad59285fb95dd7760ee9d9676344f62815cd341
parent049634a6e6d4d06483f85866d300263672ff68bf (diff)
downloadsqlparse-36687995cfd8d2f674c31f967512a6b17858ca0f.tar.gz
DIV is Operator
-rw-r--r--sqlparse/keywords.py1
-rw-r--r--tests/test_parse.py6
2 files changed, 7 insertions, 0 deletions
diff --git a/sqlparse/keywords.py b/sqlparse/keywords.py
index cd17d63..f2c24fb 100644
--- a/sqlparse/keywords.py
+++ b/sqlparse/keywords.py
@@ -241,6 +241,7 @@ KEYWORDS = {
'DISABLE': tokens.Keyword,
'DISCONNECT': tokens.Keyword,
'DISPATCH': tokens.Keyword,
+ 'DIV': tokens.Operator,
'DO': tokens.Keyword,
'DOMAIN': tokens.Keyword,
'DYNAMIC': tokens.Keyword,
diff --git a/tests/test_parse.py b/tests/test_parse.py
index 513b4be..caba537 100644
--- a/tests/test_parse.py
+++ b/tests/test_parse.py
@@ -132,6 +132,12 @@ def test_parse_nested_function():
assert type(t[0]) is sql.Function
+def test_parse_div_operator():
+ p = sqlparse.parse('col1 DIV 5 AS div_col1')[0].tokens
+ assert p[0].tokens[0].tokens[2].ttype is T.Operator
+ assert p[0].get_alias() == 'div_col1'
+
+
def test_quoted_identifier():
t = sqlparse.parse('select x.y as "z" from foo')[0].tokens
assert isinstance(t[2], sql.Identifier)