在我的rails模型中,我有一个范围方法
class User
scope :failed,
:select => %{
/*+ some hint */ *
} ,
:joins => :address,
:conditions => %{
addresses.location_id IS NULL
}
我的问题首先是这是在范围方法中引入提示的正确方法,其次是当我运行User.failed.count
时它不考虑提示。请帮忙
这是我致电User.failed
SELECT /*+ some hint */ * FROM "SOME_SCHEMA"."USERS" INNER JOIN "SOME_SCHEMA"."ADDRESSES" ON "SOME_SCHEMA"."ADDRESSES"."ID" = "SOME_SCHEMA"."USERS"."ADDRESS_ID" WHERE (addresses.location_id IS NULL)
这是我调用User.failed.count
SELECT COUNT(*) FROM "SOME_SCHEMA"."USERS" INNER JOIN "SOME_SCHEMA"."ADDRESSES" ON "SOME_SCHEMA"."ADDRESSES"."ID" = "SOME_SCHEMA"."USERS"."ADDRESS_ID" WHERE (addresses.location_id IS NULL)
注意它会跳过提示部分。