diff --git a/mindsdb_sql_parser/parser.py b/mindsdb_sql_parser/parser.py index 3482ded..67ea15c 100644 --- a/mindsdb_sql_parser/parser.py +++ b/mindsdb_sql_parser/parser.py @@ -1755,6 +1755,10 @@ def constant(self, p): def constant(self, p): return Constant(value=False) + @_('ON') + def constant(self, p): + return Constant(value='ON', with_quotes=False) + @_('integer') def constant(self, p): return Constant(value=int(p.integer)) diff --git a/tests/test_mindsdb/test_variables.py b/tests/test_mindsdb/test_variables.py index 775b746..fe4ed11 100644 --- a/tests/test_mindsdb/test_variables.py +++ b/tests/test_mindsdb/test_variables.py @@ -37,6 +37,17 @@ def test_select_variable(self): assert str(ast).lower() == sql.lower() assert str(ast) == str(expected_ast) + def test_set(self): + for value in (0, 1, 'TRUE', 'FALSE', 'ON', 'OFF'): + sql = f"set @@session.autocommit={value}" + ast = parse_sql(sql) + expected_ast = Set( + name=Variable('session.autocommit', is_system_var=True), + value=Constant(value, with_quotes=False) + ) + assert str(ast).lower() == sql.lower() + assert str(ast) == str(expected_ast) + def test_mysql(self): sql = 'select @@session.auto_increment_increment, @@character_set_client' ast = parse_sql(sql)