Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

has_many through uniq generates invalid sql

#261

has_many :uniq_replies, :source => :replies, :through => :topics, :uniq => true

pagination generates invalid sql.

from test/console


>> Project.first.uniq_replies.paginate(:page => 1, :per_page => 1)
  Project Load (0.3ms)   SELECT * FROM "projects" LIMIT 1
  Reply Load (0.8ms)   SELECT DISTINCT "replies".* FROM "replies" INNER JOIN topics ON replies.topic_id = topics.id WHERE (("topics".project_id = 1)) LIMIT 1 OFFSET 0
  SQL (0.0ms)   SQLite3::SQLException: near "*": syntax error: SELECT count(DISTINCT "replies".*) AS count_distinct_replies_all FROM "replies" INNER JOIN topics ON replies.topic_id = topics.id WHERE (("topics".project_id = 1)) 
ActiveRecord::StatementInvalid: SQLite3::SQLException: near "*": syntax error: SELECT count(DISTINCT "replies".*) AS count_distinct_replies_all FROM "replies"  INNER JOIN topics ON replies.topic_id = topics.id    WHERE (("topics".project_id = 1))

I think the SQL should read: @@@ SQL SELECT DISTINCT "replies".id ...


Reported by Chad Jolly · January 16th, 2009 @ 08:51 PM

State: invalid
Milestone: none
Assigned to: Mislav Mislav

Activity

  1. Chad Jolly
  2. Mislav
    Mislav
    • State changed from new to open

    Thanks, I'll look into this

    January 18th, 2009 @ 08:15 PM

  3. Chad Jolly
    Chad Jolly

    Hi Mislav, Just wanted to point out this ticket re: rails 2.3.2

    http://rails.lighthouseapp.com/p...

    Upon upgrading to rails 2.3.2, my has many through uniq relationships do not work at all, failing with the same error as above.

    I wonder if this is an underlying active record issue rather than will_paginate?

    March 24th, 2009 @ 11:18 PM

  4. Mislav
    Mislav
    • State changed from open to invalid

    Yeah. It's an ActiveRecord issue and it's being actively worked on

    March 25th, 2009 @ 12:28 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.