Skip to content

feat(postgrest): apply a raw PostgREST filter - #1010

Merged
Tr00d merged 1 commit into
masterfrom
feat/database.using_filters.raw
Dec 1, 2026
Merged

Tr00d merged 1 commit into
masterfrom
feat/database.using_filters.raw

Conversation

@Tr00d

@Tr00d Tr00d commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Summary

A caller can apply a raw PostgREST filter, with the operator and value written in PostgREST syntax. This is the escape hatch for filters the Operator members do not cover.

Capability: database.using_filters.raw (Filter Raw).

Public API

A new Filter overload that takes the operator as a string, on tables and on function calls:

IPostgrestTable<TModel> Filter(string columnName, string op, string criterion);          // IPostgrestTable<TModel>, Table<TModel>
IPostgrestFunctionCall<TModel> Filter(string columnName, string op, string criterion);   // IPostgrestFunctionCall<TModel>
var users = await client.Table<User>()
    .Filter("username", "in", "(\"kiwicopple\",\"dragarcia\")")
    .Get();

No new types. An existing call with an Operator value still resolves to the generic overload.

Behavior

  • Sends <column>=<op>.<criterion>, with the operator and criterion exactly as given: no quoting, escaping or % to * translation beyond URL encoding. op may carry a not. prefix.
  • Several raw filters on the same column are all sent. Raw filters go out next to the typed ones, and Clear() drops them.
  • The SDK makes no checks before the request. PostgREST rejects a filter it cannot parse with 400 PGRST100, and the SDK throws PostgrestException through the existing error path.
  • The raw filter is held in the pending query as a key/value pair. No new filter type is involved, and a raw filter cannot be nested inside Not, Or or And.

Deviations from supabase-js

  • The criterion is a string, where supabase-js takes unknown and calls toString(). The caller controls formatting and culture.
  • Like supabase-js filter(), a raw filter is not nested in or. The raw-string or(filters) of supabase-js is a separate capability.

Tests

Tier Class Pins
E2E RawFilterTests in and not.in against a live PostgREST, an unknown operator throws, narrowing a function call
Contract RawFilterRequestTests query parameter on the wire for a table and a function call
Unit RawFilterUrlTests verbatim operator and value, not. prefix, two filters on one column, mixed with typed filters, Clear()

Diff coverage: 100% (9 lines). Mutation: 5/5 killed on the changed lines, 0 survivors.

@Tr00d
Tr00d marked this pull request as ready for review December 1, 2026 12:11
@Tr00d
Tr00d merged commit b7b41c6 into master Dec 1, 2026
11 checks passed
@Tr00d
Tr00d deleted the feat/database.using_filters.raw branch December 1, 2026 12:16
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