Skip to content

Commit aff2a5c

Browse files
committed
Fixed crash on unrecognized column types
Fixes agronholm#72.
1 parent 0d2fc04 commit aff2a5c

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ UNRELEASED
77
* Dropped support for Python 3.4
88
* Added support for Python 3.7 and 3.8
99
* Added support for SQLAlchemy 1.3
10+
* Fixed crash on unknown column types (``NullType``)
1011

1112

1213
2.0.1

sqlacodegen/codegen.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
Enum, ForeignKeyConstraint, PrimaryKeyConstraint, CheckConstraint, UniqueConstraint, Table,
1616
Column, Float)
1717
from sqlalchemy.schema import ForeignKey
18+
from sqlalchemy.sql.sqltypes import NullType
1819
from sqlalchemy.types import Boolean, String
1920
from sqlalchemy.util import OrderedDict
2021

@@ -88,7 +89,8 @@ def __init__(self, table):
8889

8990
# Adapt column types to the most reasonable generic types (ie. VARCHAR -> String)
9091
for column in table.columns:
91-
column.type = self._get_adapted_type(column.type, column.table.bind)
92+
if not isinstance(column.type, NullType):
93+
column.type = self._get_adapted_type(column.type, column.table.bind)
9294

9395
def _get_adapted_type(self, coltype, bind):
9496
compiled_type = coltype.compile(bind.dialect)

0 commit comments

Comments
 (0)