binarylogic / searchlogic

Searchlogic provides object based searching, common named scopes, and other useful tools.
http://rdoc.info/projects/binarylogic/searchlogic
MIT License
1.39k stars 133 forks source link

Sorting on a single table Help #13

Closed ghost closed 15 years ago

ghost commented 15 years ago

I tried out using the example code on my controller i.e @search = new_search(params[:search]) and I am able to sort and view pages in 10, 25 etc.. However, when I add conditions the data is displayed correctly but the sorting and page links don’t work. I am trying this on a single table of data. Your comments and advised would be helpful.

original LH ticket

This ticket has 0 attachment(s).

ghost commented 15 years ago

Sorting on a single table Help

I have no idea. Can you please create a failing test, and then I can fix the issue. By test, I mean a test I can run in the searchlogic test suite. I apologize for asking you to do this, but its a new policy I am implementing with my open source projects. I am just very busy and this would help me easily knock out the issue.

by Ben Johnson

ghost commented 15 years ago

Sorting on a single table Help

Wilco, but I need time, since I am a newbie

by ramesh

ghost commented 15 years ago

Sorting on a single table Help

Will this help ?

When I use :- "@search = ArdData.new_search(params[:search]);" in the controller the sql generated on sorting any column is :- "Processing ArdDataController#index (for 127.0.0.1 at 2009-04-01 18:01:17) [GET] Parameters: {"search"=>{"order_as"=>"ASC", "order_by"=>"stock"}} ArdData Columns (2.1ms) SHOW FIELDS FROM ard_datas ArdData Load (0.2ms) SELECT * FROM ard_datas ORDER BY ard_datas.stock ASC LIMIT 25 SQL (0.1ms) SELECT count(ard_datas.part_number) AS count_part_number FROM ard_datas Rendering ard_data/index Completed in 46ms (View: 23, DB: 3) | 200 OK [http://localhost/ard_data?search%5Border_as%5D=ASC&search%5Border_by%5D=stock]"

Here I have tried sorting on the "Stock" column. This works for other columns also.

When I use:-

"@search = ArdData.new_search(:conditions => {:store_type => ’DOR’, :cpq_category => ’P’});" in the controller the sql generated on sorting any column is :-

"Processing ArdDataController#index (for 127.0.0.1 at 2009-04-01 19:24:09) [GET] Parameters: {"search"=>{"order_as"=>"ASC", "order_by"=>"stock"}} ArdData Columns (2.1ms) SHOW FIELDS FROM ard_datas ArdData Load (0.2ms) SELECT * FROM ard_datas WHERE (ard_datas.cpq_category = ’P’ AND ard_datas.store_type = ’DOR’) LIMIT 25 SQL (0.6ms) SELECT count(ard_datas.part_number) AS count_part_number FROM ard_datas WHERE (ard_datas.cpq_category = ’P’ AND ard_datas.store_type = ’DOR’) Rendering ard_data/index Completed in 73ms (View: 28, DB: 3) | 200 OK [http://localhost/ard_data?search%5Border_as%5D=ASC&search%5Border_by%5D=stock]"

The difference I see is in the "ArdData Load". The first query(no conditions) has a "ORDER BY" clause whereas the second(with conditions) doesn’t.

by ramesh

ghost commented 15 years ago

Sorting on a single table Help

Sorry for the lack of activity, is this still an issue. It looks like this bug is for the older version of searchlogic.

by Ben Johnson

ghost commented 15 years ago

Guess not, thanks!