-
Notifications
You must be signed in to change notification settings - Fork 42
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
6 changed files
with
227 additions
and
4 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
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,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "simple-ddl-parser" | ||
version = "0.28.0" | ||
version = "0.28.1" | ||
description = "Simple DDL Parser to parse SQL & dialects like HQL, TSQL (MSSQL), Oracle, AWS Redshift, Snowflake, MySQL, PostgreSQL, 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 <[email protected]>"] | ||
license = "MIT" | ||
|
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 |
---|---|---|
|
@@ -2897,3 +2897,196 @@ def test_floats(): | |
'types': []} | ||
|
||
assert expected == results | ||
|
||
|
||
def test_fix_multiline_comments_not_joined_with_table(): | ||
result = DDLParser( | ||
"""/************************ | ||
@Author: Azat Erol | ||
Always happy coding! | ||
************************/ | ||
CREATE TABLE Kunde ( | ||
KundenID INT PRIMARY KEY, | ||
KundenName VARCHAR(40), | ||
AbteilungID INT | ||
FOREIGN KEY(AbteilungID) REFERENCES Abteilung(AbteilungID) ON DELETE SET NULL | ||
); | ||
""", normalize_names=True).run(group_by_type=True) | ||
expected = {'comments': ['***********************', | ||
'@Author: Azat Erol', | ||
'Always happy coding!', | ||
'************************/'], | ||
'ddl_properties': [], | ||
'domains': [], | ||
'schemas': [], | ||
'sequences': [], | ||
'tables': [{'alter': {}, | ||
'checks': [], | ||
'columns': [{'check': None, | ||
'default': None, | ||
'name': 'KundenID', | ||
'nullable': False, | ||
'references': None, | ||
'size': None, | ||
'type': 'INT', | ||
'unique': False}, | ||
{'check': None, | ||
'default': None, | ||
'name': 'KundenName', | ||
'nullable': True, | ||
'references': None, | ||
'size': 40, | ||
'type': 'VARCHAR', | ||
'unique': False}, | ||
{'check': None, | ||
'default': None, | ||
'name': 'AbteilungID', | ||
'nullable': True, | ||
'references': {'column': 'AbteilungID', | ||
'deferrable_initially': None, | ||
'on_delete': 'SET', | ||
'on_update': None, | ||
'schema': None, | ||
'table': 'Abteilung'}, | ||
'size': None, | ||
'type': 'INT', | ||
'unique': False}], | ||
'index': [], | ||
'partitioned_by': [], | ||
'primary_key': ['KundenID'], | ||
'schema': None, | ||
'table_name': 'Kunde', | ||
'tablespace': None}], | ||
'types': []} | ||
assert expected == result | ||
|
||
|
||
def test_inserts_skipped_validly(): | ||
result = DDLParser( | ||
""" | ||
INSERT INTO "autofill_profiles" VALUES('Jim Johnson, 789 4th Street',1,'Jim','','Johnson','[email protected]','Acme Inc.','789 4th Street','Apt. #4','San Francisco','CA','94102','USA','4155512255','4155512233',1287508123); | ||
INSERT INTO "autofill_profiles" VALUES('Billy Jean, 1 Ghost Blvd.',3,'Billy','','Jean','[email protected]','Thriller Inc.','1 Ghost Blvd.','','Santa Monica','CA','98990','USA','4431110000','',1287508123); | ||
CREATE TABLE credit_cards ( label VARCHAR, unique_id INTEGER PRIMARY KEY, name_on_card VARCHAR, type VARCHAR, card_number VARCHAR, expiration_month INTEGER, expiration_year INTEGER, verification_code VARCHAR, billing_address VARCHAR, shipping_address VARCHAR, card_number_encrypted BLOB, verification_code_encrypted BLOB, date_modified INTEGER NOT NULL DEFAULT 0); | ||
COMMIT; | ||
""", normalize_names=True).run(group_by_type=True) | ||
expected = {'ddl_properties': [], | ||
'domains': [], | ||
'schemas': [], | ||
'sequences': [], | ||
'tables': [{'alter': {}, | ||
'checks': [], | ||
'columns': [{'check': None, | ||
'default': None, | ||
'name': 'label', | ||
'nullable': True, | ||
'references': None, | ||
'size': None, | ||
'type': 'VARCHAR', | ||
'unique': False}, | ||
{'check': None, | ||
'default': None, | ||
'name': 'unique_id', | ||
'nullable': False, | ||
'references': None, | ||
'size': None, | ||
'type': 'INTEGER', | ||
'unique': False}, | ||
{'check': None, | ||
'default': None, | ||
'name': 'name_on_card', | ||
'nullable': True, | ||
'references': None, | ||
'size': None, | ||
'type': 'VARCHAR', | ||
'unique': False}, | ||
{'check': None, | ||
'default': None, | ||
'name': 'type', | ||
'nullable': True, | ||
'references': None, | ||
'size': None, | ||
'type': 'VARCHAR', | ||
'unique': False}, | ||
{'check': None, | ||
'default': None, | ||
'name': 'card_number', | ||
'nullable': True, | ||
'references': None, | ||
'size': None, | ||
'type': 'VARCHAR', | ||
'unique': False}, | ||
{'check': None, | ||
'default': None, | ||
'name': 'expiration_month', | ||
'nullable': True, | ||
'references': None, | ||
'size': None, | ||
'type': 'INTEGER', | ||
'unique': False}, | ||
{'check': None, | ||
'default': None, | ||
'name': 'expiration_year', | ||
'nullable': True, | ||
'references': None, | ||
'size': None, | ||
'type': 'INTEGER', | ||
'unique': False}, | ||
{'check': None, | ||
'default': None, | ||
'name': 'verification_code', | ||
'nullable': True, | ||
'references': None, | ||
'size': None, | ||
'type': 'VARCHAR', | ||
'unique': False}, | ||
{'check': None, | ||
'default': None, | ||
'name': 'billing_address', | ||
'nullable': True, | ||
'references': None, | ||
'size': None, | ||
'type': 'VARCHAR', | ||
'unique': False}, | ||
{'check': None, | ||
'default': None, | ||
'name': 'shipping_address', | ||
'nullable': True, | ||
'references': None, | ||
'size': None, | ||
'type': 'VARCHAR', | ||
'unique': False}, | ||
{'check': None, | ||
'default': None, | ||
'name': 'card_number_encrypted', | ||
'nullable': True, | ||
'references': None, | ||
'size': None, | ||
'type': 'BLOB', | ||
'unique': False}, | ||
{'check': None, | ||
'default': None, | ||
'name': 'verification_code_encrypted', | ||
'nullable': True, | ||
'references': None, | ||
'size': None, | ||
'type': 'BLOB', | ||
'unique': False}, | ||
{'check': None, | ||
'default': 0, | ||
'name': 'date_modified', | ||
'nullable': False, | ||
'references': None, | ||
'size': None, | ||
'type': 'INTEGER', | ||
'unique': False}], | ||
'index': [], | ||
'partitioned_by': [], | ||
'primary_key': ['unique_id'], | ||
'schema': None, | ||
'table_name': 'credit_cards', | ||
'tablespace': None}], | ||
'types': []} | ||
assert expected == result | ||
|