diff --git a/src/EntityTrait.php b/src/EntityTrait.php index c19077e..88cf5e0 100644 --- a/src/EntityTrait.php +++ b/src/EntityTrait.php @@ -207,10 +207,15 @@ trait EntityTrait { $this->{$field['name']} = null; } elseif ( $field['type'] === 'array' ) { - $this->{$field['name']} = substr($value, 0, 1) === "a" ? unserialize($value) : json_decode($value, true); + if ( is_string($value)) { + $this->{$field['name']} = substr($value, 0, 1) === "a" ? unserialize($value) : json_decode($value, true); + } + elseif ( is_array($value) ) { + $this->{$field['name']} = $value; + } } elseif ( EntityField::isScalarType($field['type']) ) { - + if ( $field['type'] === 'string' ) { $annotation = $entityResolver->searchFieldAnnotation($field['name'], new Field() ); diff --git a/src/Query/Where.php b/src/Query/Where.php index 736d5ec..e8896a8 100644 --- a/src/Query/Where.php +++ b/src/Query/Where.php @@ -67,7 +67,7 @@ class Where extends Fragment { } return $this->renderSegments([ - ! $this->parent ? static::SQL_TOKEN : "", + ! $this->parent && ! empty($this->conditionList) ? static::SQL_TOKEN : "", implode(" ", $stack) ]); }