Skip to content
Closed
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
7 changes: 4 additions & 3 deletions flask_appbuilder/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ def __init__(
self.default = default

def convert(self):
col_type = self.datamodel.list_columns[self.colname].type

# sqlalchemy.types.Enum inherits from String, therefore `is_enum` must be
# checked before checking for `is_string`:
if getattr(self.datamodel, "is_enum")(self.colname):
col_type = self.datamodel.list_columns[self.colname].type
if self.datamodel.is_enum(self.colname):
return EnumField(
enum_class=col_type.enum_class,
enums=col_type.enums,
Expand All @@ -104,7 +105,7 @@ def convert(self):
validators=self.validators,
default=self.default,
)
log.error("Column %s Type not supported", self.colname)
log.error("Column %s with type %s not supported", self.colname, col_type)


class GeneralModelConverter(object):
Expand Down
2 changes: 1 addition & 1 deletion flask_appbuilder/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __getattr__(self, name: str) -> Any:
Make mypy happy about the injected filters like self.datamodel.FilterEqual
https://mypy.readthedocs.io/en/latest/cheat_sheet_py3.html#when-you-re-puzzled-or-when-things-are-complicated
"""
return super().__getattr__(name)
raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'")

def _get_attr(self, col_name):
if not hasattr(self.obj, col_name):
Expand Down
Loading