-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
90 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
from .variable import Variable | ||
from .show_index import ShowIndex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from mindsdb_sql import parse_sql | ||
from mindsdb_sql.parser.ast import * | ||
from mindsdb_sql.parser.ast import Variable | ||
|
||
class TestMDBParser: | ||
def test_select_variable(self): | ||
sql = 'SELECT @version' | ||
ast = parse_sql(sql) | ||
expected_ast = Select(targets=[Variable('version')]) | ||
assert str(ast).lower() == sql.lower() | ||
assert str(ast) == str(expected_ast) | ||
|
||
sql = 'SELECT @@version' | ||
ast = parse_sql(sql) | ||
expected_ast = Select(targets=[Variable('version', is_system_var=True)]) | ||
assert str(ast).lower() == sql.lower() | ||
assert str(ast) == str(expected_ast) | ||
|
||
sql = "set autocommit = 1, sql_mode = concat(@@sql_mode, ',STRICT_TRANS_TABLES')" | ||
ast = parse_sql(sql) | ||
expected_ast = Set( | ||
arg=Tuple([ | ||
BinaryOperation(op='=', args=[ | ||
Identifier('autocommit'), Constant(1) | ||
]), | ||
BinaryOperation(op='=', args=[ | ||
Identifier('sql_mode'), | ||
Function(op='concat', args=[ | ||
Variable('sql_mode', is_system_var=True), | ||
Constant(',STRICT_TRANS_TABLES') | ||
]) | ||
]) | ||
]) | ||
) | ||
assert str(ast).lower() == sql.lower() | ||
assert str(ast) == str(expected_ast) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters