@@ -106,7 +106,7 @@ wait_for_web_machine(Secs, Cfg) ->
106106table_def_bob () ->
107107 " create table bob ("
108108 " a varchar not null,"
109- " b varchar not null,"
109+ " b blob not null,"
110110 " c timestamp not null,"
111111 " d sint64,"
112112 " primary key ((a, b, quantum(c, 1, m)), a, b, c))" .
@@ -172,13 +172,13 @@ bad_describe_query_test(Cfg) ->
172172
173173% %% put
174174post_single_row_test (Cfg ) ->
175- RowStr = row (" q1" , " w1" , 11 , 110 ),
175+ RowStr = row (" q1" , base64 : encode_to_string ( " w1" ) , 11 , 110 ),
176176 {ok , " 200" , Headers , RespBody } = post_data (" bob" , RowStr , Cfg ),
177177 " application/json" = content_type (Headers ),
178178 RespBody = success_body ().
179179
180180post_single_row_with_null_test (Cfg ) ->
181- RowStr = row (" qN" , " wN" , 11 , null ),
181+ RowStr = row (" qN" , base64 : encode_to_string ( " wN" ) , 11 , null ),
182182 {ok , " 200" , Headers , RespBody } = post_data (" bob" , RowStr , Cfg ),
183183 " application/json" = content_type (Headers ),
184184 RespBody = success_body ().
@@ -191,22 +191,23 @@ post_single_row_missing_field_test(Cfg) ->
191191 " Missing field \" b\" for key in table \" bob\" " = Body .
192192
193193post_single_row_wrong_field_test (Cfg ) ->
194- RowStr = wrong_field_type_row (" q1" , " w1" , 12 , " raining" ),
194+ RowStr = wrong_field_type_row (" q1" , base64 : encode_to_string ( " w1" ) , 12 , " raining" ),
195195 {ok ," 400" , Headers , Body } = post_data (" bob" , RowStr , Cfg ),
196196 " text/plain" = content_type (Headers ),
197197 " Bad value for field \" d\" of type sint64 in table \" bob\" " = Body .
198198
199199
200200post_several_rows_test (Cfg ) ->
201- RowStrs = string :join ([row (" q1" , " w2" , 20 , 150 ), row (" q1" , " w1" , 20 , 119 )],
201+ RowStrs = string :join ([row (" q1" , base64 :encode_to_string (" w2" ), 20 , 150 ),
202+ row (" q1" , base64 :encode_to_string (" w1" ), 20 , 119 )],
202203 " , " ),
203204 Body = io_lib :format (" [~s ]" , [RowStrs ]),
204205 {ok , " 200" , Headers , RespBody } = post_data (" bob" , Body , Cfg ),
205206 " application/json" = content_type (Headers ),
206207 RespBody = success_body ().
207208
208209post_row_to_nonexisting_table_test (Cfg ) ->
209- RowStr = row (" q1" , " w1" , 30 , 142 ),
210+ RowStr = row (" q1" , base64 : encode_to_string ( " w1" ) , 30 , 142 ),
210211 {ok ," 404" , Headers , Body } = post_data (" bill" , RowStr , Cfg ),
211212 " text/plain" = content_type (Headers ),
212213 " Table \" bill\" does not exist" = Body .
@@ -232,26 +233,30 @@ list_keys_nonexisting_table_test(Cfg) ->
232233
233234% %% select
234235select_test (Cfg ) ->
235- Select = " select * from bob where a='q1' and b='w1' and c>1 and c<99" ,
236+ Select = " select * from bob where a='q1' and b=" ++
237+ hexlify (" w1" ) ++ " and c>1 and c<99" ,
236238 {ok ," 200" , Headers , Body } = execute_query (Select , Cfg ),
237239 " application/json" = content_type (Headers ),
238- " {\" columns\" :[\" a\" ,\" b\" ,\" c\" ,\" d\" ],"
239- " \" rows\" :[[\" q1\" ,\" w1\" ,11,110],"
240- " [\" q1\" ,\" w1\" ,20,119]]}" = Body .
240+ ? assertEqual (
241+ " {\" columns\" :[\" a\" ,\" b\" ,\" c\" ,\" d\" ]," ++
242+ " \" rows\" :[[\" q1\" ,\" " ++ base64 :encode_to_string (" w1" ) ++ " \" ,11,110]," ++
243+ " [\" q1\" ,\" " ++ base64 :encode_to_string (" w1" ) ++ " \" ,20,119]]}" , Body ).
241244
242245select_with_null_test (Cfg ) ->
243- Select = " select * from bob where a='qN' and b='wN' and c>1 and c<99 and d is null" ,
246+ Select = " select * from bob where a='qN' and b=" ++ hexlify ( " wN " ) ++ " and c>1 and c<99 and d is null" ,
244247 {ok ," 200" , Headers , Body } = execute_query (Select , Cfg ),
245248 " application/json" = content_type (Headers ),
246- " {\" columns\" :[\" a\" ,\" b\" ,\" c\" ,\" d\" ],"
247- " \" rows\" :[[\" qN\" ,\" wN\" ,11,[]]]}" = Body .
249+ ? assertEqual (
250+ " {\" columns\" :[\" a\" ,\" b\" ,\" c\" ,\" d\" ],"
251+ " \" rows\" :[[\" qN\" ,\" " ++ base64 :encode_to_string (" wN" ) ++ " \" ,11,[]]]}" , Body ).
248252
249253select_subset_test (Cfg ) ->
250- Select = " select * from bob where a='q1' and b='w1' and c>1 and c<15" ,
254+ Select = " select * from bob where a='q1' and b=" ++ hexlify ( " w1 " ) ++ " and c>1 and c<15" ,
251255 {ok , " 200" , Headers , Body } = execute_query (Select , Cfg ),
252256 " application/json" = content_type (Headers ),
253- " {\" columns\" :[\" a\" ,\" b\" ,\" c\" ,\" d\" ],"
254- " \" rows\" :[[\" q1\" ,\" w1\" ,11,110]]}" = Body .
257+ ? assertEqual (
258+ " {\" columns\" :[\" a\" ,\" b\" ,\" c\" ,\" d\" ]," ++
259+ " \" rows\" :[[\" q1\" ,\" " ++ base64 :encode_to_string (" w1" ) ++ " \" ,11,110]]}" , Body ).
255260
256261invalid_select_test (Cfg ) ->
257262 Select = " select * from bob where a='q1' and c>1 and c<15" ,
@@ -270,28 +275,30 @@ invalid_query_test(Cfg) ->
270275
271276% %% delete
272277delete_data_existing_row_test (Cfg ) ->
273- {ok , " 200" , Headers , Body } = delete (" bob" , " q1" , " w1" , 11 , Cfg ),
278+ {ok , " 200" , Headers , Body } = delete (" bob" , " q1" , base64 : encode_to_string ( " w1" ) , 11 , Cfg ),
274279 " application/json" = content_type (Headers ),
275280 Body = success_body (),
276- Select = " select * from bob where a='q1' and b='w1' and c>1 and c<99" ,
277- {ok , " 200" , _Headers2 ,
278- " {\" columns\" :[\" a\" ,\" b\" ,\" c\" ,\" d\" ],"
279- " \" rows\" :[[\" q1\" ,\" w1\" ,20,119]]}" } =
280- execute_query (Select , Cfg ).
281+ Select = " select * from bob where a='q1' and b=" ++ hexlify (" w1" ) ++ " and c>1 and c<99" ,
282+ {ok , " 200" , _Headers2 , QueryBody } = execute_query (Select , Cfg ),
283+ ? assertEqual (
284+ " {\" columns\" :[\" a\" ,\" b\" ,\" c\" ,\" d\" ]," ++
285+ " \" rows\" :[[\" q1\" ,\" " ++ base64 :encode_to_string (" w1" ) ++ " \" ,20,119]]}" ,
286+ QueryBody ).
287+
281288
282289delete_data_nonexisting_row_test (Cfg ) ->
283- {ok , " 404" , Headers , Body } = delete (" bob" , " q1" , " w1" , 500 , Cfg ),
290+ {ok , " 404" , Headers , Body } = delete (" bob" , " q1" , base64 : encode_to_string ( " w1" ) , 500 , Cfg ),
284291 " text/plain" = content_type (Headers ),
285292 " Key not found"
286293 = Body .
287294
288295delete_data_nonexisting_table_test (Cfg ) ->
289- {ok , " 404" , Headers , Body } = delete (" bill" , " q1" , " w1" , 20 , Cfg ),
296+ {ok , " 404" , Headers , Body } = delete (" bill" , " q1" , base64 : encode_to_string ( " w1" ) , 20 , Cfg ),
290297 " text/plain" = content_type (Headers ),
291298 " Table \" bill\" does not exist" = Body .
292299
293300delete_data_wrong_path_test (Cfg ) ->
294- {ok , " 400" , Headers , Body } = delete_wrong_path (" bob" , " q1" , " w1" , 20 , Cfg ),
301+ {ok , " 400" , Headers , Body } = delete_wrong_path (" bob" , " q1" , base64 : encode_to_string ( " w1" ) , 20 , Cfg ),
295302 " text/plain" = content_type (Headers ),
296303 " Not all key-constituent fields given on URL" = Body .
297304
@@ -410,3 +417,6 @@ success_body() ->
410417
411418content_type (Headers ) ->
412419 proplists :get_value (" Content-Type" , Headers ).
420+
421+ hexlify (Bin ) ->
422+ lists :flatten (io_lib :format (" 0x~s " , [mochihex :to_hex (Bin )])).
0 commit comments