Skip to content

Commit

Permalink
release 10.642.24144
Browse files Browse the repository at this point in the history
  • Loading branch information
klahnakoski committed May 23, 2024
2 parents df3ba1d + 23adb2f commit 72f9110
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mo_sql_parsing/sql_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def mysql_parser(all_columns):


def sqlserver_parser(all_columns):
atomic_ident = ansi_ident | mysql_backtick_ident | sqlserver_ident | simple_ident
atomic_ident = ansi_ident | mysql_backtick_ident | sqlserver_ident | sqlserver_local_ident
return parser(regex_string | ansi_string, atomic_ident, sqlserver=True, all_columns=all_columns)


Expand Down
3 changes: 2 additions & 1 deletion mo_sql_parsing/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@
FLOAT,
GEOMETRY,
MAP_TYPE,
INT,
INTEGER,
INTERVAL,
INT,
INT32,
INT64,
BYTEINT,
Expand Down Expand Up @@ -265,6 +265,7 @@ def get_column_type(expr, identifier, literal_string):
| assign("check", LB + expr + RB)
| assign("default", expr)
| assign("on update", expr)
| (EQ + expr)("default")
)

column_definition << Group(
Expand Down
1 change: 1 addition & 0 deletions mo_sql_parsing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,3 +911,4 @@ def no_dashes(tokens, start, string):
ident_w_dash_warning = Regex(ident_w_dash.__regex__()[1]).set_parser_name("identifier_with_dashes") / no_dashes

simple_ident = Word(FIRST_IDENT_CHAR, IDENT_CHAR).set_parser_name("identifier")
sqlserver_local_ident = Word("@" + FIRST_IDENT_CHAR, IDENT_CHAR).set_parser_name("identifier")
2 changes: 1 addition & 1 deletion packaging/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
name='mo-sql-parsing',
packages=["mo_sql_parsing"],
url='https://github.com/klahnakoski/mo-sql-parsing',
version='10.641.24143',
version='10.642.24144',
zip_safe=True
)
2 changes: 1 addition & 1 deletion packaging/setuptools.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,6 @@
"name": "mo-sql-parsing",
"packages": ["mo_sql_parsing"],
"url": "https://github.com/klahnakoski/mo-sql-parsing",
"version": "10.641.24143",
"version": "10.642.24144",
"zip_safe": true
}
13 changes: 12 additions & 1 deletion tests/test_sql_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def test_issue_231(self):
"when": {"not": {"eq": [
"t_dt",
{"cast": [
{"format": ["t_dt", {"literal":"yyyy-MM-ddTHH:mm:ss.ffffff"}]},
{"format": ["t_dt", {"literal": "yyyy-MM-ddTHH:mm:ss.ffffff"}]},
{"datetimeoffset": {}},
]},
]}},
Expand All @@ -299,3 +299,14 @@ def test_issue_231(self):
"from": "dbo.table",
}
self.assertEqual(result, expected)

def test_issue_237_declare_var(self):
sql = """create procedure k() BEGIN
DECLARE @MYVARIABLE INT = 42;
END"""
result = parse(sql)
expected = {"create_procedure": {
"name": "k",
"body": {"block": {"declare": {"default": 42, "name": "@MYVARIABLE", "type": {"int": {}},}}},
}}
self.assertEqual(result, expected)

0 comments on commit 72f9110

Please sign in to comment.