10

I proposed an edit for this answer on the grounds that the code doesn't run:

How to query the count of child records in soql

Code in original answer:

Select count(Id) totalChilds, Account__c 
     from SVMXC__Site_c WHERE totalchilds > 1 GROUP BY Account__c 

This code doesn't run. Error - WHERE expressions cannot use an aggregate operator, use a HAVING clause instead

My proposed change:

Select count(Id) totalChilds, Account__c 
     from SVMXC__Site_c GROUP BY Account__c HAVING count(Id) > 1

Edit rejected on the grounds that it deviates from the original intent of the post. Pretty sure this is wrong, since it just seems like a typo from the answerer.

Anyway, if I find an upvoted answer with code that doesn't work, should I edit, comment, or post a new answer with working code?

2 Answers 2

12

Your action was, in my opinion, the right way to address such a problem in the answer. I have made your edit directly in the answer under discussion (sorry that you don't receive credit for it in that case). We want answers to be current, complete, and correct, or they don't provide value.

You may also choose to highlight issues with a comment, especially if it's not something that can easily be fixed with an edit to the existing content. Where an answer has a simple mistake in it, correcting with an edit is a desirable service to the community and our collective knowledge base. Where the answer is wholesale wrong, consider posting an answer of your own, and/or advising that the answer is incorrect via comment.

Good opportunity for a reminder to work carefully through the review queues and try to maintain an awareness of context. The edit message for Suggested Edits is not surfaced particularly well to reviewers - please remember to look at it!

9

As one of the reviewers who rejected your edit, let me give some context to the rejection - reviewers don't see comments under answer suggested edits unless they open the answer itself & look. Since I didn't open the answer (usually due to having 2-3 queues open at once) I was missing valuable context - like the implementation of their soql query in the answer was different than the comment suggesting it.

Your edit comment should have stated something like "WHERE cannot be used with Aggregate queries, must use HAVING instead" - instead of "changing soql syntax" - state that the syntax is broken and will not run.

Looking at the answer - leaving a comment under @javanoobs suggestion (which was incorrectly implemented when added to the answer), something like "@RatanPaul you added code incorrectly - should use HAVING instead of WHERE, I've suggested an edit", this comment would notify the answerer - who can approve your edit without going through a queue, as well as add context to reviewers who took the time to check the comments.

As for reviewers, we're not perfect, we do make mistakes - and I'd say this is one. What I saw was a user changing syntax, with low rep and without a good reason - thats going to be a rejection. What I should have seen was a user fixing a problem in another users post, who's been nothing but an asset to this community (top 3% this month is no joke).

Once you get to 2k rep you won't have to worry about review queues. If you have another problem like this before then, come to meta - its pretty quiet here & everyone who posts here is very helpful.

1
  • 2
    You can actually use WHERE in an aggregate query, just not to filter on an aggregated field (like count(Id)).
    – Adrian Larson Mod
    Commented Feb 23, 2020 at 18:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .