PG missing params in sub-query

Issue #174 invalid
Valentine Zavadsky
created an issue
? job_references = Job.where(employer_id: employer.id).where(aggregation: employer.aggregation_jobs?).select(:job_reference)
? stats = JobStat.where(job_reference: job_references).count
=> SELECT COUNT(*) FROM "job_stats" WHERE "job_stats"."duplicate" = 'f' AND "job_stats"."job_reference" IN (SELECT "jobs"."job_reference" FROM "jobs" WHERE "j
obs"."employer_id" = 32)
? job_references = employer.jobs.select(:job_reference)
? stats = JobStat.where(job_reference: job_references).count
=> (0.5ms)  SELECT COUNT(*) FROM "job_stats" WHERE "job_stats"."duplicate" = 'f' AND "job_stats"."job_reference" IN (SELECT "jobs"."job_reference" FROM "jobs" WHERE "jobs"."employer_id" = $1 AND "jobs"."aggregation" = 'f')
PG::UndefinedParameter: ERROR:  there is no parameter $1

Im my Employer class i have next code:

class Employer
  has_many :jobs, ->(employer) { where(aggregation: employer.aggregation_jobs?)}, dependent: :destroy
end

Comments (5)

  1. Log in to comment