Skip to content

Commit 271ed85

Browse files
committed
new sql for multi_select
1 parent c94f9f7 commit 271ed85

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Mergin/field_filtering.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from qgis.PyQt.QtWidgets import QListView
1111
from qgis.PyQt.QtGui import QMouseEvent
1212

13-
1413
SQL_PLACEHOLDER_VALUE = "@@value@@"
1514
SQL_PLACEHOLDER_VALUE_FROM = "@@value_from@@"
1615
SQL_PLACEHOLDER_VALUE_TO = "@@value_to@@"
@@ -168,9 +167,12 @@ def _generate_sql_expression(self) -> None:
168167
elif self.filter_type == FieldFilterType.CHECKBOX:
169168
expr = f"{field} = {SQL_PLACEHOLDER_VALUE}"
170169

171-
elif self.filter_type in (FieldFilterType.SINGLE_SELECT, FieldFilterType.MULTI_SELECT):
170+
elif self.filter_type == FieldFilterType.SINGLE_SELECT:
172171
expr = f"{field} IS {SQL_PLACEHOLDER_VALUE}"
173172

173+
elif self.filter_type == FieldFilterType.MULTI_SELECT:
174+
expr = f"(',' || TRIM(\"NAME_OF_FIELD\", '{{}}') || ',' ) LIKE '%,' || {SQL_PLACEHOLDER_VALUE} || ',%'"
175+
174176
else:
175177
expr = ""
176178

0 commit comments

Comments
 (0)