From bb70576b464d4872e8cd2bc2f048b64208a49217 Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 20 Mar 2023 14:48:37 +0100 Subject: [PATCH] Fix/v0.3.3 (#168) * fix(db): rewrite json specific query for postgres backends #162 (#167) Signed-off-by: Florian Steffens * refactor(DI): replace DI method to get system configs Signed-off-by: Florian Steffens * chore(release): bump version number and changelog Signed-off-by: Florian Steffens --------- Signed-off-by: Florian Steffens --- CHANGELOG.md | 6 ++++++ appinfo/info.xml | 2 +- lib/AppInfo/Application.php | 4 ++-- lib/Db/RowMapper.php | 10 +++++++++- package-lock.json | 4 ++-- package.json | 2 +- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f74cdb04c..2bfdb6aef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.3.3 - 2023-03-20 +### Updated +- Fix for deleting columns on postgres db backend #162 +- Update dependencies +- Update translation + ## 0.3.2 - 2023-03-15 ### Updated - Add hints for translation #152 diff --git a/appinfo/info.xml b/appinfo/info.xml index 5b92a389e..e4b35dadd 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -21,7 +21,7 @@ Share your tables with users and groups within your cloud. Have a good time and manage whatever you want. ]]> - 0.3.2 + 0.3.3 agpl Florian Steffens Tables diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 2b608755f..aa4f9bc91 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -2,6 +2,7 @@ namespace OCA\Tables\AppInfo; +use OCP\Server; use OCA\Tables\Listener\UserDeletedListener; use OCA\Tables\Listener\AnalyticsDatasourceListener; use OCA\Tables\Listener\TablesReferenceListener; @@ -34,10 +35,9 @@ public function register(IRegistrationContext $context): void { $context->registerSearchProvider(SearchTablesProvider::class); - $container = $this->getContainer(); try { /** @var IConfig $config */ - $config = $container->get(IConfig::class); + $config = Server::get(IConfig::class); if (version_compare($config->getSystemValueString('version', '0.0.0'), '26.0.0', '<')) { $context->registerReferenceProvider(TableReferenceProvider::class); } else { diff --git a/lib/Db/RowMapper.php b/lib/Db/RowMapper.php index e53995115..c6faa3a94 100644 --- a/lib/Db/RowMapper.php +++ b/lib/Db/RowMapper.php @@ -76,7 +76,15 @@ public function findAllWithColumn(int $columnId): array { $qb = $this->db->getQueryBuilder(); $qb->select('*') ->from($this->table); - $qb->where('JSON_CONTAINS(JSON_EXTRACT(data, \'$[*].columnId\'), :columnId, \'$\') = 1'); + + if (str_contains(strtolower(get_class($this->db->getDatabasePlatform())), 'postgres')) { + // due to errors using doctrine with json, I paste the columnId inline. + // columnId is a number, ensured by the parameter definition + $qb->where('data::jsonb @> \'[{"columnId": '.$columnId.'}]\'::jsonb'); + } else { + $qb->where('JSON_CONTAINS(JSON_VALUE(data, \'$.columnId\'), :columnId, \'$\') = 1'); + } + $qb->setParameter('columnId', $columnId); return $this->findEntities($qb); } diff --git a/package-lock.json b/package-lock.json index 73c68d6a5..f8e04488d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tables", - "version": "0.3.2", + "version": "0.3.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "tables", - "version": "0.3.2", + "version": "0.3.3", "license": "agpl", "dependencies": { "@nextcloud/auth": "^2.0.0", diff --git a/package.json b/package.json index 617e71214..ba6177fd7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "tables", "description": "Manage data within tables.", - "version": "0.3.2", + "version": "0.3.3", "author": "Florian Steffens