Fixed candidate query

Errors in SQL when querying candidate list didn't cause the JSON output
to report an error.
Fixed an error with "partyId" field in candidate SQL query.