Skip to content

Commit

Permalink
adapted to set command: mindsdb/mindsdb_sql#339
Browse files Browse the repository at this point in the history
  • Loading branch information
ea-rus committed Jan 11, 2024
1 parent ce7f5a8 commit c16b52d
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions mindsdb/api/executor/command_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
Union,
Update,
Use,
Variable
)

# typed models
Expand Down Expand Up @@ -66,7 +67,6 @@
UpdateChatBot,
UpdateSkill
)
from mindsdb_sql.parser.dialects.mysql import Variable
from mindsdb_sql.render.sqlalchemy_render import SqlalchemyRender

import mindsdb.utilities.profiler as profiler
Expand Down Expand Up @@ -526,18 +526,22 @@ def execute_command(self, statement):
return ExecuteAnswer(ANSWER_TYPE.OK)
elif type(statement) == Set:
category = (statement.category or "").lower()
if category == "" and type(statement.arg) == BinaryOperation:
if isinstance(statement.arg.args[0], Variable):
return ExecuteAnswer(ANSWER_TYPE.OK)
if statement.arg.args[0].parts[0].lower() == "profiling":
if statement.arg.args[1].value in (1, True):
if category == "" and isinstance(statement.name, Identifier):
param = statement.name.parts[0].lower()

value = None
if isinstance(statement.value, Constant):
value = statement.value.value

if param == "profiling":
if value in (1, True):
profiler.enable()
self.session.profiling = True
else:
profiler.disable()
self.session.profiling = False
elif statement.arg.args[0].parts[0].lower() == "predictor_cache":
if statement.arg.args[1].value in (1, True):
elif param == "predictor_cache":
if value in (1, True):
self.session.predictor_cache = True
else:
self.session.predictor_cache = False
Expand All @@ -550,7 +554,7 @@ def execute_command(self, statement):
"utf8": CHARSET_NUMBERS["utf8_general_ci"],
"utf8mb4": CHARSET_NUMBERS["utf8mb4_general_ci"],
}
self.charset = statement.arg.parts[0]
self.charset = statement.value.value
self.charset_text_type = charsets.get(self.charset)
if self.charset_text_type is None:
logger.warning(
Expand Down

0 comments on commit c16b52d

Please sign in to comment.