Commits

Anonymous committed 6ba6bb1

set bucket_mod to 'undefined' to switch a jiak bucket back into dynamic-schema mode

Comments (0)

Files changed (1)

 jiak_module_for_bucket(BucketName) when is_binary(BucketName) ->
     BucketProps = riak_bucket:get_bucket(BucketName),
     case proplists:lookup(bucket_mod, BucketProps) of
-        {bucket_mod, Module} ->
+        {bucket_mod, Module} when Module /= undefined ->
             Module;
-        none ->
+        _ ->
             case bucket_props_defined(BucketProps) of
                 true ->
                     jiak_default:new(BucketProps);
     riak_ring_manager:stop(),
     riak_eventer:stop().
 
+%% just like dynamic_bucket_test, but ensuring that
+%% {bucket_mod, undefined} gets treated as if bucket_mod
+%% were not set.
+dynamic_bucket_undefined_test() ->
+    riak_ring_manager:start_link(test),
+    riak_eventer:start_link(test),    
+    BucketProps = [{bucket_mod, undefined},
+                   {allowed_fields, [<<"test">>]},
+                   {required_fields, []},
+                   {read_mask, [<<"test">>]},
+                   {write_mask, [<<"test">>]}],
+    riak_bucket:set_bucket(<<"dynamic_bucket_test">>, BucketProps),
+    Mod = jiak_module_for_bucket(<<"dynamic_bucket_test">>),
+    ?assertEqual([<<"test">>], Mod:allowed_fields()),
+    ?assertEqual([], Mod:required_fields()),
+    ?assertEqual([<<"test">>], Mod:read_mask()),
+    ?assertEqual([<<"test">>], Mod:write_mask()),
+    riak_ring_manager:stop(),
+    riak_eventer:stop().
+
 module_bucket_test() ->
     riak_ring_manager:start_link(test),
     riak_eventer:start_link(test),