Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/199.canada.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Now properly handles string filtering for DataStore text array (`_text`) fields.
12 changes: 12 additions & 0 deletions ckanext/datastore/backend/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,18 @@ def _where_clauses(
# this fixes parity there.
value = (str(v) for v in value)
clause = (clause_str, dict(zip(placeholders, value)))
elif isinstance(value, str) and field_array_type:
# (canada fork only): transform string filters for _text type
# TODO: upstream contrib!!
value = [v.strip() for v in value.split(',')]
placeholders = [
f"value_{next(idx_gen)}" for _ in value
]
clause_str = ('{0} && ARRAY[{1}]'.format(
sa.column(field),
','.join(f":{p}" for p in placeholders)
))
clause = (clause_str, dict(zip(placeholders, value)))
else:
if fields_types[field] == 'text':
# pSQL can do int_field = "10"
Expand Down