Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pypika/terms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,12 @@ def get_function_sql(self, **kwargs: Any) -> str:

return "{name}({args}{special})".format(
name=self.name,
args=",".join(self.get_arg_sql(arg, **kwargs) for arg in self.args),
args=",".join(
p.get_sql(with_alias=False, subquery=True, **kwargs)
if hasattr(p, "get_sql")
else self.get_arg_sql(p, **kwargs)
for p in self.args
),
special=(" " + special_params_sql) if special_params_sql else "",
)

Expand Down
5 changes: 5 additions & 0 deletions pypika/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,11 @@ def test__approx_percentile(self):
str(q),
)

def test__subquery_in_params_functions(self):
subquery = Query.from_('table').select('id')
func = fn.Function('func', 'id', subquery)
self.assertEqual("func('id',(SELECT id FROM table))", func.get_sql())


class ConditionTests(unittest.TestCase):
def test__case__raw(self):
Expand Down