如何在rails scope方法中编写oracle提示

时间:2018-02-07 05:31:55

标签: ruby-on-rails oracle ruby-on-rails-3 oracle-sqldeveloper

在我的rails模型中,我有一个范围方法

class User
  scope :failed,
    :select => %{
      /*+ some hint */ *
    } ,
    :joins => :address,
    :conditions => %{
      addresses.location_id IS NULL
    }

我的问题首先是这是在范围方法中引入提示的正确方法,其次是当我运行User.failed.count时它不考虑提示。请帮忙

这是我致电User.failed

时生成的sql
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

时生成的sql
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)

注意它会跳过提示部分。

0 个答案:

没有答案