From 07781989ef44fadc5da515b84003956e94b2e312 Mon Sep 17 00:00:00 2001 From: xnuinside Date: Sun, 14 Jan 2024 17:08:41 +0300 Subject: [PATCH] release version 1.0.2 --- CHANGELOG.txt | 15 +++++++++++---- README.md | 14 ++++++++++++++ docs/README.rst | 23 +++++++++++++++++++++++ simple_ddl_parser/dialects/sql.py | 16 +++++++++++++--- tests/test_read_from_file.py | 2 +- tests/test_references.py | 10 ++++++++-- 6 files changed, 70 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ddbc054..b0ef4f9 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,10 +1,17 @@ **v1.0.2** -### Minor Fixes -1. typo on Databricks dialect -2. improve equals symbols support within COMMENT statement. -3. snowflake TAG now available on SCHEMA definitions. +### Improvements +1. Fixed bug with places first table property value in 'authorization' key. Now it is used real property name. +2. Fixed typo on Databricks dialect +3. improved equals symbols support within COMMENT statement. 4. turn regexp into functions +### MySQL Improvements +1. UNSIGNED property after int parsed validly now + +### Snowflake +1. Snowflake TAG now available on SCHEMA definitions. + + **v1.0.1** ### Minor Fixes 1. When using `normalize_names=True` do not remove `[]` from types like `decimal(21)[]`. diff --git a/README.md b/README.md index 521a09e..f269d35 100644 --- a/README.md +++ b/README.md @@ -486,6 +486,20 @@ for help with debugging & testing support for BigQuery dialect DDLs: ## Changelog +**v1.1.0** +### Improvements +1. Fixed bug with places first table property value in 'authorization' key. Now it is used real property name. +2. Fixed typo on Databricks dialect +3. improved equals symbols support within COMMENT statement. +4. turn regexp into functions + +### MySQL Improvements +1. UNSIGNED property after int parsed validly now + +### Snowflake +1. Snowflake TAG now available on SCHEMA definitions. + + **v1.0.1** ### Minor Fixes 1. When using `normalize_names=True` do not remove `[]` from types like `decimal(21)[]`. diff --git a/docs/README.rst b/docs/README.rst index b527f1e..e82f337 100644 --- a/docs/README.rst +++ b/docs/README.rst @@ -549,6 +549,29 @@ for help with debugging & testing support for BigQuery dialect DDLs: Changelog --------- +**v1.1.0** + +Improvements +^^^^^^^^^^^^ + + +#. Fixed bug with places first table property value in 'authorization' key. Now it is used real property name. +#. Fixed typo on Databricks dialect +#. improved equals symbols support within COMMENT statement. +#. turn regexp into functions + +MySQL Improvements +^^^^^^^^^^^^^^^^^^ + + +#. UNSIGNED property after int parsed validly now + +Snowflake +^^^^^^^^^ + + +#. Snowflake TAG now available on SCHEMA definitions. + **v1.0.1** Minor Fixes diff --git a/simple_ddl_parser/dialects/sql.py b/simple_ddl_parser/dialects/sql.py index ac4ef13..2cdc245 100644 --- a/simple_ddl_parser/dialects/sql.py +++ b/simple_ddl_parser/dialects/sql.py @@ -177,6 +177,7 @@ def parse_complex_type(p_list: List[str]) -> str: if isinstance(p_list[1], dict): _type = p_list[1]["type"] start_index = 2 + for elem in p_list[start_index:]: if isinstance(elem, list): for _elem in elem: @@ -202,7 +203,6 @@ def p_c_type(self, p: List) -> None: p[0] = {} p_list = remove_par(list(p)) _type = None - if len(p_list) == 2: _type = p_list[-1] elif isinstance(p[1], str) and p[1].lower() == "encode": @@ -302,7 +302,11 @@ def process_type_to_column_data(self, p_list, p): p[0][key] = value else: # for [] arrays - p[0]["type"] += p_list[-1]["type"] + if "[]" in p_list[-1]["type"]: + p[0]["type"] += p_list[-1]["type"] + else: + # types like int UNSIGNED + p[0]["type"] += f' {p_list[-1]["type"]}' del p_list[-1] return False @@ -483,7 +487,13 @@ def p_expression_schema(self, p: List) -> None: if isinstance(p_list[-1], dict): p[0].update(p_list[-1]) elif len(p) > 2: - p[0]["authorization"] = p[2] + if p[0].get("schema") is not None: + # then is is a authorization schema property + p[0]["authorization"] = p[2] + else: + if isinstance(p_list[-2], dict): + last_key = list(p_list[-2].keys())[-1] + p[0][last_key] = p_list[-1] def set_properties_for_schema_and_database(self, p: List, p_list: List) -> None: if not p[0].get("properties"): diff --git a/tests/test_read_from_file.py b/tests/test_read_from_file.py index 390d00b..9b65cb6 100644 --- a/tests/test_read_from_file.py +++ b/tests/test_read_from_file.py @@ -213,7 +213,7 @@ def test_parse_from_file_encoding(): "columns": [ { "name": "`entry`", - "type": "mediumintunsigned", + "type": "mediumint unsigned", "size": 8, "references": None, "unique": False, diff --git a/tests/test_references.py b/tests/test_references.py index 14888e4..103171b 100644 --- a/tests/test_references.py +++ b/tests/test_references.py @@ -463,7 +463,10 @@ def test_foreigen_keys(): "unique": False, }, ], - "table_properties": {"engine":"InnoDB", "character": "SET","authorization":"utf8"}, + "table_properties": { + "engine": "InnoDB", + "character": "utf8", + }, "index": [], "partitioned_by": [], "primary_key": ["exception_id"], @@ -565,7 +568,10 @@ def test_compound_foreigen_keys(): ] }, "tablespace": None, - "table_properties": {"engine":"InnoDB", "character": "SET","authorization":"utf8"}, + "table_properties": { + "engine": "InnoDB", + "character": "utf8", + }, } ], "types": [],