diff --git a/pypika/terms.py b/pypika/terms.py index 7d0d0d1..3ef9a4b 100644 --- a/pypika/terms.py +++ b/pypika/terms.py @@ -2,7 +2,7 @@ import json import re import uuid -from datetime import date, time, datetime +from datetime import date, datetime, time from enum import Enum from typing import ( TYPE_CHECKING, @@ -1429,7 +1429,7 @@ def get_sql(self, **kwargs: Any) -> str: # FIXME escape function_sql = self.get_function_sql( - with_namespace=with_namespace, quote_char=quote_char, dialect=dialect + with_namespace=with_namespace, quote_char=quote_char, dialect=dialect, **kwargs ) if self.schema is not None: diff --git a/tests/test_parameter.py b/tests/test_parameter.py index 920803a..1e6d0aa 100644 --- a/tests/test_parameter.py +++ b/tests/test_parameter.py @@ -11,7 +11,8 @@ Query, Tables, ) -from pypika.terms import ListParameter, ParameterValueWrapper +from pypika.functions import Upper +from pypika.terms import ListParameter, ParameterValueWrapper, ValueWrapper class ParametrizedTests(unittest.TestCase): @@ -212,3 +213,15 @@ def test_pyformat_parameter(self): 'INSERT INTO "abc" ("a","b","c") VALUES (%(param1)s,%(param2)s,%(param3)s)', sql ) self.assertEqual({"param1": 1, "param2": 2.2, "param3": "foo"}, parameter.get_parameters()) + + def test_function_parameter(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Upper(ValueWrapper("foobar"))) + ) + p = ListParameter("%s") + sql = q.get_sql(parameter=p) + self.assertEqual('SELECT * FROM "abc" WHERE "category"=UPPER(%s)', sql) + + self.assertEqual(["foobar"], p.get_parameters())