Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 16 additions & 0 deletions lib/active_record/connection_adapters/sqlserver_column.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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