Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mindsdb_sql_parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
11 changes: 11 additions & 0 deletions tests/test_mindsdb/test_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading