我獲得PG :: UndefinedFunction:ERROR生產
class Customer < ActiveRecord::Base
enum status: [:unconfirmed]
default_scope { order updated_at: :desc }
scope :unconfirmed, -> { where(status: 0) }
end
在架構狀態字段定義爲整數,默認爲0
在發展中,SQLite的一類客戶,一切工作正常但在生產,PostgreSQL的,當我嘗試運行Customer.unconfirmed我得到一個錯誤:
PG::UndefinedFunction: ERROR: operator does not exist: boolean = integer
LINE 1: ...s".* FROM "customers" WHERE "customers"."status" = 0 ORDER...
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT "customers".* FROM "customers" WHERE "customers"."status" = 0 ORDER BY "customers"."updated_at" DESC
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR: operator does not exist: boolean = integer
LINE 1: ...s".* FROM "customers" WHERE "customers"."status" = 0 ORDER...
誰能幫我找出這裏發生了什麼?
只是'狀態:0 :: Boolean'取代'狀態:0' –