Skip to content

Commit 34b13be

Browse files
committed
parse ON
1 parent a72d020 commit 34b13be

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

mindsdb_sql_parser/parser.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,10 @@ def constant(self, p):
17551755
def constant(self, p):
17561756
return Constant(value=False)
17571757

1758+
@_('ON')
1759+
def constant(self, p):
1760+
return Constant(value='ON', with_quotes=False)
1761+
17581762
@_('integer')
17591763
def constant(self, p):
17601764
return Constant(value=int(p.integer))

tests/test_mindsdb/test_variables.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ def test_select_variable(self):
3737
assert str(ast).lower() == sql.lower()
3838
assert str(ast) == str(expected_ast)
3939

40+
def test_set(self):
41+
for value in (0, 1, 'TRUE', 'FALSE', 'ON', 'OFF'):
42+
sql = f"set @@session.autocommit={value}"
43+
ast = parse_sql(sql)
44+
expected_ast = Set(
45+
name=Variable('session.autocommit', is_system_var=True),
46+
value=Constant(value, with_quotes=False)
47+
)
48+
assert str(ast).lower() == sql.lower()
49+
assert str(ast) == str(expected_ast)
50+
4051
def test_mysql(self):
4152
sql = 'select @@session.auto_increment_increment, @@character_set_client'
4253
ast = parse_sql(sql)

0 commit comments

Comments
 (0)