Skip to content

fix: filter by text is case sensitive#1472

Open
paanSinghCoder wants to merge 10 commits intomainfrom
fix/operator-case-sensitive
Open

fix: filter by text is case sensitive#1472
paanSinghCoder wants to merge 10 commits intomainfrom
fix/operator-case-sensitive

Conversation

@paanSinghCoder
Copy link
Contributor

@paanSinghCoder paanSinghCoder commented Mar 23, 2026

Summary

Make organization like filters case-insensitive in Admin SearchOrganizations backend query handling.

Related PR - raystack/salt#83

Changes
Updated frontier/internal/store/postgres/org_billing_repository.go

  • like now uses ILIKE
  • notlike now uses NOT ILIKE

Added regression coverage in frontier/internal/store/postgres/org_billing_repository_test.go to assert title like generates ILIKE.

Why
Filtering organizations by title from /organizations returned different results for different casing (e.g. fah vs Fah). This aligns filter behavior with expected case-insensitive search.

Technical Details

Test Plan

  • Manual testing completed
  • Build and type checking passes

@vercel
Copy link

vercel bot commented Mar 23, 2026

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

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment Mar 26, 2026 6:41am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 23, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This pull request introduces case-insensitive string filtering through new ilike and notilike operators. The backend PostgreSQL repository adds these operators to filter processing with SQL ILIKE / NOT ILIKE comparisons, while the frontend removes special-case remapping logic that previously converted ilike to like.

Changes

Cohort / File(s) Summary
Backend filter operators
internal/store/postgres/org_billing_repository.go
Added ilike and notilike operator constants and extended processStringDataType to handle case-insensitive SQL comparisons with TEXT column casting.
Frontend filter handling
web/sdk/admin/utils/transform-query.ts
Removed conditional operator remapping logic that converted ilike to like based on filter value type; operator now passes through directly from filter definition.
Dependency management
go.mod
Updated github.com/raystack/salt from v0.6.2 to v0.6.3.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes


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.

@coveralls
Copy link

coveralls commented Mar 23, 2026

Pull Request Test Coverage Report for Build 23581110940

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 4 (0.0%) changed or added relevant lines in 1 file are covered.
  • 365 unchanged lines in 5 files lost coverage.
  • Overall coverage increased (+0.2%) to 41.229%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/store/postgres/org_billing_repository.go 0 4 0.0%
Files with Coverage Reduction New Missed Lines %
internal/api/v1beta1connect/organization.go 5 66.8%
internal/api/v1beta1connect/user_pat.go 38 78.02%
core/userpat/service.go 63 81.97%
pkg/server/connect_interceptors/authorization.go 90 0.0%
core/organization/service.go 169 49.44%
Totals Coverage Status
Change from base Build 23482039206: 0.2%
Covered Lines: 14724
Relevant Lines: 35713

💛 - Coveralls

Copy link
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: 1c9eba0b-c172-4ae4-8f52-3ee982080f31

📥 Commits

Reviewing files that changed from the base of the PR and between fec853b and 1d62277.

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

Copy link
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

🧹 Nitpick comments (1)
internal/store/postgres/org_billing_repository_test.go (1)

110-126: Add a matching notlike regression case.

This PR changes both like and notlike, but this table only adds like coverage. Add a sibling case asserting NOT ILIKE generation to prevent one-sided regressions.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0acc1813-2df9-42bf-9dcb-84163a7884f8

📥 Commits

Reviewing files that changed from the base of the PR and between 1d62277 and aa8160b.

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

@paanSinghCoder paanSinghCoder requested a review from rsbh March 25, 2026 09:46
Copy link
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

♻️ Duplicate comments (1)
internal/store/postgres/org_billing_repository.go (1)

420-423: ⚠️ Potential issue | 🔴 Critical

Line 421 and Line 423: Raw SQL interpolation introduces injection risk.

filter.Value is interpolated directly into SQL via fmt.Sprintf, so crafted input can break out of the predicate. Please switch to parameterized goqu expressions (same fix should be applied to all LIKE/ILIKE branches).

🔧 Proposed fix
-	case OPERATOR_ILIKE:
-		query = query.Where(goqu.L(fmt.Sprintf(`"%s"::TEXT ILIKE '%s'`, filter.Name, filter.Value.(string))))
-	case OPERATOR_NOT_ILIKE:
-		query = query.Where(goqu.L(fmt.Sprintf(`"%s"::TEXT NOT ILIKE '%s'`, filter.Name, filter.Value.(string))))
+	case OPERATOR_ILIKE:
+		query = query.Where(goqu.Cast(goqu.I(filter.Name), "TEXT").ILike(filter.Value.(string)))
+	case OPERATOR_NOT_ILIKE:
+		query = query.Where(goqu.Cast(goqu.I(filter.Name), "TEXT").NotILike(filter.Value.(string)))
#!/bin/bash
set -euo pipefail

echo "=== Interpolated LIKE/ILIKE patterns in org_billing_repository.go ==="
rg -nP 'fmt\.Sprintf\(`"%s"::TEXT (NOT )?I?LIKE '\''%s'\''' internal/store/postgres/org_billing_repository.go || true

echo
echo "=== Parameterized/cast expressions present ==="
rg -nP 'goqu\.Cast\(goqu\.I\(filter\.Name\), "TEXT"\)\.(I|NotI|L|NotL)ike\(' internal/store/postgres/org_billing_repository.go || true

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c9ef6627-0bd0-4bfb-b4fa-290566c6fc63

📥 Commits

Reviewing files that changed from the base of the PR and between dfb0d4d and 5dc687a.

📒 Files selected for processing (4)
  • internal/api/v1beta1connect/organization_billing.go
  • internal/api/v1beta1connect/rql_validation.go
  • internal/store/postgres/org_billing_repository.go
  • web/sdk/admin/utils/transform-query.ts

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.

3 participants