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

RCBC-450: Set value of subdoc exists to true or false if result is success or path-not-found #120

Merged

Conversation

DemetrisChr
Copy link
Contributor

Bring in changes from couchbase/couchbase-cxx-client#452 and make any necessary wrapper-side changes.

When calling #content for an exists spec the result is the same as the result of #exists, provided that the subdoc operation was successful or the error was path-not-found (otherwise an error is raised), which is required to be compliant with the RFC. Previously, a PathNotFound error was raised when the path did not exist. This logic is handled by the C++ core

@DemetrisChr DemetrisChr requested a review from avsej September 18, 2023 17:14
@cb-sdk-robot
Copy link
Collaborator

Can one of the admins verify this patch?

@@ -3517,7 +3517,7 @@ cb_Backend_document_lookup_in(VALUE self, VALUE bucket, VALUE scope, VALUE colle
if (!resp_entry.value.empty()) {
rb_hash_aset(entry, value_property, cb_str_new(resp_entry.value));
}
if (resp_entry.ec && resp_entry.ec != couchbase::errc::key_value::path_not_found) {
if (resp_entry.ec) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no need for this check now that C++ clears path_not_found status codes for exists specs

@@ -191,7 +190,7 @@ def exists?(path_or_index)
end
return false unless field

raise field.error unless field.error.nil?
raise field.error unless field.error.nil? || field.error.is_a?(Error::PathNotFound)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The core can return path_not_found status codes if those are coming from get or count operations. Those should not be raised if #exists is called - they should only be raised for #content

@DemetrisChr DemetrisChr merged commit 9e06b9d into couchbase:main Sep 18, 2023
@DemetrisChr DemetrisChr deleted the RCBC-450-lookup-in-exists-value branch September 18, 2023 19:49
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.

3 participants