Yii2: Object of class yii\db\JsonExpression could not be converted to string using batchInsert

Created on 17 Feb 2018  Â·  3Comments  Â·  Source: yiisoft/yii2

What steps will reproduce the problem?

postgres field contains jsonb type, trying to make batch Insert using: createCommand()->batchInsert()->execute();

What is the expected result?

Insert fields into DB table

What do you get instead?

Error message:

HP Recoverable Error – yii\base\ErrorException
Object of class yii\db\JsonExpression could not be converted to string

  1. in /private/var/www/zzz/www/vendor/yiisoft/yii2/db/pgsql/QueryBuilder.php at line 466
    $value = 'FALSE';
    } elseif ($value === null) {
    $value = 'NULL';
    }
    $vs[] = $value;
    }
    $values[] = '(' . implode(', ', $vs) . ')';
    }
    if (empty($values)) {
    return '';
    }
    foreach ($columns as $i => $name) {
        $columns[$i] = $schema->quoteColumnName($name);
    }

Additional info

looks like _tostring pattern have to be implemented

bug

Most helpful comment

Will handle

All 3 comments

Will handle

Same issue with Command::update() method.

@khvalov please open new issue. Thanks.

Was this page helpful?
0 / 5 - 0 ratings