@@ -21,16 +21,71 @@ function TestRelationalOperand_testUpdateDate(testCase)
2121 ));
2222 q = University .All & ' id=2' ;
2323
24- new_value = ' ' ;
24+ new_value = [] ;
2525 q .update(' date' , new_value );
26- testCase .verifyEqual(q .fetch1(' date' ), new_value );
26+ res = mym([' select date from `' testCase .PREFIX ...
27+ ' _university`.`all` where id=2 and date is null;' ]);
28+ testCase .verifyEqual(length(res .date ), 1 );
2729
2830 new_value = ' 2020-04-14' ;
2931 q .update(' date' , new_value );
30- testCase .verifyEqual(q .fetch1(' date' ), new_value );
32+ res = mym([' select date from `' testCase .PREFIX ...
33+ ' _university`.`all` where id=2 and date like '' ' new_value ' '' ;' ]);
34+ testCase .verifyEqual(length(res .date ), 1 );
3135
3236 q .update(' date' );
33- testCase .verifyEqual(q .fetch1(' date' ), ' ' );
37+ res = mym([' select date from `' testCase .PREFIX ...
38+ ' _university`.`all` where id=2 and date is null;' ]);
39+ testCase .verifyEqual(length(res .date ), 1 );
40+ end
41+ function TestRelationalOperand_testUpdateString(testCase )
42+ st = dbstack ;
43+ disp([' ---------------' st(1 ).name ' ---------------' ]);
44+ % related https://github.com/datajoint/datajoint-matlab/issues/211
45+ package = ' University' ;
46+
47+ c1 = dj .conn(...
48+ testCase .CONN_INFO .host ,...
49+ testCase .CONN_INFO .user ,...
50+ testCase .CONN_INFO .password ,' ' ,true );
51+
52+ dj .createSchema(package ,[testCase .test_root ' /test_schemas' ], ...
53+ [testCase .PREFIX ' _university' ]);
54+
55+ insert(University .All , struct( ...
56+ ' id' , 3 , ...
57+ ' string' , ' normal' ...
58+ ));
59+ q = University .All & ' id=3' ;
60+
61+ new_value = ' ' ;
62+ q .update(' string' , new_value );
63+ res = mym([' select string from `' testCase .PREFIX ...
64+ ' _university`.`all` where id=3 and string like '' ' new_value ' '' ;' ]);
65+ testCase .verifyEqual(length(res .string ), 1 );
66+
67+ new_value = ' ' ;
68+ q .update(' string' , new_value );
69+ res = mym([' select string from `' testCase .PREFIX ...
70+ ' _university`.`all` where id=3 and string like '' ' new_value ' '' ;' ]);
71+ testCase .verifyEqual(length(res .string ), 1 );
72+
73+ new_value = [];
74+ q .update(' string' , new_value );
75+ res = mym([' select string from `' testCase .PREFIX ...
76+ ' _university`.`all` where id=3 and string is null;' ]);
77+ testCase .verifyEqual(length(res .string ), 1 );
78+
79+ new_value = ' diff' ;
80+ q .update(' string' , new_value );
81+ res = mym([' select string from `' testCase .PREFIX ...
82+ ' _university`.`all` where id=3 and string like '' ' new_value ' '' ;' ]);
83+ testCase .verifyEqual(length(res .string ), 1 );
84+
85+ q .update(' string' );
86+ res = mym([' select string from `' testCase .PREFIX ...
87+ ' _university`.`all` where id=3 and string is null;' ]);
88+ testCase .verifyEqual(length(res .string ), 1 );
3489 end
3590 end
3691end
0 commit comments