Skip to content

Commit 686a21d

Browse files
author
Aidan Haran
committed
Handle any default column class when deduplicating
1 parent bee6e1d commit 686a21d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- [#874](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/874) Deduplicate schema cache structures
99
- [#875](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/875) Handle default boolean column values when deduplicating
1010
- [#879](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/879) Added visit method for HomogeneousIn
11+
- [#880](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/880) Handle any default column class when deduplicating
1112

1213
#### Changed
1314

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)