Skip to content

Commit

Permalink
Address "warning: in `column': the last argument was passed as a sing…
Browse files Browse the repository at this point in the history
…le Hash"
  • Loading branch information
kamipo committed Feb 21, 2019
1 parent 6cb176c commit b57ca84
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def primary_key(name, type = :primary_key, **options)

##
# :method: column
# :call-seq: column(name, type, options = {})
# :call-seq: column(name, type, **options)
#
# Appends a column or columns of a specified type.
#
Expand Down Expand Up @@ -364,7 +364,7 @@ def [](name)
# t.references :tagger, polymorphic: true
# t.references :taggable, polymorphic: { default: 'Photo' }, index: false
# end
def column(name, type, options = {})
def column(name, type, **options)
name = name.to_s
type = type.to_sym if type
options = options.dup
Expand Down Expand Up @@ -541,7 +541,7 @@ def initialize(table_name, base)
# t.column(:name, :string)
#
# See TableDefinition#column for details of the options you can use.
def column(column_name, type, options = {})
def column(column_name, type, **options)
index_options = options.delete(:index)
@base.add_column(name, column_name, type, options)
index(column_name, index_options.is_a?(Hash) ? index_options : {}) if index_options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def drop_table(table_name, options = {})
# # Defines a column with a database-specific type.
# add_column(:shapes, :triangle, 'polygon')
# # ALTER TABLE "shapes" ADD "triangle" polygon
def add_column(table_name, column_name, type, options = {})
def add_column(table_name, column_name, type, **options)
at = create_alter_table table_name
at.add_column(column_name, type, options)
execute schema_creation.accept at
Expand Down
15 changes: 8 additions & 7 deletions activerecord/test/schema/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,18 @@
end

create_table :books, id: :integer, force: true do |t|
default_zero = { default: 0 }
t.references :author
t.string :format
t.column :name, :string
t.column :status, :integer, default: 0
t.column :read_status, :integer, default: 0
t.column :status, :integer, **default_zero
t.column :read_status, :integer, **default_zero
t.column :nullable_status, :integer
t.column :language, :integer, default: 0
t.column :author_visibility, :integer, default: 0
t.column :illustrator_visibility, :integer, default: 0
t.column :font_size, :integer, default: 0
t.column :difficulty, :integer, default: 0
t.column :language, :integer, **default_zero
t.column :author_visibility, :integer, **default_zero
t.column :illustrator_visibility, :integer, **default_zero
t.column :font_size, :integer, **default_zero
t.column :difficulty, :integer, **default_zero
t.column :cover, :string, default: "hard"
end

Expand Down

0 comments on commit b57ca84

Please sign in to comment.