Skip to content

Add scalar function call methods to SQLExpressions#1656

Open
zio0911 wants to merge 5 commits intoOpenFeign:masterfrom
zio0911:feature/scalar-function-call
Open

Add scalar function call methods to SQLExpressions#1656
zio0911 wants to merge 5 commits intoOpenFeign:masterfrom
zio0911:feature/scalar-function-call

Conversation

@zio0911
Copy link

@zio0911 zio0911 commented Mar 25, 2026

Closes #1657

Summary

Add convenience methods to SQLExpressions for creating scalar function call expressions that support fully qualified (multi-part) function names.

Problem

  • RelationalFunctionCall only supports table-valued functions in FROM/JOIN clauses
  • Calling scalar functions with schema-qualified names (e.g., other_db.dbo.my_function(arg)) requires manually constructing template strings with {0}, {1} placeholders
  • No dedicated API in SQLExpressions for scalar function calls

Solution

Added three new factory methods to SQLExpressions:

  • function(Class<T>, String, Object...) - generic scalar function call
  • stringFunction(String, Object...) - String-returning function call
  • numberFunction(Class<T>, String, Object...) - Number-returning function call
// Before (manual template with placeholders)
Expressions.stringTemplate("other_db.dbo.my_function({0}, {1})", arg1, arg2);

// After (just pass function name and arguments)
SQLExpressions.stringFunction("other_db.dbo.my_function", arg1, arg2);

Supports any naming convention:

  • my_function(...) - simple
  • schema.my_function(...) - 2-part
  • database.schema.my_function(...) - 3-part (cross-database)
  • server.database.schema.my_function(...) - 4-part (linked server)

Changes

  • SQLExpressions.java - Added function(), stringFunction(), numberFunction() methods and private createFunctionCallTemplate() helper
  • SQLExpressionsFunctionTest.java - New test class with 9 test cases covering naming patterns, return types, and SQL contexts (SELECT, WHERE, INSERT VALUES)
  • SerializationTest.java - Added 2 scalar function serialization tests with SQLServerTemplates

이승영 added 5 commits March 25, 2026 12:34
Add convenience methods for creating scalar function call expressions
that support fully qualified (multi-part) function names such as
schema.function, database.schema.function, or
linked_server.database.schema.function.

New methods:
- function(Class, String, Object...) - generic scalar function call
- stringFunction(String, Object...) - String-returning function call
- numberFunction(Class, String, Object...) - Number-returning function call

These complement the existing relationalFunctionCall() which is designed
for table-valued functions in FROM/JOIN clauses.
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.

Add scalar function call methods to SQLExpressions for schema-qualified function names

1 participant