nextcloud / tables

🍱 Nextcloud tables app
https://apps.nextcloud.com/apps/tables
GNU Affero General Public License v3.0
148 stars 23 forks source link

Filter views with magic values seem broken #869

Closed juliusknorr closed 8 months ago

juliusknorr commented 8 months ago

Looks like this no longer works (on our apps table for example):

| 12 |      182 | My apps | ?     |             | max        | 2023-09-18 11:50:26 | andy         | 2023-12-19 16:22:15 | [974,977,975,976,969,973,971,972,964,980] | []   | [[{"columnId":976,"operator":"contains","value":"@me"}],[{"columnId":975,"operator":"is-equal","value":"@me"}]] |
juliusknorr commented 8 months ago

We used to search case insensitive before but now we match exactly which is likely more the expected behaviour of a contains filter.

For our use case we should actually rather start implementing https://github.com/nextcloud/tables/issues/586

As a quick fix we could change the matching to insensitive or maybe rather split for two different filter comparisons

juliusknorr commented 8 months ago

Quick hotfix could be this but needs some further checks if this doesn't have any sideeffects:

diff --git a/lib/Db/Row2Mapper.php b/lib/Db/Row2Mapper.php
index f34ef722..2be83e1e 100644
--- a/lib/Db/Row2Mapper.php
+++ b/lib/Db/Row2Mapper.php
@@ -329,7 +329,7 @@ class Row2Mapper {
                                                $qb->expr()->like('value', $qb->createNamedParameter('%,'.$this->db->escapeLikeParameter($value).',%'))
                                        ));
                                }
-                               return $qb2->andWhere($qb->expr()->like('value', $qb->createNamedParameter('%'.$this->db->escapeLikeParameter($value).'%', $paramType)));
+                               return $qb2->andWhere($qb->expr()->ilike('value', $qb->createNamedParameter('%'.$this->db->escapeLikeParameter($value).'%', $paramType)));
                        case 'is-equal':
                                if ($column->getType() === 'selection' && $column->getSubtype() === 'multi') {
                                        $value = str_replace(['"', '\''], '', $value);
juliusknorr commented 8 months ago

Duplicate of #868