Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1101: Refactor evalAPPEND to handle leading zeros in value #1107

Merged
merged 4 commits into from
Oct 16, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions internal/eval/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -4582,6 +4582,15 @@ func evalAPPEND(args []string, store *dstore.Store) []byte {

if obj == nil {
// Key does not exist path

// check if the value starts with '0' and has more than 1 character to handle leading zeros
if len(value) > 1 && value[0] == '0' {
// treat as string if has leading zeros
store.Put(key, store.NewObj(value, -1, object.ObjTypeString, object.ObjEncodingRaw))
return clientio.Encode(len(value), false)
}

// Deduce type and encoding based on the value if no leading zeros
oType, oEnc := deduceTypeEncoding(value)

var storedValue interface{}
Expand Down