public function prepare($builder)
    {
        /** @var DynamicActiveRecord $modelClass */
        $modelClass = $this->modelClass;
        $this->_dynamicColumn = $modelClass::dynamicColumn();

        if (empty($this->_dynamicColumn)) {
            /** @var string $modelClass */
            throw new \yii\base\InvalidConfigException(
                $modelClass . '::dynamicColumn() must return an attribute name'
            );
        }

        if (empty($this->select)) {
            $this->select[] = '*';
        }

        if (is_array($this->select) && in_array('*', $this->select)) {
            $db = $modelClass::getDb();
            $this->select[$this->_dynamicColumn] =
                'COLUMN_JSON(' . $db->quoteColumnName($this->_dynamicColumn) . ')';
        }

        return parent::prepare($builder);
    }