Skip to content

Commit 1a63942

Browse files
committed
Fix warning about symbol to string conversion being frozen in future
1 parent df2630f commit 1a63942

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

lib/active_record/connection_adapters/sqlserver/schema_statements.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -323,20 +323,22 @@ def check_constraints(table_name)
323323
end
324324

325325
def type_to_sql(type, limit: nil, precision: nil, scale: nil, **)
326-
type_limitable = %w[string integer float char nchar varchar nvarchar binary_basic].include?(type.to_s)
326+
type = type.to_sym
327+
328+
type_limitable = [:string, :integer, :float, :char, :nchar, :varchar, :nvarchar, :binary_basic].include?(type)
327329
limit = nil unless type_limitable
328330

329-
case type.to_s
330-
when "integer"
331+
case type
332+
when :integer
331333
case limit
332334
when 1 then "tinyint"
333335
when 2 then "smallint"
334336
when 3..4, nil then "integer"
335337
when 5..8 then "bigint"
336338
else raise(ActiveRecordError, "No integer type has byte size #{limit}. Use a numeric with precision 0 instead.")
337339
end
338-
when "time" # https://learn.microsoft.com/en-us/sql/t-sql/data-types/time-transact-sql
339-
column_type_sql = type.to_s
340+
when :time # https://learn.microsoft.com/en-us/sql/t-sql/data-types/time-transact-sql
341+
column_type_sql = type.to_s.dup
340342
if precision
341343
if (0..7) === precision
342344
column_type_sql << "(#{precision})"
@@ -345,7 +347,7 @@ def type_to_sql(type, limit: nil, precision: nil, scale: nil, **)
345347
end
346348
end
347349
column_type_sql
348-
when "datetime2"
350+
when :datetime2
349351
column_type_sql = super
350352
if precision
351353
if (0..7) === precision
@@ -355,7 +357,7 @@ def type_to_sql(type, limit: nil, precision: nil, scale: nil, **)
355357
end
356358
end
357359
column_type_sql
358-
when "datetimeoffset"
360+
when :datetimeoffset
359361
column_type_sql = super
360362
if precision
361363
if (0..7) === precision

0 commit comments

Comments
 (0)