@@ -3128,4 +3128,31 @@ TEST_F(JsonFamilyTest, JsonCommandsWorkingWithOtherTypesBug) {
3128
3128
EXPECT_THAT (resp, " value" );
3129
3129
}
3130
3130
3131
+ TEST_F (JsonFamilyTest, ResetStringKeyWithSetGet) {
3132
+ auto resp = Run ({" JSON.SET" , " key" , " $" , R"( {"a":"b"})" });
3133
+ ASSERT_THAT (resp, " OK" );
3134
+
3135
+ resp = Run ({" JSON.GET" , " key" });
3136
+ EXPECT_THAT (resp, R"( {"a":"b"})" );
3137
+
3138
+ // Resetting the key with a string value
3139
+ resp = Run ({" SET" , " key" , R"( {"a":"b"})" });
3140
+ ASSERT_THAT (resp, " OK" );
3141
+
3142
+ resp = Run ({" GET" , " key" });
3143
+ EXPECT_THAT (resp, R"( {"a":"b"})" );
3144
+
3145
+ // JSON.GET should still work after resetting the key with a string value
3146
+ resp = Run ({" JSON.GET" , " key" });
3147
+ EXPECT_THAT (resp, R"( {"a":"b"})" );
3148
+
3149
+ // Resetting the key again with JSON.SET
3150
+ // This should not cause any issues
3151
+ resp = Run ({" JSON.SET" , " key" , " $" , R"( {"a":"b"})" });
3152
+ ASSERT_THAT (resp, " OK" );
3153
+
3154
+ resp = Run ({" JSON.GET" , " key" });
3155
+ EXPECT_THAT (resp, R"( {"a":"b"})" );
3156
+ }
3157
+
3131
3158
} // namespace dfly
0 commit comments