[#6526] - Bad interpretation of SQL-Query-comments

Category:
Bug report
Priority:
Normal
Status:
Feedback Requested
Project: Severity:
Major
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:
0

If I include a comment (prefixed with -- as line or /* */ for multi-line) in my SQL-Query that includes a parameter, like for example -- $P{REPORT_CONTEXT}, the Jasperstudio SQL Parser seems to interpret this, it gives me the error "Invalid column index" although the query is completely correct. When I remove the comment, everything works fine.
So it seems to interpret the parameter expression within a comment, very confusing!

v6.1.1
sibylle.koetzer's picture
Joined: Dec 2 2015 - 7:46am
Last seen: 5 years 5 months ago

5 Comments:

#1
  • Assigned:nobody» chicuslavic

could you add your query to the description?

#2

Hello chicuslavic,
you can just use an example query (from the Sample DB) followed by a comment like that:

Select * from Address where city = 'Oslo'
-- now follows a comment with any parameter: $P{REPORT_CONTEXT}

Greetings, Sibylle

#3
  • Assigned:chicuslavic» teodord
#4
  • Assigned:nobody»

Can confirm. This is a major problem. Which version will it be resolved in?

#5
  • Status:New» Feedback Requested
  • Assigned:nobody» teodord

Hi,

I think the problem is with SQL comments that contain $P{} and/or $!P{} references.
We do not parse the SQL queries for comments to eliminate such parameter references in comments, so there will be a mismatch when the parameter values are set on the JDBC statement.
Not sure if we want to go that far in parsing SQL queries to eliminate comments.

If this is indeed the situation you encounter, would it be too much to ask you that when you comment out entire sections of the SQL query, you also touch the $P{} and $!P{} references to disable them by adding some character to them so that the parameter parser no longer finds them in comments?
Something like:

$_P{} and $_!P{}

After all, they are comments, so you probably keep them around for later use. When uncommenting, just need to make sure you reactivate the parameter references by removing the disabling character.
Let's just say this would be the Jasper way of commenting out parameter references in queries.

---
Thanks,
Teodor

Feedback