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

Association issue on FROM clause #343

Open
hebergentilin opened this issue Mar 6, 2017 · 0 comments
Open

Association issue on FROM clause #343

hebergentilin opened this issue Mar 6, 2017 · 0 comments

Comments

@hebergentilin
Copy link

hebergentilin commented Mar 6, 2017

Consider the sequence of this columns:

g.column name: '#', attribute: 'id', assoc: [:register] do |invoice|
  invoice.register.id
end

g.column name: 'Student', attribute: 'name', assoc: [:register, :student] do |invoice|
  invoice.register.student.name
end

When searching by student.name, it raises the following error:

PG::UndefinedTable: ERROR: missing input to table "students" at clause FROM

SELECT COUNT(count_column) FROM (SELECT  1 AS count_column FROM "invoices" INNER JOIN "registers" ON "registers"."id" = "invoices"."register_id" AND "registers"."company_id" = $1 WHERE (registers.status = 1 AND invoices.status = 1) AND "invoices"."company_id" = $2 AND (  students.name ILIKE '%d%') LIMIT 20 OFFSET 0) subquery_for_count

But, switching the columns position, the error gone:

g.column name: 'Student', attribute: 'name', assoc: [:register, :student] do |invoice|
  invoice.register.student.name
end

g.column name: '#', attribute: 'id', assoc: [:register] do |invoice|
  invoice.register.id
end
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

1 participant