Skip to content

Commit

Permalink
Fix #27 PostgreSQL indeterminate datatype error in console schedule l…
Browse files Browse the repository at this point in the history
…ogs output
  • Loading branch information
panlatent committed Jun 15, 2024
1 parent 9871a20 commit be3ce62
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/schedules/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,15 @@ protected function execute(int $logId = null): bool
{
$process = new Process($this->buildCommand(), dirname(Craft::$app->request->getScriptFile()), null, null, $this->timeout ?: null);

$process->run(function ($type, $buffer) use ($logId) {
// https://stackoverflow.com/questions/49033241/postgresql-sqlstate42p18-indeterminate-datatype-with-pdo-and-concat
$contactExpression = Craft::$app->getDb()->getIsMysql() ? 'CONCAT([[output]],:output)' : '[[output]] || :output';

$process->run(function ($type, $buffer) use ($logId, $contactExpression) {
$output = $buffer . "\n";
Craft::$app->getDb()->createCommand()
->update(Table::SCHEDULELOGS, [
'status' => self::STATUS_PROCESSING,
'output' => new Expression("CONCAT([[output]],:output)", ['output' => $output]),
'output' => new Expression($contactExpression, ['output' => $output]),
], [
'id' => $logId,
])
Expand Down

0 comments on commit be3ce62

Please sign in to comment.