diff --git a/appinfo/info.xml b/appinfo/info.xml index ecd525706..773b29cf9 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -42,6 +42,7 @@ Have a good time and manage whatever you want. pgsql mysql + sqlite diff --git a/lib/Db/ColumnTypes/SuperColumnQB.php b/lib/Db/ColumnTypes/SuperColumnQB.php index 81787eae8..0607dfd9c 100644 --- a/lib/Db/ColumnTypes/SuperColumnQB.php +++ b/lib/Db/ColumnTypes/SuperColumnQB.php @@ -23,8 +23,7 @@ public function formatCellValue(string $unformattedValue): string { if ($this->platform === self::DB_PLATFORM_PGSQL) { return 'LOWER('.$unformattedValue.')'; } elseif ($this->platform === self::DB_PLATFORM_SQLITE) { - // TODO DB BE SQLITE - return ''; + return $unformattedValue; } else { // mariadb / mysql return 'JSON_UNQUOTE(LOWER(' . $unformattedValue . '))'; } @@ -80,9 +79,9 @@ private function sqlFilterOperation(string $operator, string $formattedCellValue private function getFormattedDataCellValue(string $columnPlaceHolder, int $columnId): string { if ($this->platform === self::DB_PLATFORM_PGSQL) { - $cellValue = 'c'.intval($columnId).' ->> \'value\''; + $cellValue = 'c'.$columnId.' ->> \'value\''; } elseif ($this->platform === self::DB_PLATFORM_SQLITE) { - // TODO DB BE SQLITE + $cellValue = 'json_extract(t2.value, "$.columnId") = '.$columnId.' AND LOWER(json_extract(t2.value, "$.value"))'; } else { $cellValue = 'JSON_EXTRACT(data, CONCAT( JSON_UNQUOTE(JSON_SEARCH(JSON_EXTRACT(data, \'$[*].columnId\'), \'one\', :'.$columnPlaceHolder.')), \'.value\'))'; } @@ -134,8 +133,8 @@ public function addWhereFilterExpression(IQueryBuilder $qb, array $filter, strin if ($this->platform === self::DB_PLATFORM_PGSQL) { $sqlFilterString = $filterOperation; } elseif ($this->platform === self::DB_PLATFORM_SQLITE) { - // TODO DB BE SQLITE - $sqlFilterString = ''; + $qb->from($qb->createFunction('json_each(data) as t2')); + $sqlFilterString = $filterOperation; } else { // mariadb / mysql $sqlFilterString = $filterOperation; } diff --git a/lib/Db/RowMapper.php b/lib/Db/RowMapper.php index 6460a4b4f..a034d86e1 100644 --- a/lib/Db/RowMapper.php +++ b/lib/Db/RowMapper.php @@ -154,8 +154,8 @@ private function addOrderByRules(IQueryBuilder $qb, $sortArray) { if ($this->platform === IColumnTypeQB::DB_PLATFORM_PGSQL) { $orderString = 'c'.$sortRule['columnId'].'->>\'value\''; } elseif ($this->platform === IColumnTypeQB::DB_PLATFORM_SQLITE) { - // TODO DB BE SQLITE - $orderString = ''; + // here is an error for (multiple) sorting, works only for the first column at the moment + $orderString = 'json_extract(t2.value, "$.value")'; } else { // mariadb / mysql $orderString = 'JSON_EXTRACT(data, CONCAT( JSON_UNQUOTE(JSON_SEARCH(JSON_EXTRACT(data, \'$[*].columnId\'), \'one\', :'.$sortColumnPlaceholder.')), \'.value\'))'; }