diff options
Diffstat (limited to 'rubocop/migration_helpers.rb')
-rw-r--r-- | rubocop/migration_helpers.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/rubocop/migration_helpers.rb b/rubocop/migration_helpers.rb index 50d7b198931..d14b1bdd6bb 100644 --- a/rubocop/migration_helpers.rb +++ b/rubocop/migration_helpers.rb @@ -61,11 +61,16 @@ module RuboCop File.basename(node.location.expression.source_buffer.name).split('_').first.to_i end - # Returns true if a column definition is for an array + # Returns true if a column definition is for an array, like { array: true } + # + # @example + # add_column :table, :ids, :integer, array: true, default: [] + # # rubocop:disable Lint/BooleanSymbol def array_column?(node) node.each_descendant(:pair).any? do |pair_node| - pair_node.child_nodes[0].value == :array && # Searching for a (pair (sym :array) (true)) node + pair_node.child_nodes[0].sym_type? && # Searching for a RuboCop::AST::SymbolNode + pair_node.child_nodes[0].value == :array && # Searching for a (pair (sym :array) (true)) node pair_node.child_nodes[1].type == :true # RuboCop::AST::Node uses symbols for types, even when that is a :true end end |