Repository: shinichi-takii/ddlparse

Issue:
Parsing failure for columns include dot at default values
# Requirements
* Parsing failure for columns include dot at default values.

## Example code

```python
# -*- coding: utf-8 -*-

from ddlparse import DdlParse

sample_ddl = """
CREATE TABLE Sample_Table (
  Col_01 varchar(100),
  Col_02 char(200),
  Col_03 integer,
  Col_04 double,
  Col_05 datetime,
  Col_06 decimal(2,1) not null default '0.0',
  Col_07 integer,
  CONSTRAINT const_01 PRIMARY KEY (Col_01, Col_02),
  CONSTRAINT \"const_02\" UNIQUE (Col_03, Col_04),
  CONSTRAINT \"const_03\" FOREIGN KEY (Col_04, \"Col_05\") REFERENCES ref_table_01 (\"Col_04\", Col_05)
);
"""
parser = DdlParse(sample_ddl)
table = parser.parse()


print("* BigQuery Fields * : normal")
print(table.to_bigquery_fields())
```

## Output

Parsing stops at Col_06...

```json
[{"name": "Col_01", "type": "STRING", "mode": "NULLABLE"},{"name": "Col_02", "type": "STRING", "mode": "NULLABLE"},{"name": "Col_03", "type": "INTEGER", "mode": "NULLABLE"},{"name": "Col_04", "type": "FLOAT", "mode": "NULLABLE"},{"name": "Col_05", "type": "DATETIME", "mode": "NULLABLE"},{"name": "Col_06", "type": "FLOAT", "mode": "REQUIRED"}]
```



Discussion:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index adef029..aca4078 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,13 @@
 # Changelog
+All notable changes to the "ddlparse" module will be documented in this file.
+
+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.3.1] - 2019-12-05
+### Fixed
+- Fixed parsing failure for columns include dot at default values.
 
 ## [1.3.0] - 2019-06-15
 ### Added
@@ -8,17 +17,22 @@
 - Add supports column comments in BigQuery DDL.
 
 ## [1.2.3] - 2019-02-17
+### Fixed
 - Fix parse error for MySQL DDL with 'FOREIGN KEY'.
 - Fix not completely parsed with block comments.
 
 ## [1.2.2] - 2019-02-02
-- Fix FutureWarning of Python 3.7.
+### Added
 - Add supports PostgreSQL data type.
     - `UUID`
+
+### Fixed
+- Fix FutureWarning of Python 3.7.
 - Fix parse `DEFAULT` value.
     - Add parse regex of `DEFAULT` value.
 
 ## [1.2.1] - 2019-01-27
+### Added
 - Add supports for Python 3.7.
     - Pass Python 3.7 test.
 - Add supports PostgreSQL data type.
@@ -29,6 +43,7 @@
     - Add decimal point to `DEFAULT` parse character.
 
 ## [1.2.0] - 2019-01-02
+### Added
 - Add `DdlParseTable.to_bigquery_ddl` function.
     - BigQuery DDL (CREATE TABLE) statement generate function.
 - Add `DdlParseColumn.bigquery_legacy_data_type` property.
@@ -38,38 +53,50 @@
     - Get BigQuery Standard SQL data property.
 
 ## [1.1.3] - 2018-08-02
+### Added
 - Add support inline comment.
 - Add support constraint name with quotes.
 - Add support Oracle Length Semantics for Character Datatypes.
 
 ## [1.1.2] - 2018-03-25
+### Added
 - Add support Oracle data type.
     - `CLOB`, `NCLOB`
     - `NUMBER` with no length & scale specification
+
+### Fixed
 - Miner fix.
 
 ## [1.1.1] - 2018-03-25
+### Fixed
 - Fix Postgres/Redshift parse of "::" syntax in field attribute.
 
 ## [1.1.0] - 2018-01-14
+### Added
 - Add `source_database` option.
 - Add `to_bigquery_fields` method to Columns dicttionary(`DdlParseColumnDict` class).
+
+### Fixed
 - Fix BigQuery convert of Oracle data type.
     - Oracle 'DATE' -> BigQuery 'DATETIME'
     - Oracle 'NUMBER' -> BigQuery 'INTEGER' or 'FLOAT'
 
 ## [1.0.2] - 2018-01-09
+### Fixed
 - Miner enhancement.
     - `ddlparse.py` : Exclude unused module.
     - `example.py` : Modified comment.
     - `README.md` : Miner fix.
 
 ## [1.0.1] - 2018-01-07
+### Fixed
 - Miner enhancement.
 
 ## [1.0.0]
+### Added
 - Initial released.
 
+[1.3.1]: https://github.com/shinichi-takii/ddlparse/compare/v1.3.0...v1.3.1
 [1.3.0]: https://github.com/shinichi-takii/ddlparse/compare/v1.2.3...v1.3.0
 [1.2.3]: https://github.com/shinichi-takii/ddlparse/compare/v1.2.2...v1.2.3
 [1.2.2]: https://github.com/shinichi-takii/ddlparse/compare/v1.2.1...v1.2.2
diff --git a/ddlparse/__init__.py b/ddlparse/__init__.py
index d19584b..e7f3440 100644
--- a/ddlparse/__init__.py
+++ b/ddlparse/__init__.py
@@ -8,7 +8,7 @@
 from .ddlparse import *
 
 __copyright__    = 'Copyright (C) 2018-2019 Shinichi Takii'
-__version__      = '1.3.0'
+__version__      = '1.3.1'
 __license__      = 'BSD-3-Clause'
 __author__       = 'Shinichi Takii'
 __author_email__ = 'shinichi.takii@gmail.com'
diff --git a/ddlparse/ddlparse.py b/ddlparse/ddlparse.py
index a4ac93c..44b133c 100644
--- a/ddlparse/ddlparse.py
+++ b/ddlparse/ddlparse.py
@@ -524,7 +524,7 @@ class DdlParse(DdlParseBase):
                         + Optional(_LPAR + Regex(r"\d+\s*,*\s*\d*") + Optional(Suppress(_CHAR_SEMANTICS | _BYTE_SEMANTICS)) + _RPAR)
                         )("type")
                     + Optional(Word(r"\[\]"))("array_brackets")
-                    + Optional(Regex(r"(?!--)(\b(COMMENT|DEFAULT)\b\s+[^,]+|([A-Za-z0-9_'\": -]|[^\x01-\x7E])*)", re.IGNORECASE))("constraint")
+                    + Optional(Regex(r"(?!--)(\b(COMMENT|DEFAULT)\b\s+[^,]+|([A-Za-z0-9_\.'\": -]|[^\x01-\x7E])*)", re.IGNORECASE))("constraint")
                 )("column")
                 |
                 _COMMENT
diff --git a/setup.cfg b/setup.cfg
index a5988c6..dddb9d5 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,2 +1,2 @@
 [tool:pytest]
-addopts = -vs --maxfail=2 --showlocal --durations=0 --cov-report term-missing --cov ./ddlparse
+addopts = -vs --maxfail=2 --showlocals --durations=0 --cov-report term-missing --cov ./ddlparse


Test patch:
diff --git a/test-requirements.txt b/test-requirements.txt
index f2afa18..bae867f 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -1,5 +1,6 @@
 pytest>=3.6
 pytest-cov
+tox
 coveralls
 codecov
 codeclimate-test-reporter
diff --git a/test/test_ddlparse.py b/test/test_ddlparse.py
index 944ac17..9bf5a76 100644
--- a/test/test_ddlparse.py
+++ b/test/test_ddlparse.py
@@ -152,6 +152,8 @@ TEST_DATA = {
               Col_03 integer,
               Col_04 double,
               Col_05 datetime,
+              Col_06 decimal(2,1) not null default '0.0',
+              Col_07 integer,
               CONSTRAINT const_01 PRIMARY KEY (Col_01, Col_02),
               CONSTRAINT \"const_02\" UNIQUE (Col_03, Col_04),
               CONSTRAINT \"const_03\" FOREIGN KEY (Col_04, \"Col_05\") REFERENCES ref_table_01 (\"Col_04\", Col_05)
@@ -165,6 +167,8 @@ TEST_DATA = {
             {"name" : "Col_03", "type" : "INTEGER", "length" : None, "scale" : None, "array_dimensional" : 0, "not_null" : False, "pk" : False, "unique" : True, "constraint" : "UNIQUE", "description" : None},
             {"name" : "Col_04", "type" : "DOUBLE", "length" : None, "scale" : None, "array_dimensional" : 0, "not_null" : False, "pk" : False, "unique" : True, "constraint" : "UNIQUE", "description" : None},
             {"name" : "Col_05", "type" : "DATETIME", "length" : None, "scale" : None, "array_dimensional" : 0, "not_null" : False, "pk" : False, "unique" : False, "constraint" : "", "description" : None},
+            {"name" : "Col_06", "type" : "DECIMAL", "length" : 2, "scale" : 1, "array_dimensional" : 0, "not_null" : True, "pk" : False, "unique" : False, "constraint" : "NOT NULL", "description" : None},
+            {"name" : "Col_07", "type" : "INTEGER", "length" : None, "scale" : None, "array_dimensional" : 0, "not_null" : False, "pk" : False, "unique" : False, "constraint" : "", "description" : None},
         ],
         "bq_field" : [
             '{"name": "Col_01", "type": "STRING", "mode": "REQUIRED"}',
@@ -172,6 +176,8 @@ TEST_DATA = {
             '{"name": "Col_03", "type": "INTEGER", "mode": "NULLABLE"}',
             '{"name": "Col_04", "type": "FLOAT", "mode": "NULLABLE"}',
             '{"name": "Col_05", "type": "DATETIME", "mode": "NULLABLE"}',
+            '{"name": "Col_06", "type": "FLOAT", "mode": "REQUIRED"}',
+            '{"name": "Col_07", "type": "INTEGER", "mode": "NULLABLE"}',
         ],
         "bq_standard_data_type" : [
             "STRING",
@@ -179,6 +185,8 @@ TEST_DATA = {
             "INT64",
             "FLOAT64",
             "DATETIME",
+            "FLOAT64",
+            "INT64",
         ],
     },