File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
lib/active_record/connection_adapters/sqlserver/type Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,16 @@ def eql?(other)
3636 self . class == other . class && value == other . value
3737 end
3838 alias :== :eql?
39+
40+ def self . from_msgpack_ext ( string )
41+ type , value = string . chomp! ( "msgpack_ext" ) . split ( ',' )
42+
43+ Data . new ( value , type . constantize )
44+ end
45+
46+ def to_msgpack_ext
47+ [ type . class . to_s , value ] . join ( ',' ) + "msgpack_ext"
48+ end
3949 end
4050 end
4151 end
Original file line number Diff line number Diff line change @@ -2586,6 +2586,19 @@ def thread_encrypting_and_decrypting(thread_label)
25862586 end
25872587end
25882588
2589+ # Need to use `install_unregistered_type_fallback` instead of `install_unregistered_type_error` so that message-pack
2590+ # can read and write `ActiveRecord::ConnectionAdapters::SQLServer::Type::Data` objects.
2591+ class ActiveRecordMessagePackTest < ActiveRecord ::TestCase
2592+ private
2593+ def serializer
2594+ @serializer ||= ::MessagePack ::Factory . new . tap do |factory |
2595+ ActiveRecord ::MessagePack ::Extensions . install ( factory )
2596+ ActiveSupport ::MessagePack ::Extensions . install ( factory )
2597+ ActiveSupport ::MessagePack ::Extensions . install_unregistered_type_fallback ( factory )
2598+ end
2599+ end
2600+ end
2601+
25892602# TODO: Need to uncoerce the 'SerializedAttributeTest' tests before releasing adapter for Rails 7.1
25902603class SerializedAttributeTest < ActiveRecord ::TestCase
25912604 coerce_all_tests!
You can’t perform that action at this time.
0 commit comments