Skip to content

Add WithLower, disable exact fallback for WithILikeOps#52

Merged
jakub-id merged 2 commits into
mainfrom
with-lower
Apr 28, 2026
Merged

Add WithLower, disable exact fallback for WithILikeOps#52
jakub-id merged 2 commits into
mainfrom
with-lower

Conversation

@jakub-id

Copy link
Copy Markdown
Contributor

No description provided.

@jakub-id jakub-id merged commit d842f53 into main Apr 28, 2026
1 check passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR extends pgcql string-field query generation to support optional lower(...) wrapping for case-insensitive matching, and changes WithILikeOps() behavior to always use ILIKE (i.e., no exact-match fallback).

Changes:

  • Add WithLower() support to FieldString, applying lower() to both column and parameter for non-ILIKE comparisons (including IN).
  • Add WithoutExact() and update WithILikeOps() to disable exact-match fallback.
  • Expand parsing tests to cover the new behaviors (WithoutExact, WithLower, and WithILikeOps fallback changes).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
pgcql/pg_field_string.go Adds enableLower, WithLower(), WithoutExact(), and adjusts LIKE/ILIKE vs exact fallback logic.
pgcql/pgcql_test.go Adds test coverage for like-only fields, lower-wrapped comparisons, and updated ILIKE behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pgcql/pg_field_string.go
Comment on lines 337 to +360
@@ -324,9 +350,15 @@ func (f *FieldString) Generate(sc cql.SearchClause, queryArgumentIndex int) (str
pgOp = "NOT ILIKE"
}
}
return f.column + " " + pgOp + fmt.Sprintf(" $%d", queryArgumentIndex), []any{pgTerm}, nil
if f.enableILike {
return f.column + " " + pgOp + fmt.Sprintf(" $%d", queryArgumentIndex), []any{pgTerm}, nil
}
return f.getQueryColumn() + " " + pgOp + " " + f.getQueryArg(queryArgumentIndex), []any{pgTerm}, nil
}
}
if !f.enableExact {
return "", nil, &PgError{message: "unsupported relation " + string(sc.Relation)}

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

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

WithILikeOps() now sets enableExact=false, but the LIKE/ILIKE branch only triggers for relations =, <>, and exact (not ==). As a result, queries like authori==Test (or any field configured with WithoutExact()) will now fall through and return unsupported relation ==, which is inconsistent with other field types and with existing support for == as equality. Consider treating == the same as = in the LIKE/ILIKE handling (and/or mapping it before the enableExact check), and add a regression test for == on ILIKE/like-only fields.

Copilot uses AI. Check for mistakes.
Comment thread pgcql/pgcql_test.go
Comment on lines 141 to +148
{"authori = \"test*\"", "Author ILIKE $1", []any{"test%"}},
{"authori <> \"test*\"", "Author NOT ILIKE $1", []any{"test%"}},
{"authori = Test", "Author ILIKE $1", []any{"Test"}},
{"authori <> Test", "Author NOT ILIKE $1", []any{"Test"}},
{"authoriLower = \"test*\"", "Author ILIKE $1", []any{"test%"}},
{"authoriLower <> \"test*\"", "Author NOT ILIKE $1", []any{"test%"}},
{"authoriLower = Test", "Author ILIKE $1", []any{"Test"}},
{"titleLower = AbC", "lower(Title) = lower($1)", []any{"AbC"}},

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

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

The new behaviors around WithILikeOps() (no exact fallback) and WithoutExact() aren’t exercised with the == relation, which is used elsewhere in this test suite (e.g., title==2). Adding a couple of authori==... / authorLikeOnly==... cases here would catch regressions where == is accidentally rejected or handled differently than =.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants