Skip to content

Conversation

@alex-feel
Copy link
Owner

No description provided.

Add array_contains operator for metadata filtering to support searching within array fields. The operator uses json_each() for SQLite and jsonb_array_elements_text()/@> for PostgreSQL.

Key implementation details:
- SQLite: json_type() check before json_each() to prevent errors on non-arrays
- PostgreSQL: CASE WHEN jsonb_typeof() = 'array' wrapping to return FALSE instead of throwing "cannot extract elements from a scalar" error
- Support for case-insensitive string matching
- Support for boolean, integer, float values in arrays
- Support for nested paths (e.g., references.context_ids)

The graceful handling ensures array_contains returns empty results (not errors) when used on scalar, object, null, or missing fields.
@github-actions
Copy link

github-actions bot commented Jan 5, 2026

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  app
  metadata_types.py
  query_builder.py 569-571
Project Total  

This report was generated by python-coverage-comment-action

@alex-feel alex-feel merged commit 23c6c2b into main Jan 5, 2026
6 checks passed
@alex-feel alex-feel deleted the alex-feel-dev branch January 5, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants