bullet
bullet copied to clipboard
Double false positive with includes as String
When doing an include using a String
, ie.
Tag.includes('tag_kind')
You end up with a double false positive. Bullet appears to always expect includes to be Symbol
s.
Started GET "/tags?_include[]=tag_kind.*" for ::1 at 2016-06-14 10:12:21 -0400
Processing by TagsController#index as JSON
Parameters: {"_include"=>["tag_kind.*"]}
Tag Load (0.6ms) SELECT "tags".* FROM "tags"
TagKind Load (0.6ms) SELECT "tag_kinds".* FROM "tag_kinds" WHERE "tag_kinds"."id" IN (1, 5, 3, 4, 2, 7, 8, 10, 6, 9)
Completed 200 OK in 32ms (Views: 9.1ms | ActiveRecord: 14.0ms | Elasticsearch: 0.0ms)
user: mintyfresh
http://localhost:3000/tags?_include[]=tag_kind.*
N+1 Query detected
Tag => [:tag_kind]
Add to your finder: :includes => [:tag_kind]
N+1 Query method call stack
/Users/mintyfresh/test-app/app/models/tag.rb:74:in `serializable_hash'
/Users/mintyfresh/test-app/app/controllers/tags_controller.rb:5:in `index'
/Users/mintyfresh/test-app/app/models/tag.rb:74:in `serializable_hash'
/Users/mintyfresh/test-app/app/controllers/tags_controller.rb:5:in `index'
user: mintyfresh
http://localhost:3000/tags?_include[]=tag_kind.*
Unused Eager Loading detected
Tag => ["tag_kind"]
Remove from your finder: :includes => [:tag_kind]