Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.19.2 release #56

Merged
merged 3 commits into from Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.txt
@@ -1,3 +1,6 @@
**v0.19.2**
1. Added support for ` quotes in column & tables names

**v0.19.1**
Fixes:
1. Issue with '\t' reported in https://github.com/xnuinside/simple-ddl-parser/issues/53
Expand Down
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -357,6 +357,9 @@ For one of the work projects I needed to convert SQL ddl to Python ORM models in
So I remembered about Parser in Fakeme and just extracted it & improved.

## Changelog
**v0.19.2**
1. Added support for ` quotes in column & tables names

**v0.19.1**
Fixes:
1. Issue with '\t' reported in https://github.com/xnuinside/simple-ddl-parser/issues/53
Expand Down
5 changes: 5 additions & 0 deletions docs/README.rst
Expand Up @@ -406,6 +406,11 @@ So I remembered about Parser in Fakeme and just extracted it & improved.
Changelog
---------

**v0.19.2**


#. Added support for ` quotes in column & tables names

**v0.19.1**
Fixes:

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "simple-ddl-parser"
version = "0.19.1"
version = "0.19.2"
description = "Simple DDL Parser to parse SQL & dialects like HQL, TSQL, Oracle, AWS Redshift, Snowflake, etc ddl files to json/python dict with full information about columns: types, defaults, primary keys, etc.; sequences, alters, custom types & other entities from ddl."
authors = ["Iuliia Volkova <xnuinside@gmail.com>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion simple_ddl_parser/ddl_parser.py
Expand Up @@ -53,7 +53,7 @@ def t_STRING(self, t):
return t

def t_ID(self, t):
r"([0-9]\.[0-9])\w|([a-zA-Z_,0-9:><\/\=\-\+\~\%$\*'\()!{}\[\]\"]+)"
r"([0-9]\.[0-9])\w|([a-zA-Z_,0-9:><\/\=\-\+\~\%$\*'\()!{}\[\]\"\`]+)"
t.type = tok.symbol_tokens.get(t.value, "ID")
if t.type == "LP" and not self.lexer.after_columns:
self.lexer.lp_open += 1
Expand Down
56 changes: 56 additions & 0 deletions tests/test_simple_ddl_parser.py
Expand Up @@ -1877,3 +1877,59 @@ def test_tabs_not_fails_ddl():
"types": [],
}
assert expected == result


def test_quotes():

ddl = """
CREATE TABLE IF NOT EXISTS `shema`.table
(
field_1 BIGINT,
`partition` STRING,
);
"""
parse_result = DDLParser(ddl).run(output_mode="hql")
expected = [
{
"columns": [
{
"name": "field_1",
"type": "BIGINT",
"size": None,
"references": None,
"unique": False,
"nullable": True,
"default": None,
"check": None,
},
{
"name": "`partition`",
"type": "STRING",
"size": None,
"references": None,
"unique": False,
"nullable": True,
"default": None,
"check": None,
},
],
"primary_key": [],
"alter": {},
"checks": [],
"index": [],
"partitioned_by": [],
"tablespace": None,
"stored_as": None,
"location": None,
"comment": None,
"row_format": None,
"fields_terminated_by": None,
"lines_terminated_by": None,
"map_keys_terminated_by": None,
"collection_items_terminated_by": None,
"external": False,
"schema": "`shema`",
"table_name": "table",
}
]
assert expected == parse_result