fundacionjala / enforce-sonarqube-plugin

Apex static code analyzer.
MIT License
37 stars 38 forks source link

Urgent - SOQL Subquery Limit Issue #122

Open iamankush opened 7 years ago

iamankush commented 7 years ago

Hi Enforce Team,

Thank you for the amazing product. I need your help with a very specific scenario while parsing the LIMIT in SOQL with subquery when using WHERE clause. e.g. SELECT Id, Member_ID_HFc, Name , (SELECT ID FROM Assets WHERE Company_Number_HFc!=null LIMIT 1) FROM Account WHERE Id = :objParentRecord.objId

It works fine if I add limit 1 but if I remove the limit 1, it breaks the unit test. When I am trying to debug SOQL with SOQL expressions class, i am not able to figure out what is the issue.

Edit1 : the error is showing EOF at the end of parsed query in junit. Not sure why but still analyzing.

Please help with this issue as this one is really urgent for me to fix for a project deliverable. Your help is appreciated. Please let me know in case you need more details.

Regards, Ankush

iamankush commented 7 years ago

@goldmane Could you please help ?

goldmane commented 7 years ago

@iamankush - I was able to reproduce the error and noticed that it was incorrectly parsing the where clause, specifically not allowing the null keyword to be used as an operand. Check PR #123 to see if this resolves your issue

iamankush commented 7 years ago

Thanks a lot Awesome Eric ! Your help is really appreciated! we have 3 more issues which we are facing. I will raise the issues and will keep you posted!

@goldmane

iamankush commented 7 years ago

Hi @goldmane Eric,

Could you please try the same query in your test class? This fix does not solve my issue.

Exact query which do not parse - SELECT Id, Member_ID_HFc, Name , (SELECT ID FROM Assets WHERE Company_Number_HFc!=null) FROM Account WHERE Id = :objParentRecord.objId

It doesnt seems to be a problem with null , see below query: assertThat(parser).matches("SELECT Id, Member_ID_HF__c, Name , (SELECT ID FROM Assets WHERE Company_Number_HF_c!='0'),Name FROM Account WHERE Id = :objParentRecord.objId");

Could you please help me with this issue?

iamankush commented 7 years ago

@kevinTveizaga @dan-canqui @goldmane @paolo @ziur @rodrigouz @alexrv11 @adriangrajeda

abd3 commented 6 years ago

@rahulAppirio can you check whether #129 fixes this, or if we can add the code snippet above to a unit test and resolve this? @iamankush you can build the updated version of this plugin which may resolve your issue.