Skip to content

Commit

Permalink
Merge #44 'support_ruby_31'
Browse files Browse the repository at this point in the history
* origin/support_ruby_31:
  modify `remove_foreign_key`
  support Ruby 3.1
  • Loading branch information
maneyko committed Feb 27, 2023
2 parents 4efe846 + 938ef0f commit 8ecb0fd
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def index_name(table_name, options) #:nodoc:
end

# Override super method to provide support for expression column names.
def quoted_columns_for_index(column_names, **options)
def quoted_columns_for_index(column_names, options = {})
return [column_names] if column_names.is_a?(String)

quoted_columns = Hash[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ module PgSaurus::ConnectionAdapters::AbstractAdapter::SchemaMethods
# Provide :schema option to +create_table+ method.
def create_table(table_name, options = {}, &block)
table_name, options = extract_table_options(table_name, options)
super(table_name, options, &block)
super(table_name, **options, &block)
end

# Provide :schema option to +drop_table+ method.
def drop_table(table_name, options = {})
super(*extract_table_options(table_name, options))
table_name, options = extract_table_options(table_name, options)
super(table_name, **options)
end

# Extract the table-specific options for the given table name from the options.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def add_foreign_key(from_table, to_table, options = {})
" Use :exclude_index => true when adding the foreign key."
end

super from_table, to_table, options
super from_table, to_table, **options

unless exclude_index
add_index from_table, column
Expand All @@ -44,14 +44,14 @@ def add_foreign_key(from_table, to_table, options = {})
# See activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
#
# Pass in the option remove_index: true to remove index as well.
def remove_foreign_key(from_table, options_or_to_table = {})
if options_or_to_table.is_a?(Hash) && options_or_to_table[:remove_index]
column = options_or_to_table[:column]
def remove_foreign_key(from_table, to_table = nil, **options)
if options[:remove_index]
column = options[:column]
remove_index from_table, column
options_or_to_table.delete(:remove_index)
options.delete(:remove_index)
end

super(from_table, options_or_to_table)
super(from_table, to_table, **options)
end

# See: activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def drop_table(table_name, options = {})
options = options.dup
schema_name = options.delete(:schema)
table_name = "#{schema_name}.#{table_name}" if schema_name
super(table_name, options)
super(table_name, **options)
end

# Make method +tables+ return tables not only from public schema.
Expand Down
2 changes: 1 addition & 1 deletion lib/pg_saurus/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module PgSaurus
# Version of pg_saurus gem.
VERSION = "5.2.0"
VERSION = "5.3.0"
end
4 changes: 2 additions & 2 deletions pg_saurus.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: pg_saurus 5.2.0 ruby lib
# stub: pg_saurus 5.3.0 ruby lib

Gem::Specification.new do |s|
s.name = "pg_saurus".freeze
s.version = "5.2.0"
s.version = "5.3.0"

s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
Expand Down

0 comments on commit 8ecb0fd

Please sign in to comment.