8000 Fixed BTS-1703: Cannot chain multiple UPSERTS (#20349) · trooso/arangodb@23afd80 · GitHub
[go: up one dir, main page]

Skip to content

Commit 23afd80

Browse files
authored
Fixed BTS-1703: Cannot chain multiple UPSERTS (arangodb#20349)
1 parent 5b38f20 commit 23afd80

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
devel
22
-----
3+
4+
* Fixed BTS-1703: Cannot chain multiple UPSERTS.
5+
36
* Fixed issue #17673: Adds timezone conversion as an optional parameter in
47
all relevant date functions.
58

arangod/Aql/grammar.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3961,7 +3961,7 @@ YYLTYPE yylloc = yyloc_default;
39613961
{
39623962
// reserve a variable named "$OLD", we might need it in the update expression
39633963
// and in a later return thing
3964-
AstNode* variableNode = parser->ast()->createNodeVariable(Variable::NAME_OLD, true);
3964+
AstNode* variableNode = parser->ast()->createNodeVariable(Variable::NAME_OLD, false);
39653965
parser->pushStack(variableNode);
39663966

39673967
auto scopes = parser->ast()->scopes();
@@ -4041,7 +4041,7 @@ YYLTYPE yylloc = yyloc_default;
40414041
{
40424042
// reserve a variable named "$OLD", we might need it in the update expression
40434043
// and in a later return thing
4044-
AstNode* variableNode = parser->ast()->createNodeVariable(Variable::NAME_OLD, true);
4044+
AstNode* variableNode = parser->ast()->createNodeVariable(Variable::NAME_OLD, false);
40454045

40464046
auto scopes = parser->ast()->scopes();
40474047

arangod/Aql/grammar.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,7 @@ upsert_statement:
14311431
T_UPSERT T_FILTER {
14321432
// reserve a variable named "$OLD", we might need it in the update expression
14331433
// and in a later return thing
1434-
AstNode* variableNode = parser->ast()->createNodeVariable(Variable::NAME_OLD, true);
1434+
AstNode* variableNode = parser->ast()->createNodeVariable(Variable::NAME_OLD, false);
14351435
parser->pushStack(variableNode);
14361436

14371437
auto scopes = parser->ast()->scopes();
@@ -1494,7 +1494,7 @@ upsert_statement:
14941494
| T_UPSERT upsert_input {
14951495
// reserve a variable named "$OLD", we might need it in the update expression
14961496
// and in a later return thing
1497-
AstNode* variableNode = parser->ast()->createNodeVariable(Variable::NAME_OLD, true);
1497+
AstNode* variableNode = parser->ast()->createNodeVariable(Variable::NAME_OLD, false);
14981498

14991499
auto scopes = parser->ast()->scopes();
15001500

tests/js/client/aql/aql-modify-Modify-noncluster.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,22 @@ function ahuacatlModifySuite () {
777777

778778
assertEqual(999999, c1.document("test999999").value1);
779779
assertEqual(1, c1.document("test999999").value2);
780-
}
780+
},
781+
782+
////////////////////////////////////////////////////////////////////////////////
783+
/// @brief multiple upserts on top level
784+
////////////////////////////////////////////////////////////////////////////////
785+
786+
testMultipleUpsertsOnTopLevel : function () {
787+
const actual = db._query("UPSERT { _key: 'foo' } INSERT {} UPDATE { updated: true } IN @@cn1 UPSERT { _key: 'foo' } INSERT {} UPDATE { updated: true } IN @@cn2", { "@cn1": cn1, "@cn2": cn2 });
788+
789+
const expected = { writesExecuted: 2, writesIgnored: 0 };
790+
assertEqual(expected, sanitizeStats(actual.getExtra().stats));
791+
assertEqual([], actual.toArray());
792+
793+
assertTrue(c1.document("foo").updated);
794+
assertTrue(c2.document("foo").updated);
795+
},
781796

782797
};
783798
}

0 commit comments

Comments
 (0)
0