fix: 按数值类型还原汇总连接设置

This commit is contained in:
WuYongJie 2026-09-09 19:34:38 +08:00
parent f484fab7eb
commit 535902c8f3

View File

@ -230,7 +230,7 @@ class CourierFreightReconciliationMirrorRepository
}
foreach ($settings as $name => $value) {
$previousSettings[$name] = $this->connection->selectOne('SELECT @@SESSION.' . $name . ' AS value')->value;
$this->connection->statement('SET SESSION ' . $name . '=?', [$value]);
$this->setSummarySessionSetting($name, $value);
}
}
$asOf = now()->toDateTimeString();
@ -243,7 +243,7 @@ class CourierFreightReconciliationMirrorRepository
} finally {
try {
foreach (array_reverse($previousSettings, true) as $name => $value) {
$this->connection->statement('SET SESSION ' . $name . '=?', [$value]);
$this->setSummarySessionSetting($name, $value);
}
} finally {
$lock->release();
@ -251,6 +251,17 @@ class CourierFreightReconciliationMirrorRepository
}
}
private function setSummarySessionSetting(string $name, mixed $value): void
{
if ($name === 'optimizer_switch') {
$this->connection->statement('SET SESSION optimizer_switch=?', [$value]);
return;
}
// MariaDB rejects quoted numeric values for these session variables.
// Names come only from the fixed settings map above.
$this->connection->statement('SET SESSION ' . $name . '=' . (float) $value);
}
private function summaryCacheKey(array $filters): string
{
$filters = array_filter(array_map(static fn ($value): string => trim((string) $value), $filters), static fn (string $value): bool => $value !== '');