Skip to content

Commit 51cf5a4

Browse files
committed
Only quote table/column names for active record
1 parent 1292131 commit 51cf5a4

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

lib/rails_admin/abstract_model.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,19 @@ def model
6161
end
6262

6363
def quoted_table_name
64-
model.quoted_table_name
64+
if adapter == :active_record
65+
model.quoted_table_name
66+
else
67+
table_name
68+
end
6569
end
6670

6771
def quote_column_name(name)
68-
model.connection.quote_column_name(name)
72+
if adapter == :active_record
73+
model.connection.quote_column_name(name)
74+
else
75+
name
76+
end
6977
end
7078

7179
def to_s

spec/controllers/rails_admin/main_controller_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ def get(action, params)
7373
context 'using mongoid, not supporting joins', mongoid: true do
7474
it 'gives back the remote table with label name' do
7575
controller.params = {sort: 'team', model_name: 'players'}
76-
expect(controller.send(:get_sort_hash, RailsAdmin.config(Player))).to match(sort: /.players.\..team_id./, sort_reverse: true)
76+
expect(controller.send(:get_sort_hash, RailsAdmin.config(Player))).to match(sort: /.?players.?\..?team_id.?/, sort_reverse: true)
7777
end
7878
end
7979

8080
context 'using active_record, supporting joins', active_record: true do
8181
it 'gives back the local column' do
8282
controller.params = {sort: 'team', model_name: 'players'}
83-
expect(controller.send(:get_sort_hash, RailsAdmin.config(Player))).to match(sort: /.teams.\..name./, sort_reverse: true)
83+
expect(controller.send(:get_sort_hash, RailsAdmin.config(Player))).to match(sort: /.?teams.?\..?name.?/, sort_reverse: true)
8484
end
8585
end
8686
end

0 commit comments

Comments
 (0)