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

Add support for command JSON.STRAPPEND #501 #882

Merged
merged 4 commits into from
Oct 11, 2024

Conversation

karandixit10
Copy link
Contributor

@karandixit10 karandixit10 commented Sep 30, 2024

Fixes #501

Description

This pull request adds support for JSON.STRAPPEND command

image

Copy link
Contributor

@apoorvyadav1111 apoorvyadav1111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, looks good to me, just left a few suggestions. Thanks

integration_tests/commands/async/json_test.go Show resolved Hide resolved
internal/eval/commands.go Outdated Show resolved Hide resolved
internal/eval/eval.go Outdated Show resolved Hide resolved
internal/eval/eval.go Outdated Show resolved Hide resolved
@karandixit10 karandixit10 force-pushed the Issue-501 branch 3 times, most recently from 4a4dabd to 477a429 Compare October 2, 2024 11:53
Copy link
Contributor

@apoorvyadav1111 apoorvyadav1111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, the changes look good to me. Thank you for addressing the comments.

@karandixit10
Copy link
Contributor Author

@lucifercr07 can you merge this PR it's been reviewed

@lucifercr07
Copy link
Contributor

@karandixit10 please resolve conflicts.

@@ -2520,7 +2521,7 @@ func testEvalLLEN(t *testing.T, store *dstore.Store) {
evalSET([]string{"EXISTING_KEY", "mock_value"}, store)
},
input: []string{"EXISTING_KEY"},
output: []byte("-ERR Existing key has wrong Dice type\r\n"),
output: []byte("-Existing key has wrong Dice type\r\n"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change in line with Redis output?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, this return can to be updated. Currently the message in dice is: image But in redis: image I understand we have to replace dice with redis, but we have an extra ERR in the message which can be removed if we modify the object.AssertTypeAndEncoding with the following change:

func AssertTypeAndEncoding(typeEncoding, expectedType, expectedEncoding uint8) []byte {
	if err := AssertType(typeEncoding, expectedType); err != nil {
		return diceerrors.NewErrWithMessage(diceerrors.WrongKeyTypeErr)
	}
	if err := AssertEncoding(typeEncoding, expectedEncoding); err != nil {
		return diceerrors.NewErrWithMessage(diceerrors.WrongKeyTypeErr)
	}
	return nil
}

and add the following error in errors.go file:

	WrongKeyTypeErr        = "-Existing key has wrong Dice type"

How do you feel about this suggestion.

Yeah It's same as the Dice output

Copy link
Contributor

@lucifercr07 lucifercr07 Oct 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's correct, if you pass a message prefixed with - it's not prefixed with an error.
We don't need to change all the test cases in this case.

// NewErrWithMessage If the error code is already passed in the string,
// the error code provided is used, otherwise the string "-ERR " for the generic
// error code is automatically added. Note that 's' must NOT end with \r\n.
func NewErrWithMessage(errMsg string) []byte {
	// If the string already starts with "-..." then the error code
	// is provided by the caller. Otherwise, we use "-ERR".
	if errMsg == "" || errMsg[0] != '-' {
		errMsg = fmt.Sprintf(ErrDefault, errMsg)
	}

	return newDiceErr(errMsg).toEncodedMessage()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I'll revert it back to original

@karandixit10 karandixit10 force-pushed the Issue-501 branch 3 times, most recently from fd77940 to d33bf19 Compare October 4, 2024 12:33
@karandixit10
Copy link
Contributor Author

Hi @lucifercr07 I have made the changes you can merge this now

@karandixit10
Copy link
Contributor Author

Hi @lucifercr07 conflicts are coming now, I'll fix those please merge them after that.

@karandixit10 karandixit10 force-pushed the Issue-501 branch 2 times, most recently from 2d46889 to 7f475ea Compare October 6, 2024 00:24
Copy link
Contributor

@lucifercr07 lucifercr07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please resolve conflicts. We can merge.

@karandixit10
Copy link
Contributor Author

Hi @lucifercr07 , Resolved the confilcts.

@lucifercr07 lucifercr07 merged commit 766cf4e into DiceDB:master Oct 11, 2024
2 checks passed
sashpawar11 pushed a commit to sashpawar11/dice that referenced this pull request Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for command JSON.STRAPPEND
3 participants