File tree 2 files changed +23
-0
lines changed
lib/active_record/connection_adapters/sqlserver/type
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,16 @@ def eql?(other)
36
36
self . class == other . class && value == other . value
37
37
end
38
38
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
39
49
end
40
50
end
41
51
end
Original file line number Diff line number Diff line change @@ -2586,6 +2586,19 @@ def thread_encrypting_and_decrypting(thread_label)
2586
2586
end
2587
2587
end
2588
2588
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
+
2589
2602
# TODO: Need to uncoerce the 'SerializedAttributeTest' tests before releasing adapter for Rails 7.1
2590
2603
class SerializedAttributeTest < ActiveRecord ::TestCase
2591
2604
coerce_all_tests!
You can’t perform that action at this time.
0 commit comments