Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #1405 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

[PATCH] Fix for different handling of 'join' by count and find

Reported by: pritchie@gmail.com Assigned to: sam@conio.net
Priority: normal Milestone:
Component: ActiveRecord Version: 0.12.1
Severity: major Keywords:
Cc:

Description

In the current trunk the syntax for 'join' is interpreted differently for count than it is for find. This breaks pagination that use :join, as depending on your syntax either the count sql or the find sql will fail.

Currently the count syntax expects the join type, this is in line with the documentation. find on the other hand inserts a ', ' in front of the joins wich makes :joins => 'INNER JOIN...' illegal.

valid count join:

count('INNER JOIN developers_projects ON id=developer_id', 'project_id=1')

valid find join:

find :joins => 'developers_projects', :conditions => 'id=developer_id AND project_id=1'

Based on the documentation the behavior of 'count' is correct.

Attachments

join_for_count_and_find_fix.diff (2.2 kB) - added by pritchie@gmail.com on 06/06/05 18:30:33.
Patch for contruct_sql to remove ', ' when using joins w/ accompanying tests.

Change History

06/06/05 18:30:33 changed by pritchie@gmail.com

  • attachment join_for_count_and_find_fix.diff added.

Patch for contruct_sql to remove ', ' when using joins w/ accompanying tests.

06/06/05 21:53:30 changed by pritchie@gmail.com

06/16/05 05:53:09 changed by david

  • owner changed from David to sam@conio.net.

06/16/05 09:27:57 changed by pritchie@gmail.com

Just saw the owner change on this. Any questions/comments?

06/25/05 11:47:25 changed by david

  • status changed from new to closed.
  • resolution set to fixed.