diff --git a/library/think/Model.php b/library/think/Model.php index ce5c9017..3b95aad7 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -154,12 +154,19 @@ abstract class Model implements \JsonSerializable, \ArrayAccess if (!empty($this->field)) { if (true === $this->field) { - $this->field = $this->db()->getTableInfo('', 'type'); - } - if (is_array($this->field) && key($this->field) !== 0) { - $query->setFieldType($this->field); - $this->field = array_keys($this->field); + $type = $this->db()->getTableInfo('', 'type'); + } else { + $type = []; + foreach ((array) $this->field as $key => $val) { + if (is_int($key)) { + $key = $val; + $val = 'varchar'; + } + $type[$key] = $val; + } } + $query->setFieldType($type); + $this->field = array_keys($type); $query->allowField($this->field); }