Skip to content

Improve segment filters for custom data fields - #550

Open
pausan wants to merge 1 commit into
pentacent:mainfrom
gamehouse-eu:improved-custom-data-operators
Open

Improve segment filters for custom data fields#550
pausan wants to merge 1 commit into
pentacent:mainfrom
gamehouse-eu:improved-custom-data-operators

Conversation

@pausan

@pausan pausan commented Jul 26, 2026

Copy link
Copy Markdown

Segment filters on custom data (data.*) previously only offered matches, is empty and is not empty in the editor, even though the query layer supported more. This PR exposes the richer set and makes comparisons behave predictably.

UI (segment editor)

New operators for custom fields: starts with, ends with, includes, is greater than, is smaller than, is after date, is before date.

The value input adapts to the operator (text, number, or the existing date/time/timezone picker), and existing filters are correctly round-tripped back into the editor.

Query layer (Keila.Contacts.Query)
$gt/$gte/$lt/$lte on custom data now compare only when the stored value and the filter value are the same JSON type: numbers compare numerically, strings lexicographically, anything else never matches. Previously these fell back to PostgreSQL's JSONB type-rank ordering, which silently matched or excluded contacts based on type rather than value.
Documented the semantics and caveats (e.g. date strings must be ISO 8601 to sort correctly) in the module docs.

Tests

Added coverage for the new query semantics and for the editor's form ↔ filter conversions.
No migrations; existing filters keep working.

- Exposed custom data filters to the UI.
- Query filter improvements to performs more consistent comparisons
  by taking into account field types instead of failing silently.
- Added more tests for custom fields.
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.

1 participant