mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Avoid to allow unused splat args for t.timestamps
in create_table
Unfortunately `t.timestamps` in `create_table` allows unused splat args. But the same one in `change_table` does not allow them. This commit fixes the inconsistent behavior.
This commit is contained in:
parent
6107a40c0e
commit
e7023cb8f1
3 changed files with 4 additions and 6 deletions
|
@ -341,9 +341,7 @@ module ActiveRecord
|
|||
# <tt>:updated_at</tt> to the table. See {connection.add_timestamps}[rdoc-ref:SchemaStatements#add_timestamps]
|
||||
#
|
||||
# t.timestamps null: false
|
||||
def timestamps(*args)
|
||||
options = args.extract_options!
|
||||
|
||||
def timestamps(**options)
|
||||
options[:null] = false if options[:null].nil?
|
||||
|
||||
column(:created_at, :datetime, options)
|
||||
|
|
|
@ -21,7 +21,7 @@ module ActiveRecord
|
|||
end
|
||||
alias :belongs_to :references
|
||||
|
||||
def timestamps(*, **options)
|
||||
def timestamps(**options)
|
||||
options[:null] = true if options[:null].nil?
|
||||
super
|
||||
end
|
||||
|
@ -59,7 +59,7 @@ module ActiveRecord
|
|||
end
|
||||
alias :add_belongs_to :add_reference
|
||||
|
||||
def add_timestamps(*, **options)
|
||||
def add_timestamps(_, **options)
|
||||
options[:null] = true if options[:null].nil?
|
||||
super
|
||||
end
|
||||
|
|
|
@ -462,7 +462,7 @@ class TimestampTest < ActiveRecord::TestCase
|
|||
|
||||
def test_index_is_created_for_both_timestamps
|
||||
ActiveRecord::Base.connection.create_table(:foos, force: true) do |t|
|
||||
t.timestamps(:foos, null: true, index: true)
|
||||
t.timestamps null: true, index: true
|
||||
end
|
||||
|
||||
indexes = ActiveRecord::Base.connection.indexes("foos")
|
||||
|
|
Loading…
Reference in a new issue