8000 Fixed issue #14720 by jsteemann · Pull Request #14772 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Fixed issue #14720 #14772

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

Merged
merged 2 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
v3.8.2 (XXXX-XX-XX)
-------------------

* Fixed issue #14720: Bulk import ignores onDuplicate in 3.8.0.
The "onDuplicate" attribute was ignored by the `/_api/import` REST API when
not specifying the "type" URL parameter.

* Fix internal iterator states after intermediate commits in write transactions.
Iterators could point to invalid data after an intermediate commit, producing
undefined behavior.
Expand Down
4 changes: 2 additions & 2 deletions arangod/RestHandler/RestImportHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,8 @@ bool RestImportHandler::createFromKeyValueList() {
bool const complete = _request->parsedValue("complete", false);
bool const overwrite = _request->parsedValue("overwrite", false);
_ignoreMissing = _request->parsedValue("ignoreMissing", false);
OperationOptions opOptions(_context);
opOptions.waitForSync = _request->parsedValue("waitForSync", false);
OperationOptions opOptions = buildOperationOptions();
opOptions.waitForSync = _request->parsedValue(StaticStrings::WaitForSyncString, false);

// extract the collection name
bool found;
Expand Down
73 changes: 73 additions & 0 deletions tests/rb/HttpInterface/api-import-spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,79 @@
doc.parsed_response['value2'].should eq('test')
doc.parsed_response.should_not have_key('value3')
end

it "using onDuplicate=update, values" do
cmd = api + "?collection=#{@cn}&onDuplicate=update"
body = "[\"_key\",\"value\"]\n"
body += "[\"test1\",1]\n"
body += "[\"test1\",2]\n"
body += "[\"test2\",23]\n"
body += "[\"test2\",42]\n"
body += "[\"test3\",99]\n"
doc = ArangoDB.log_post("#{prefix}-update", cmd, :body => body)

doc.code.should eq(201)
doc.parsed_response['error'].should eq(false)
doc.parsed_response['created'].should eq(1)
doc.parsed_response['errors'].should eq(0)
doc.parsed_response['empty'].should eq(0)
doc.parsed_response['ignored'].should eq(0)
doc.parsed_response['updated'].should eq(4)

doc = ArangoDB.get("/_api/document/#{@cn}/test1")
doc.code.should eq(200)
doc.parsed_response['_key'].should eq('test1')
doc.parsed_response['value'].should eq(2)

doc = ArangoDB.get("/_api/document/#{@cn}/test2")
doc.code.should eq(200)
doc.parsed_response['_key'].should eq('test2')
doc.parsed_response['value'].should eq(42)

doc = ArangoDB.get("/_api/document/#{@cn}/test3")
doc.code.should eq(200)
doc.parsed_response['_key'].should eq('test3')
doc.parsed_response['value'].should eq(99)
end

it "using onDuplicate=error, values" do
cmd = api + "?collection=#{@cn}&onDuplicate=error"
body = "[\"_key\",\"value1\"]\n"
body += "[\"test1\",17]\n"
body += "[\"test2\",23]\n"
body += "[\"test3\",99]\n"
body += "[\"test4\",\"abc\"]\n"
body += "[\"test4\",\"def\"]\n"
doc = ArangoDB.log_post("#{prefix}-update", cmd, :body => body)

doc.code.should eq(201)
doc.parsed_response['error'].should eq(false)
doc.parsed_response['created'].should eq(2)
doc.parsed_response['errors'].should eq(3)
doc.parsed_response['empty'].should eq(0)
doc.parsed_response['ignored'].should eq(0)
doc.parsed_response['updated'].should eq(0)

doc = ArangoDB.get("/_api/document/#{@cn}/test1")
doc.code.should eq(200)
doc.parsed_response['_key'].should eq('test1')
doc.parsed_response['value1'].should eq(1)

doc = ArangoDB.get("/_api/document/#{@cn}/test2")
doc.code.should eq(200)
doc.parsed_response['_key'].should eq('test2')
doc.parsed_response['value1'].should eq("abc")

doc = ArangoDB.get("/_api/document/#{@cn}/test3")
doc.code.should eq(200)
doc.parsed_response['_key'].should eq('test3')
doc.parsed_response['value1'].should eq(99)

doc = ArangoDB.get("/_api/document/#{@cn}/test4")
doc.code.should eq(200)
doc.parsed_response['_key'].should eq('test4')
doc.parsed_response['value1'].should eq("abc")
end
end

end
Expand Down
0