Quote table_ and column_name for sorting#3652
Conversation
f5f7d8a to
51cf5a4
Compare
| expect(controller.send(:get_sort_hash, RailsAdmin.config(Player))).to eq(sort: 'players.team_id', sort_reverse: true) | ||
| expect(controller.send(:get_sort_hash, RailsAdmin.config(Player))).to match(sort: /.?players.?\..?team_id.?/, sort_reverse: true) | ||
| end | ||
| end | ||
|
|
||
| context 'using active_record, supporting joins', active_record: true do | ||
| it 'gives back the local column' do | ||
| controller.params = {sort: 'team', model_name: 'players'} | ||
| expect(controller.send(:get_sort_hash, RailsAdmin.config(Player))).to eq(sort: 'teams.name', sort_reverse: true) | ||
| expect(controller.send(:get_sort_hash, RailsAdmin.config(Player))).to match(sort: /.?teams.?\..?name.?/, sort_reverse: true) |
There was a problem hiding this comment.
Maybe I should also add a regression spec with a model with capitalized fields? Where would I put it?
There was a problem hiding this comment.
Somewhere around here will be good, as this fix is about #get_sort_hash.
Also you can create RDBMS-specific test cases like:
rails_admin/spec/rails_admin/support/csv_converter_spec.rb
Lines 69 to 75 in 0e12e5b
|
Any update on this? |
mshibuya
left a comment
There was a problem hiding this comment.
Thanks for the PR! I've made some comments.
| expect(controller.send(:get_sort_hash, RailsAdmin.config(Player))).to eq(sort: 'players.team_id', sort_reverse: true) | ||
| expect(controller.send(:get_sort_hash, RailsAdmin.config(Player))).to match(sort: /.?players.?\..?team_id.?/, sort_reverse: true) | ||
| end | ||
| end | ||
|
|
||
| context 'using active_record, supporting joins', active_record: true do | ||
| it 'gives back the local column' do | ||
| controller.params = {sort: 'team', model_name: 'players'} | ||
| expect(controller.send(:get_sort_hash, RailsAdmin.config(Player))).to eq(sort: 'teams.name', sort_reverse: true) | ||
| expect(controller.send(:get_sort_hash, RailsAdmin.config(Player))).to match(sort: /.?teams.?\..?name.?/, sort_reverse: true) |
There was a problem hiding this comment.
Somewhere around here will be good, as this fix is about #get_sort_hash.
Also you can create RDBMS-specific test cases like:
rails_admin/spec/rails_admin/support/csv_converter_spec.rb
Lines 69 to 75 in 0e12e5b
51cf5a4 to
68299c0
Compare
|
Great job, thank you! |
|
Ah sorry I forgot about that. I think I didn't add the regression test or RDBMS-specific test cases. |
|
I'll handle that when I have time 👍 |
Add a test case to ensure the table and column names are quoted
Fixes #1631.