Pocket Query: How to get around an error because of a space character in a query parameter value

Marketa Dvorackova December 9, 2015

Hello,

I would like to ask your help when it comes to parameters in a query. The query works ok, if the input parameter value does not contain spaces. Once it does, it gives an error. Is there a way around this please?
The example query is simple: SELECT id FROM cwd_group WHERE group_name=:GroupName
GroupName = "confluence-administrators" - no problem
GroupName = "GA Team" - gives a syntax error

org.springframework.jdbc.BadSqlGrammarException: select id from cwd_group where group_name=?

Thank you very much for your help.

1 answer

1 accepted

0 votes
Answer accepted
Felix Grund (Scandio)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 9, 2015

Hi Marketa,

Thanks for raising this question! It's actually very strange -- your query works totally fine for me. I created a group with name "group with spaces". I used your statement and I simply enter the group name in the macro browser:

image2015-12-10 8:23:58.png

image2015-12-10 8:24:30.png

Did you do it the exact same way? What database are you using? Can you post your full stack trace that appears when you check the "debug" flag in the macro browser?

Regards, Felix (Scandio)

Marketa Dvorackova December 9, 2015

Hi Felix, more or less yes, the group query is nested in another query. {code}select user_name from cwd_user left join cwd_membership on cwd_user.id=cwd_membership.child_user_id where cwd_membership.parent_id = (select id from cwd_group where group_name=:GroupName) order by user_name asc;{code} as I actually need to get to the users of a given group. But should be the same, the result is still one row - one id that is being used further. But there is a specific thing that I didn't discover before.. it seems that it only doesn't work for one group. I have tested again a couple with spaces and worked ok, as you say. One doesn't though. After further investigation directly in DB I've found out that a couple of groups (regardles spaces in title) are stored twice!!! Same name, different IDs. What a mess:( Sorry to have bothered you, absolutely not an issue of pocket query but crowd.

Felix Grund (Scandio)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 9, 2015

Ok, glad to hear it's nothing to do with PocketQuery. Less glad that it's a mess of course ;). If you like PocketQuery after all, would you consider leaving a review at the Atlassian Marketplace? :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events