Skip to content

Commit 1dfb90f

Browse files
author
Aidan Haran
committed
Handle any default column class when deduplicating
1 parent 2fbded9 commit 1dfb90f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/active_record/connection_adapters/sqlserver_column.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ def case_sensitive?
3030

3131
private
3232

33-
# Handle when the default value is a boolean. Boolean's do not respond to the method `:-@`. Method now
34-
# checks whether the default value is already frozen and if so it uses that, otherwise it calls `:-@` to
35-
# freeze it.
33+
# Change to Rails implementation that handles when the `default` object does not respond to the `:-@` method
34+
# call. Examples of classes that do not respond to `:-@` are `TrueClass`, `FalseClass` and `Date`.
35+
#
36+
# The `default` object for other database adapters is always a String. This isn't the case for the SQL Server
37+
# adapter.
3638
def deduplicated
3739
@name = -name
3840
@sql_type_metadata = sql_type_metadata.deduplicate if sql_type_metadata
39-
@default = (default.frozen? ? default : -default) if default
41+
@default = (default.respond_to?(:-@) ? -default : default.dup.freeze) if default
4042
@default_function = -default_function if default_function
4143
@collation = -collation if collation
4244
@comment = -comment if comment

0 commit comments

Comments
 (0)