Repository: kayak/pypika
Pull request #496 (2020-09-29 08:17:46)

Added value wrapping for column defaults
I think this is the change you wanted @mikeengland 

Before this column defaults had to be a `Term`, meaning that a simple value had to be wrapped. e.g.

```python
a = Column("a", "INT", default=ValueWrapper(42))
```

This change will wrap non `None` `Term`s

```python
a = Column("a", "INT", default=42)
```



Patch:
diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml
index cc3ef91..eb5d5b7 100644
--- a/.github/workflows/pythonpackage.yml
+++ b/.github/workflows/pythonpackage.yml
@@ -30,10 +30,24 @@ jobs:
       - name: Run test suite
         run: tox
 
-      - name: Generate coverage report
-        uses: codecov/codecov-action@v1
+      # Uncomment when Black is setup for PyPika
+      #    - name: Run Black code formatter check
+      #      run: black --check .
+
+      - name: Coveralls
+        # Official Coveralls GitHub action does not work with Python coverage files!
+        # https://github.com/coverallsapp/github-action/issues/30
+        uses: AndreMiras/coveralls-python-action@v20200413
+        with:
+          parallel: true
+          debug: true
+
+  coveralls_finish:
+    needs: test
+    runs-on: ubuntu-latest
+    steps:
+      - name: Coveralls Finished
+        uses: AndreMiras/coveralls-python-action@develop
         with:
-          file: ./coverage.xml
-          flags: unittests
-          name: codecov-umbrella
-          fail_ci_if_error: true
+          parallel-finished: true
+          debug: true
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..3365797
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,28 @@
+language: python
+
+python:
+    - "3.6"
+    - "3.7"
+    - "3.8"
+    - "3.9-dev"
+    - "nightly"
+
+matrix:
+  allow_failures:
+      - python: "nightly"
+      - python: "3.9-dev"
+  include:
+  - python: "pypy3.5"
+    dist: xenial
+
+install:
+    - "python setup.py install"
+    - "pip install coverage"
+    - "pip install coveralls"
+    - "pip install parameterized==0.7.0"
+
+script:
+    - "coverage run --source=pypika setup.py test"
+
+after_success:
+    coveralls
diff --git a/README.rst b/README.rst
index 4922a8f..3a624b2 100644
--- a/README.rst
+++ b/README.rst
@@ -1307,8 +1307,8 @@ Crafted with ♥ in Berlin.
 
 .. |BuildStatus| image:: https://github.com/kayak/pypika/workflows/Unit%20Tests/badge.svg
    :target: https://github.com/kayak/pypika/actions
-.. |CoverageStatus| image:: https://codecov.io/gh/kayak/pypika/branch/master/graph/badge.svg
-   :target: https://codecov.io/gh/kayak/pypika
+.. |CoverageStatus| image:: https://coveralls.io/repos/kayak/pypika/badge.svg?branch=master
+   :target: https://coveralls.io/github/kayak/pypika?branch=master
 .. |Codacy| image:: https://api.codacy.com/project/badge/Grade/6d7e44e5628b4839a23da0bd82eaafcf
    :target: https://www.codacy.com/app/twheys/pypika
 .. |Docs| image:: https://readthedocs.org/projects/pypika/badge/?version=latest
diff --git a/pypika/queries.py b/pypika/queries.py
index 2b9ee81..03a3ad1 100644
--- a/pypika/queries.py
+++ b/pypika/queries.py
@@ -275,12 +275,12 @@ class Column:
         column_name: str,
         column_type: Optional[str] = None,
         nullable: Optional[bool] = None,
-        default: Optional[Term] = None,
+        default: Optional[Union[Any, Term]] = None,
     ) -> None:
         self.name = column_name
         self.type = column_type
         self.nullable = nullable
-        self.default = default
+        self.default = default if default is None or isinstance(default, Term) else ValueWrapper(default)
 
     def get_name_sql(self, **kwargs: Any) -> str:
         quote_char = kwargs.get("quote_char")
diff --git a/tox.ini b/tox.ini
index 77bd09e..05d7575 100644
--- a/tox.ini
+++ b/tox.ini
@@ -4,7 +4,7 @@ envlist = py36,py37,py38,py39,pypy3
 deps = -r requirements-dev.txt
 commands =
     coverage run
-    coverage xml
+    coverage report
 [gh-actions]
 python =
     3.6: py36


Test patch:
diff --git a/pypika/tests/test_create.py b/pypika/tests/test_create.py
index 556ff69..17b1770 100644
--- a/pypika/tests/test_create.py
+++ b/pypika/tests/test_create.py
@@ -23,6 +23,13 @@ class CreateTableTests(unittest.TestCase):
 
             self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q))
 
+        with self.subTest("with unwrapped defaults"):
+            a = Column("a", "INT", default=42)
+            b = Column("b", "VARCHAR(100)", default="foo")
+            q = Query.create_table(self.new_table).columns(a, b)
+
+            self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q))
+
         with self.subTest("with period for"):
             a = Column("id", "INT")
             b = Column("valid_from", "DATETIME")