Skip to content

Commit

Permalink
Validate table name length when renaming (rails-sqlserver#1080)
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanharan authored and Lavika committed Sep 26, 2023
1 parent a05fc54 commit 24e61a0
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ def primary_keys_select(table_name)
sp_executesql(sql, "SCHEMA", binds).map { |r| r["name"] }
end

def rename_table(table_name, new_name)
def rename_table(table_name, new_name, **options)
validate_table_length!(new_name) unless options[:_uses_legacy_table_name]
schema_cache.clear_data_source_cache!(table_name.to_s)
schema_cache.clear_data_source_cache!(new_name.to_s)
do_execute "EXEC sp_rename '#{table_name}', '#{new_name}'"
rename_table_indexes(table_name, new_name)
end
Expand Down

0 comments on commit 24e61a0

Please sign in to comment.