Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: syntax error at or near ")" #52

Open
lpirola opened this issue Sep 29, 2016 · 0 comments
Assignees

Comments

@lpirola
Copy link
Contributor

lpirola commented Sep 29, 2016

https://sentry.io/nossas-cidades/me-representa/issues/164534777/

PG::SyntaxError: ERROR:  syntax error at or near ")"
LINE 9:                 ()
                         ^

  app/models/user.rb:67:in `matches'
    select { |dt| dt.score_direitos_humanos.to_i > 0 }
  app/controllers/users_controller.rb:40:in `matchup'
    @matdata = @user.matches
...
(96 additional frame(s) were not displayed)

ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  syntax error at or near ")"
LINE 9:                 ()
                         ^
: SELECT 
          (
            select
                count(*)
              from 
                answers ca 
              where 
                ca.responder_id = candidates.id and ca.responder_type='Candidate' and ca.short_answer = 'Sim' and 
                ()
          ) as score_eleitor
          ,(
            select
                count(*)
              from 
                answers ca 
              where 
                ca.responder_id = candidates.id and ca.responder_type='Candidate' and ca.short_answer = 'Sim'
          ) as score_direitos_humanos
          , candidates.nickname
          , candidates.id as id
          , (select u.score from parties_unions pu inner join unions u on pu.union_id = u.id where pu.party_id = candidates.party_id and u.city_id = candidates.city_id limit 1) as union_score
          , parties.score as party_score
          , (select count(*) from users us where us.candidate_id = candidates.id) as votos 
         FROM "candidates" INNER JOIN "parties" ON "parties"."id" = "candidates"."party_id" WHERE (candidates.finished_at is not null and candidates.city_id = 4205407)

ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR:  syntax error at or near ")"
LINE 9:                 ()
                         ^
: SELECT 
          (
            select
                count(*)
              from 
                answers ca 
              where 
                ca.responder_id = candidates.id and ca.responder_type='Candidate' and ca.short_answer = 'Sim' and 
                ()
          ) as score_eleitor
          ,(
            select
                count(*)
              from 
                answers ca 
              where 
                ca.responder_id = candidates.id and ca.responder_type='Candidate' and ca.short_answer = 'Sim'
          ) as score_direitos_humanos
          , candidates.nickname
          , candidates.id as id
          , (select u.score from parties_unions pu inner join unions u on pu.union_id = u.id where pu.party_id = candidates.party_id and u.city_id = candidates.city_id limit 1) as union_score
          , parties.score as party_score
          , (select count(*) from users us where us.candidate_id = candidates.id) as votos 
         FROM "candidates" INNER JOIN "parties" ON "parties"."id" = "candidates"."party_id" WHERE (candidates.finished_at is not null and candidates.city_id = 4205407)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants