Parameters to text string+


I have this Java code:

		String q = "SELECT COUNT(*) AS size FROM data WHERE Type='$1'";
		N1qlQueryResult result = getDb().query(N1qlQuery.parameterized(q, JsonArray.from("Feedback")));
		Util.trace(N1qlQuery.parameterized(q, JsonArray.from(formName)).toString());
		return result.allRows().get(0).value().getInt("size");

It returns nothing. But if I change it and put “Feedback” in the place where I have “$1” then it works. So I guess the problem is replacing parameters if the placeholders are inside a text constant.

What is the best way to solve this?

I also tried to log the “real” statement - but without success. How can I get it (after the parameters have been inserted)?


You don’t need the single quotes around $1 - N1QL will know that you are looking for a string just because the parameter value is a string.
With the single quotes, you are literally searching for “$1”.