Skip to content

Conversation

@bkoelman
Copy link
Member

@bkoelman bkoelman commented Dec 14, 2025

This PR enables using a (built-in or custom) function as the first parameter of the any/contains/startsWith/endsWith query string functions. For example, the following filters are now allowed (where toUpperCase is a custom function):

?filter=any(toUpperCase(title),'A','B','C')
?filter=any(lessThan(votes,10),'true')
?filter=contains(toUpperCase(title),'EXAMPLE')
?filter=startsWith(toUpperCase(title),'EXAMPLE')
?filter=endsWith(toUpperCase(title),'EXAMPLE')

Additionally, this PR adds an example that defines a custom filter function, backed by a user-defined SQL function.
For example, in a query string such as:

?filter=equals(decrypt(password),'secret')

The decrypt custom filter function is substituted by the decrypt_column_value() user-defined SQL function in the generated WHERE clause.

CREATE OR REPLACE FUNCTION decrypt_column_value(value text)
    RETURNS text
RETURN your_crypto_logic_here;

QUALITY CHECKLIST

@bkoelman bkoelman changed the title Greater flexibility in user-defined filter functions Greater flexibility in custom filter functions Dec 14, 2025
@codecov
Copy link

codecov bot commented Dec 14, 2025

Codecov Report

❌ Patch coverage is 92.30769% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.21%. Comparing base (1e33bd4) to head (22488f8).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...ore/Queries/Expressions/QueryExpressionRewriter.cs 66.66% 0 Missing and 2 partials ⚠️
...ApiDotNetCore/Queries/Expressions/AnyExpression.cs 85.71% 0 Missing and 1 partial ⚠️
...NetCore/Queries/Expressions/MatchTextExpression.cs 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1881   +/-   ##
=======================================
  Coverage   92.21%   92.21%           
=======================================
  Files         437      437           
  Lines       14866    14880   +14     
  Branches     2451     2454    +3     
=======================================
+ Hits        13708    13722   +14     
  Misses        713      713           
  Partials      445      445           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…artsWith/endsWith built-in query string functions; add example to expose function defined in SQL
@bkoelman bkoelman force-pushed the more-custom-query-functions branch from 697028c to 22488f8 Compare December 14, 2025 21:55
@bkoelman bkoelman marked this pull request as ready for review December 14, 2025 22:36
@bkoelman bkoelman merged commit 4b7a47c into master Dec 14, 2025
15 checks passed
@bkoelman bkoelman deleted the more-custom-query-functions branch December 14, 2025 22:40
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.

2 participants