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

Fix issue with NULL columns #70

Merged
merged 4 commits into from
Jul 9, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ python:
- "3.6"
- "3.7"
- "3.8"
- "3.9"

# command to install dependencies
install:
Expand Down
21 changes: 15 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [1.10.0] - 2021-07-10
### Added
- Added supports for Python 3.9

### Fixed
- Fixed parsing of columns with NULL/NOT NULL constraint.


## [1.9.0] - 2020-11-04
### Added
- Add supports Cloud Spanner data-type.
Expand Down Expand Up @@ -58,7 +66,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `FIXED`

### Fixed
- Miner fix.
- Minor fix.


## [1.5.0] - 2020-07-06
Expand All @@ -70,7 +78,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Fix parse for column-constraint.
- Miner fix.
- Minor fix.


## [1.4.0] - 2019-12-08
Expand Down Expand Up @@ -161,7 +169,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `NUMBER` with no length & scale specification

### Fixed
- Miner fix.
- Minor fix.


## [1.1.1] - 2018-03-25
Expand All @@ -182,22 +190,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.0.2] - 2018-01-09
### Fixed
- Miner enhancement.
- Minor enhancement.
- `ddlparse.py` : Exclude unused module.
- `example.py` : Modified comment.
- `README.md` : Miner fix.
- `README.md` : Minor fix.


## [1.0.1] - 2018-01-07
### Fixed
- Miner enhancement.
- Minor enhancement.


## [1.0.0]
### Added
- Initial released.


[1.10.0]: https://github.com/shinichi-takii/ddlparse/compare/v1.9.0...v1.10.0
[1.9.0]: https://github.com/shinichi-takii/ddlparse/compare/v1.8.0...v1.9.0
[1.8.0]: https://github.com/shinichi-takii/ddlparse/compare/v1.7.0...v1.8.0
[1.7.0]: https://github.com/shinichi-takii/ddlparse/compare/v1.6.1...v1.7.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![PyPI version](https://img.shields.io/pypi/v/ddlparse.svg)](https://pypi.org/project/ddlparse/)
[![Python version](https://img.shields.io/pypi/pyversions/ddlparse.svg)](https://pypi.org/project/ddlparse/)
[![Travis CI Build Status](https://travis-ci.org/shinichi-takii/ddlparse.svg?branch=master)](https://travis-ci.org/shinichi-takii/ddlparse)
[![Travis CI Build Status](https://travis-ci.com/shinichi-takii/ddlparse.svg?branch=master)](https://travis-ci.com/shinichi-takii/ddlparse)
[![Coveralls Coverage Status](https://coveralls.io/repos/github/shinichi-takii/ddlparse/badge.svg?branch=master)](https://coveralls.io/github/shinichi-takii/ddlparse?branch=master)
[![codecov Coverage Status](https://codecov.io/gh/shinichi-takii/ddlparse/branch/master/graph/badge.svg)](https://codecov.io/gh/shinichi-takii/ddlparse)
[![Requirements Status](https://requires.io/github/shinichi-takii/ddlparse/requirements.svg?branch=master)](https://requires.io/github/shinichi-takii/ddlparse/requirements/?branch=master)
Expand Down
4 changes: 2 additions & 2 deletions ddlparse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

from .ddlparse import *

__copyright__ = 'Copyright (C) 2018-2020 Shinichi Takii'
__version__ = '1.9.0'
__copyright__ = 'Copyright (C) 2018-2021 Shinichi Takii'
__version__ = '1.10.0'
__license__ = 'BSD-3-Clause'
__author__ = 'Shinichi Takii'
__author_email__ = 'shinichi.takii@shaketh.com'
Expand Down
2 changes: 1 addition & 1 deletion ddlparse/ddlparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ class DdlParse(DdlParseBase):
+ Optional(
Regex(r"(?!--)", re.IGNORECASE)
+ Group(
Optional(Regex(r"\b(?:NOT\s+)NULL?\b", re.IGNORECASE))("null")
Optional(Regex(r"\b(?:NOT\s+)?NULL?\b", re.IGNORECASE))("null")
& Optional(Regex(r"\bAUTO_INCREMENT\b", re.IGNORECASE))("auto_increment")
& Optional(Regex(r"\b(UNIQUE|PRIMARY)(?:\s+KEY)?\b", re.IGNORECASE))("key")
& Optional(Regex(
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def _test_requirements():
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Topic :: Database',
'Topic :: Software Development :: Libraries :: Python Modules',
],
Expand Down
10 changes: 9 additions & 1 deletion test/test_ddlparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@
Col_49 number,
Col_50 decimal,
Col_51 string(20),
Col_52 bytes(20)
Col_52 bytes(20),
Col_53 char(200) NULL,
Col_54 char(200) NOT NULL
);
""",
"database": None,
Expand Down Expand Up @@ -123,6 +125,8 @@
{"name": "Col_50", "type": "DECIMAL", "length": None, "scale": None},
{"name": "Col_51", "type": "STRING", "length": 20, "scale": None},
{"name": "Col_52", "type": "BYTES", "length": 20, "scale": None},
{"name": "Col_53", "type": "CHAR", "length": 200, "scale": None, "array_dimensional": 0, "is_unsigned": False, "is_zerofill": False, "not_null": False, "pk": False, "unique": False, "description": None},
{"name": "Col_54", "type": "CHAR", "length": 200, "scale": None, "array_dimensional": 0, "is_unsigned": False, "is_zerofill": False, "not_null": True, "pk": False, "unique": False, "constraint": "NOT NULL", "description": None},
],
"bq_field": [
'{"name": "Col_01", "type": "STRING", "mode": "REQUIRED"}',
Expand Down Expand Up @@ -177,6 +181,8 @@
'{"name": "Col_50", "type": "INTEGER", "mode": "NULLABLE"}',
'{"name": "Col_51", "type": "STRING", "mode": "NULLABLE"}',
'{"name": "Col_52", "type": "BYTES", "mode": "NULLABLE"}',
'{"name": "Col_53", "type": "STRING", "mode": "NULLABLE"}',
'{"name": "Col_54", "type": "STRING", "mode": "REQUIRED"}',
],
"bq_standard_data_type": [
"STRING",
Expand Down Expand Up @@ -231,6 +237,8 @@
"INT64",
"STRING",
"BYTES",
"STRING",
"STRING",
],
},

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py35,py36,py37,py38
envlist = py35,py36,py37,py38,py39

[testenv]
deps=
Expand Down