Named query does not accept empty string parameters

I have a named query that has a where clause that looks like below:

title like ‘%{titleContains}%’

and titleContains is a QueryString. This clause looks for title that contains the string titleContains. I am expecting the clause to not filter anything when an empty string is passed in. But named query will give an error if titleContains is an empty string:

Missing value for query parameter titleContains

I think this is a bug that needs to be fixed.

For like clauses I don’t use a query string and would do it like

WHERE title CONCAT('%', :title, '%') where title is a string parameter. If you do it this way does that fix your issue?

thanks for the quick response, it does work for me.
but I do want to see whether admins would consider allowing passing empty QueryString type parameter.

How are you feeding the parameter to the named query? Are you sure its going through as an empty string and not potentially as a None which I think would translate to a NULL?

I am feeding the empty string through two places:

  1. I leave it blank in the testing page for named queries
  2. I leave it blank in the query binding page
    in both cases, I got the same error
1 Like

Ok fair enough. What is the error that you get?

missing value for query parameter {titleContains}

Try feeding a single space in those cases.

I actually tried that, it worked that way

Is there a reason that it needs to be a QueryString and not a parameter?

No, not after seeing the solution provided by @bkarabinchak.psi. Now I am just curious why it wouldn’t allow empty string in a QueryString type parameter.
I initially used QueryString because that gives me similar syntax to a vision query binding. Now I am switching to perspective and I have to use a named query.