-
-
Notifications
You must be signed in to change notification settings - Fork 47
EnumTypeChecker
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.
If the project helps you or your organization, I would be very grateful if you contribute or donate. Your support is an incredible motivation and the biggest reward for my hard work.
- Home
- Installation
- How to run?
- Configuration
- Auto correction
- Integrations
- Checkers
- ColumnPresenceChecker
- LengthConstraintChecker
- NullConstraintChecker
- UniqueIndexChecker
- ForeignKeyChecker
- MissingUniqueIndexChecker
- MissingIndexChecker
- PrimaryKeyTypeChecker
- ForeignKeyTypeChecker
- RedundantIndexChecker
- RedundantUniqueIndexChecker
- EnumTypeChecker
- ForeignKeyCascadeChecker
- EnumValueChecker
- CaseSensitiveUniqueValidationChecker
- ThreeStateBooleanChecker
- MissingAssociationClassChecker
- MissingTableChecker
- ImplicitOrderingChecker
- FAQ
- Development