fix: make util.get_model_fields()
work with more model classes
should not restrict to classes inheriting from wuttjamaican base, any sqlalchemy class should work
This commit is contained in:
parent
4643aa3e3c
commit
1efaca4e52
|
@ -462,14 +462,13 @@ def get_model_fields(config, model_class=None):
|
|||
if not model_class:
|
||||
return
|
||||
|
||||
app = config.get_app()
|
||||
model = app.model
|
||||
if not issubclass(model_class, model.Base):
|
||||
return
|
||||
|
||||
mapper = sa.inspect(model_class)
|
||||
fields = [prop.key for prop in mapper.iterate_properties]
|
||||
return fields
|
||||
try:
|
||||
mapper = sa.inspect(model_class)
|
||||
except sa.exc.NoInspectionAvailable:
|
||||
pass
|
||||
else:
|
||||
fields = [prop.key for prop in mapper.iterate_properties]
|
||||
return fields
|
||||
|
||||
|
||||
def make_json_safe(value, key=None, warn=True):
|
||||
|
|
Loading…
Reference in a new issue