Skip to content

Commit

Permalink
Convert non-Strings in Lists to Strings before sending to Redis
Browse files Browse the repository at this point in the history
  • Loading branch information
eknoes committed Aug 9, 2019
1 parent b5d23d0 commit d83fd2d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/redisserialise.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class RedisSerialise {
consumer(_star);
consumer(_IntToRaw(len));
consumer(_linesep);
object.forEach((v)=>SerialiseConsumable(v,consumer));
object.forEach((v)=> SerialiseConsumable(v is int ? v.toString() : v,consumer));
}
else if(object is int){
consumer(_semicol);
Expand Down
2 changes: 2 additions & 0 deletions test/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ part 'testperformance.dart';
part 'testpubsub.dart';
part 'testlua.dart';
part 'testunicode.dart';
part 'testconversion.dart';


Future testing_performance(Function fun,String name, int rep){
Expand Down Expand Up @@ -53,6 +54,7 @@ main(){
q.add(testing_helper(test_commands_one_by_one(),"one by one"));
q.add(testing_helper(testincrcasmultiple(),"CAS"));
q.add(testing_helper(testluanative(),"eval"));
q.add(testing_helper(testConversion(),"Convert ints to strings when in Array"));

Future.wait(q)
.then((_){
Expand Down
18 changes: 18 additions & 0 deletions test/testconversion.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
part of testredis;

Future testConversion() {

RedisConnection conn = new RedisConnection();
return conn.connect('localhost',6379).then((Command command) {
command.send_object(["SADD", "test_list", 1]).then((val) {
if(val is RedisError) {
throw "Expected redis-dart to convert integers to bulk strings when contained in array.";
}
return true;
})
.catchError((error) {
throw "Expected redis-dart to convert integers to bulk strings when contained in array.";
});
});

}

0 comments on commit d83fd2d

Please sign in to comment.