code: def fields_for_model(self, model, include_fk=False, fields=None,
                           exclude=None, base_fields=None, dict_cls=dict):
          
          # this prevents an error when building the docs
          if not hasattr(model, '__mapper__'):
              return
  
          result = dict_cls()
          base_fields = base_fields or {}
          for prop in model.__mapper__.iterate_properties:
              if self._should_exclude_field(prop, fields=fields, exclude=exclude):
                  continue
  
              attr_name = prop.key
              if hasattr(prop, 'columns'):
                  if not include_fk:
                      # Only skip a column if there is no overridden column
                      # which does not have a Foreign Key.
                      for column in prop.columns:
                          if not column.foreign_keys:
                              break
                      else:
                          continue
  
                  col_name = prop.columns[0].name
                  if attr_name != col_name and hasattr(model, col_name):
                      attr_name = col_name
  
              field = base_fields.get(attr_name) or self.property2field(prop)
              if field:
                  result[attr_name] = field
          return result
docs: Overridden to correctly name hybrid_property fields, eg given::
  
              class User(db.Model):
                  _password = db.Column('password', db.String)
  
                  @db.hybrid_property
                  def password(self):
                      return self._password
  
                  @password.setter
                  def password(self, password):
                      self._password = hash_password(password)
  
          In this case upstream marshmallow_sqlalchemy uses '_password' for the
          field name, but we use 'password', as would be expected because it's
          the attribute name used for the public interface of the Model. In order
          for this logic to work, the column name must be specified and it must be
          the same as the hybrid property name. Otherwise we just fallback to the
          upstream naming convention.