Class: RuboCop::Cop::Migration::Jsonb
- Inherits:
-
Base
- Object
- Base
- RuboCop::Cop::Migration::Jsonb
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/migration/jsonb.rb
Overview
Prefer jsonb to json.
In PostgreSQL, there is no equality operator for the json column type,
which can cause errors for existing SELECT DISTINCT queries in your application.
Constant Summary collapse
- MSG =
'Prefer `jsonb` to `json`.'- RESTRICT_ON_SEND =
%i[ add_column change change_column json ].freeze
Instance Method Summary collapse
- #on_send(node) ⇒ void (also: #on_csend)
Instance Method Details
#on_send(node) ⇒ void Also known as: on_csend
This method returns an undefined value.
34 35 36 37 38 39 40 41 |
# File 'lib/rubocop/cop/migration/jsonb.rb', line 34 def on_send(node) json_range = json_range_from_target_send_node(node) return unless json_range add_offense(json_range) do |corrector| corrector.replace(json_range, 'jsonb') end end |