diff --git a/CHANGELOG.md b/CHANGELOG.md index 19dd13a70..bacee02ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [#876](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/876) Use native String#end_with - [#873](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/873) Various fixes to get the tests running for Rails 6.1 - [#874](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/874) Deduplicate schema cache structures +- [#875](https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/pull/875) Handle default boolean column values when deduplicating #### Changed diff --git a/lib/active_record/connection_adapters/sqlserver_column.rb b/lib/active_record/connection_adapters/sqlserver_column.rb index b03e8e7e4..acd2c40ef 100644 --- a/lib/active_record/connection_adapters/sqlserver_column.rb +++ b/lib/active_record/connection_adapters/sqlserver_column.rb @@ -27,6 +27,22 @@ def is_utf8? def case_sensitive? collation && collation.match(/_CS/) end + + private + + # Handle when the default value is a boolean. Boolean's do not respond to the method `:-@`. Method now + # checks whether the default value is already frozen and if so it uses that, otherwise it calls `:-@` to + # freeze it. + def deduplicated + @name = -name + @sql_type_metadata = sql_type_metadata.deduplicate if sql_type_metadata + @default = (default.frozen? ? default : -default) if default + @default_function = -default_function if default_function + @collation = -collation if collation + @comment = -comment if comment + + freeze + end end end end