Skip to content

fix: handle in/notin operators in token search filters#1656

Open
rohilsurana wants to merge 2 commits into
mainfrom
token-page-filters
Open

fix: handle in/notin operators in token search filters#1656
rohilsurana wants to merge 2 commits into
mainfrom
token-page-filters

Conversation

@rohilsurana
Copy link
Copy Markdown
Member

Summary

  • Add explicit in/notin operator handling in OrgTokensRepository.addFilter
  • The in operator requires splitting comma-separated string values into a slice for goqu's In() method
  • Without this, goqu.Op{"in": "system.buy"} generates invalid SQL — it passes a raw string instead of a list to IN ()
  • Same pattern as OrgBillingRepository.addRQLFiltersInQuery which already handles this correctly

Root cause

The DataTable multiselect filter sends operator: "in" with stringValue: "system.buy" (comma-separated for multiple values). The addFilter default case passes this directly to goqu as goqu.Op{"in": filter.Value}, but goqu's in needs a slice, not a string. The fix splits the value by commas before passing to In()/NotIn().

Test plan

  • Open tokens page → Filter → Event → select "Recharge" → verify filtered results appear
  • Select multiple event types → verify comma-separated values filter correctly
  • Use "is not" operator → verify notin works

@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment May 27, 2026 10:10am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 039e7054-518a-4165-aabc-a5fecd10c7f8

📥 Commits

Reviewing files that changed from the base of the PR and between 8aadd5b and 3aba0ed.

📒 Files selected for processing (1)
  • internal/store/postgres/org_tokens_repository.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/store/postgres/org_tokens_repository.go

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Organization token filtering now supports "in" and "notin" operators, allowing selection or exclusion by multiple comma-separated values. Input values are trimmed and empty entries ignored, making multi-value filters more forgiving and reliable. This improves list filtering precision when searching for or excluding specific token attributes.

Walkthrough

The PR extends OrgTokensRepository.addFilter to support "in" and "notin" operators by parsing comma-separated values (using strings) and generating TEXT-cast SQL IN/NOT IN predicates from the resulting list.

Changes

Filter Operator Extension

Layer / File(s) Summary
In/NotIn filter operators implementation
internal/store/postgres/org_tokens_repository.go
OrgTokensRepository.addFilter now handles "in" and "notin" by splitting comma-separated values, trimming and discarding empties, casting the target to TEXT, and emitting IN/NOT IN predicates; strings imported to support parsing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • rsbh
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e693f884-d065-4e95-abdd-bb22f50d3118

📥 Commits

Reviewing files that changed from the base of the PR and between e399d9c and 8aadd5b.

📒 Files selected for processing (1)
  • internal/store/postgres/org_tokens_repository.go

Comment thread internal/store/postgres/org_tokens_repository.go Outdated
@coveralls
Copy link
Copy Markdown

coveralls commented May 27, 2026

Coverage Report for CI Build 26504858608

Coverage decreased (-0.02%) to 42.831%

Details

  • Coverage decreased (-0.02%) from the base build.
  • Patch coverage: 14 uncovered changes across 1 file (0 of 14 lines covered, 0.0%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
internal/store/postgres/org_tokens_repository.go 14 0 0.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 37860
Covered Lines: 16216
Line Coverage: 42.83%
Coverage Strength: 11.99 hits per line

💛 - Coveralls

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