Skip to content
Evgeniy Demin edited this page Nov 27, 2022 · 1 revision

The checker finds enums with value types different from the database's field.

The problem only becomes apparent when prepared_statements: option is set to false. This is typical and recommended by Rails when connecting via PgBouncer.

ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR:  operator
   does not exist: text = integer
      LINE 1: SELECT "users".* FROM "users" WHERE "users"."os" = 0
# app/models/user.rb
enum os: [:linux, :windows]
# db/schema.rb
  t.text "os"

The data actually saved in the column is '1', '2' etc.

With prepared_statements: true this error doesn't happen, and it works but it's preferable to keep it consistent to avoid implicit typecasting.

Clone this wiki locally