FIX: invalid plan generation when % in query on badge definition UI
This commit is contained in:
parent
bb3fb37650
commit
1e4c7dfbe7
|
@ -192,7 +192,8 @@ class BadgeGranter
|
|||
end
|
||||
|
||||
query_plan = nil
|
||||
query_plan = ActiveRecord::Base.exec_sql("EXPLAIN #{sql}", params) if opts[:explain]
|
||||
# HACK: active record is weird, force it to go down the sanitization path that cares not for % stuff
|
||||
query_plan = ActiveRecord::Base.exec_sql("EXPLAIN #{sql} /*:backfill*/", params) if opts[:explain]
|
||||
|
||||
sample = SqlBuilder.map_exec(OpenStruct, grants_sql, params).map(&:to_h)
|
||||
|
||||
|
|
|
@ -38,8 +38,10 @@ describe BadgeGranter do
|
|||
describe 'preview' do
|
||||
it 'can correctly preview' do
|
||||
Fabricate(:user, email: 'sam@gmail.com')
|
||||
result = BadgeGranter.preview('select id user_id, null post_id, created_at granted_at from users where email like \'%gmail.com\'')
|
||||
result = BadgeGranter.preview('select id user_id, null post_id, created_at granted_at from users
|
||||
where email like \'%gmail.com\'', explain: true)
|
||||
expect(result[:grant_count]).to eq(1)
|
||||
expect(result[:query_plan]).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue