From 0e250e56ec3a5b569936d5489f2c5a68f3182731 Mon Sep 17 00:00:00 2001 From: Romain 'Maz' BILLOIR Date: Mon, 10 Feb 2025 00:33:42 +0000 Subject: [PATCH] Fix SqliteAdapter wrong week format --- src/Adapters/SqliteAdapter.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Adapters/SqliteAdapter.php b/src/Adapters/SqliteAdapter.php index 3e17022..d45ef81 100644 --- a/src/Adapters/SqliteAdapter.php +++ b/src/Adapters/SqliteAdapter.php @@ -8,6 +8,12 @@ class SqliteAdapter extends AbstractAdapter { public function format(string $column, string $interval): string { + // Fix wrong week date format after SQLite v3.46 + // Using coalesce for backward compatibility + if ($interval === 'week') { + return "coalesce(strftime('%G-%V', {$column}), strftime('%Y-%W', {$column}))"; + } + $format = match ($interval) { 'minute' => '%Y-%m-%d %H:%M:00', 'hour' => '%Y-%m-%d %H:00',