Skip to content

Commit e9ed224

Browse files
committed
fix(Filter.remap_fields): fix capital letters in meta fields being ignored; adjust tests
#284 (comment)
1 parent bd5e898 commit e9ed224

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

tagstudio/src/core/library.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2450,6 +2450,12 @@ def remap_fields(self, entry: Entry) -> dict[str | int, str]:
24502450
for key, value in field.items():
24512451
key_mapped = self._field_id_to_name_map.get(int(key))
24522452
key_type = self.get_field_obj(key)["type"]
2453+
if isinstance(value, str):
2454+
value = value.casefold()
2455+
elif isinstance(value, list):
2456+
for i in value:
2457+
if isinstance(i, str):
2458+
i = i.casefold()
24532459
if (
24542460
key_type != "tag_box"
24552461
and key_mapped != "author"

tagstudio/tests/core/test_search.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@
7171
[{key_unbound: ["tag1"], key_empty: ["description"]}, {"description": "desc"}],
7272
),
7373
("; no author", [{key_unbound: ["no", "author"]}]),
74-
("description: Foo", [{"description": "foo"}])
74+
("description: Foo", [{"description": "foo"}]),
7575
]
7676

7777
remap_cases: list[tuple] = [
7878
(test_entry_one, {"tags": [1000, 1001], "author": ["James"]}),
7979
(test_entry_two, {}),
80-
(test_entry_three, {"tags": [1001], "description": ["Foo description"]}),
80+
(test_entry_three, {"tags": [1001], "description": ["foo description"]}),
8181
(test_entry_four, {"author": ["Victor"], "description": ["description"]}),
8282
(test_entry_five, {"author": ["Victor", "James"]}),
8383
]
@@ -157,10 +157,10 @@
157157
)
158158

159159
filter_case_six: tuple = (
160-
[{"description": "foo"}],
161-
SearchMode.OR,
162-
[(ItemType.ENTRY, 2), (ItemType.ENTRY, 5)]
163-
)
160+
[{"description": "foo"}],
161+
SearchMode.OR,
162+
[(ItemType.ENTRY, 2), (ItemType.ENTRY, 5)],
163+
)
164164

165165
negative_filter_case_one: tuple = (
166166
[{key_empty: "description"}],
@@ -180,7 +180,6 @@
180180
[
181181
(ItemType.ENTRY, 0),
182182
(ItemType.ENTRY, 1),
183-
(ItemType.ENTRY, 2),
184183
(ItemType.ENTRY, 3),
185184
(ItemType.ENTRY, 4),
186185
],

0 commit comments

Comments
 (0)