Skip to content

Commit 4f409d9

Browse files
authored
Merge pull request rails#54472 from wata727/pass_kwargs_to_postgresql_table
Pass keyword arguments to PostgreSQL Adapter Table methods
2 parents d35672e + eaab3e0 commit 4f409d9

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -307,35 +307,35 @@ class Table < ActiveRecord::ConnectionAdapters::Table
307307
# t.exclusion_constraint("price WITH =, availability_range WITH &&", using: :gist, name: "price_check")
308308
#
309309
# See {connection.add_exclusion_constraint}[rdoc-ref:SchemaStatements#add_exclusion_constraint]
310-
def exclusion_constraint(*args)
311-
@base.add_exclusion_constraint(name, *args)
310+
def exclusion_constraint(...)
311+
@base.add_exclusion_constraint(name, ...)
312312
end
313313

314314
# Removes the given exclusion constraint from the table.
315315
#
316316
# t.remove_exclusion_constraint(name: "price_check")
317317
#
318318
# See {connection.remove_exclusion_constraint}[rdoc-ref:SchemaStatements#remove_exclusion_constraint]
319-
def remove_exclusion_constraint(*args)
320-
@base.remove_exclusion_constraint(name, *args)
319+
def remove_exclusion_constraint(...)
320+
@base.remove_exclusion_constraint(name, ...)
321321
end
322322

323323
# Adds a unique constraint.
324324
#
325325
# t.unique_constraint(:position, name: 'unique_position', deferrable: :deferred, nulls_not_distinct: true)
326326
#
327327
# See {connection.add_unique_constraint}[rdoc-ref:SchemaStatements#add_unique_constraint]
328-
def unique_constraint(*args)
329-
@base.add_unique_constraint(name, *args)
328+
def unique_constraint(...)
329+
@base.add_unique_constraint(name, ...)
330330
end
331331

332332
# Removes the given unique constraint from the table.
333333
#
334334
# t.remove_unique_constraint(name: "unique_position")
335335
#
336336
# See {connection.remove_unique_constraint}[rdoc-ref:SchemaStatements#remove_unique_constraint]
337-
def remove_unique_constraint(*args)
338-
@base.remove_unique_constraint(name, *args)
337+
def remove_unique_constraint(...)
338+
@base.remove_unique_constraint(name, ...)
339339
end
340340

341341
# Validates the given constraint on the table.
@@ -344,8 +344,8 @@ def remove_unique_constraint(*args)
344344
# t.validate_constraint "price_check"
345345
#
346346
# See {connection.validate_constraint}[rdoc-ref:SchemaStatements#validate_constraint]
347-
def validate_constraint(*args)
348-
@base.validate_constraint(name, *args)
347+
def validate_constraint(...)
348+
@base.validate_constraint(name, ...)
349349
end
350350

351351
# Validates the given check constraint on the table
@@ -354,8 +354,8 @@ def validate_constraint(*args)
354354
# t.validate_check_constraint name: "price_check"
355355
#
356356
# See {connection.validate_check_constraint}[rdoc-ref:SchemaStatements#validate_check_constraint]
357-
def validate_check_constraint(*args)
358-
@base.validate_check_constraint(name, *args)
357+
def validate_check_constraint(...)
358+
@base.validate_check_constraint(name, ...)
359359
end
360360
end
361361

activerecord/test/cases/migration/change_table_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,28 +165,28 @@ def test_xml_creates_xml_column
165165

166166
def test_exclusion_constraint_creates_exclusion_constraint
167167
with_change_table do |t|
168-
expect :add_exclusion_constraint, nil, [:delete_me, "daterange(start_date, end_date) WITH &&", using: :gist, where: "start_date IS NOT NULL AND end_date IS NOT NULL", name: "date_overlap"]
168+
expect :add_exclusion_constraint, nil, [:delete_me, "daterange(start_date, end_date) WITH &&"], using: :gist, where: "start_date IS NOT NULL AND end_date IS NOT NULL", name: "date_overlap"
169169
t.exclusion_constraint "daterange(start_date, end_date) WITH &&", using: :gist, where: "start_date IS NOT NULL AND end_date IS NOT NULL", name: "date_overlap"
170170
end
171171
end
172172

173173
def test_remove_exclusion_constraint_removes_exclusion_constraint
174174
with_change_table do |t|
175-
expect :remove_exclusion_constraint, nil, [:delete_me, name: "date_overlap"]
175+
expect :remove_exclusion_constraint, nil, [:delete_me], name: "date_overlap"
176176
t.remove_exclusion_constraint name: "date_overlap"
177177
end
178178
end
179179

180180
def test_unique_constraint_creates_unique_constraint
181181
with_change_table do |t|
182-
expect :add_unique_constraint, nil, [:delete_me, :foo, deferrable: :deferred, name: "unique_constraint"]
182+
expect :add_unique_constraint, nil, [:delete_me, :foo], deferrable: :deferred, name: "unique_constraint"
183183
t.unique_constraint :foo, deferrable: :deferred, name: "unique_constraint"
184184
end
185185
end
186186

187187
def test_remove_unique_constraint_removes_unique_constraint
188188
with_change_table do |t|
189-
expect :remove_unique_constraint, nil, [:delete_me, name: "unique_constraint"]
189+
expect :remove_unique_constraint, nil, [:delete_me], name: "unique_constraint"
190190
t.remove_unique_constraint name: "unique_constraint"
191191
end
192192
end

0 commit comments

Comments
 (0)