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

Upper case "CREATE" in column name ends table parse #94

Closed
n2ygk opened this issue Nov 16, 2021 · 5 comments
Closed

Upper case "CREATE" in column name ends table parse #94

n2ygk opened this issue Nov 16, 2021 · 5 comments

Comments

@n2ygk
Copy link

n2ygk commented Nov 16, 2021

Describe the bug
It looks like you are seeing CREATE and breaking the table DDL parse...

To Reproduce

t1.sql:

DROP TABLE IF EXISTS demo;
--
CREATE TABLE demo
(
     foo                             char(1),
     create_date                     DATETIME2,
     created_BY                      VARCHAR (20)
)
--

t2.sql:

DROP TABLE IF EXISTS demo;
--
CREATE TABLE demo
(
     foo                             char(1),
     CREATE_date                     DATETIME2,
     created_by                      VARCHAR (20),
)
--
sdp -v t1.sql
$ sdp -v t1.sql
Start parsing file t1.sql 

File with result was saved to >> schemas folder
[{'alter': {},
  'checks': [],
  'columns': [{'check': None,
               'default': None,
               'name': 'foo',
               'nullable': True,
               'references': None,
               'size': 1,
               'type': 'char',
               'unique': False},
              {'check': None,
               'default': None,
               'name': 'create_date',
               'nullable': True,
               'references': None,
               'size': None,
               'type': 'DATETIME2',
               'unique': False},
              {'check': None,
               'default': None,
               'name': 'created_BY',
               'nullable': True,
               'references': None,
               'size': 20,
               'type': 'VARCHAR',
               'unique': False}],
  'index': [],
  'partitioned_by': [],
  'primary_key': [],
  'schema': None,
  'table_name': 'demo',
  'tablespace': None}]

vs:

$ sdp -v t2.sql
Start parsing file t2.sql 

File with result was saved to >> schemas folder
[{'alter': {},
  'checks': [],
  'columns': [{'check': None,
               'default': None,
               'name': 'foo',
               'nullable': True,
               'references': None,
               'size': 1,
               'type': 'char',
               'unique': False}],
  'index': [],
  'partitioned_by': [],
  'primary_key': [],
  'schema': None,
  'table_name': 'demo',
  'tablespace': None}]

Expected behavior
A capitalized substring field name that is CREATE shouldn't break the parser.

@n2ygk
Copy link
Author

n2ygk commented Nov 16, 2021

Looks like your tokenizer is misidentifying keywords even when they are no separated by white space.

@xnuinside
Copy link
Owner

xnuinside commented Nov 16, 2021

@n2ygk no, ptoblem not in tokenizer, lol, problem in changes that I did in 0.22.0 version to get possible parse statements without ; or GO. I will fix it tomorrow and release the patch version. thanks for catching this. Very stupid issue )) I set jus ok, if line started with CREATE then it's new statement ))) looks like it was monkey in my head at that moment. I will change it to normal regular expression)) to avoid such cases

@n2ygk
Copy link
Author

n2ygk commented Nov 16, 2021 via email

@xnuinside
Copy link
Owner

@n2ygk fixed in 0.22.2, test added: #95

@xnuinside
Copy link
Owner

@n2ygk Alan, I will close the issue - check my comment in PR) it was already released at the morning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants