Skip to content

Commit

Permalink
Address review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
rdulmina committed Sep 20, 2024
1 parent 49e2d5b commit 962f3f1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/on-conflict-clause/on_conflict_clause.bal
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ public function main() {
];

// The result of the following will be an error since the key `John` is duplicated
// and `isSafeReplace()` function returns an error for the name `John`
// and `isSafeReplace()` function returns an error for the name `John`.
map<int>|error studentScores = map from var {name, score} in students
select [name, score]
on conflict isSafeReplace(name);

io:println(studentScores);

// The result of the following will be an error since the key `1` is duplicated
// and `isSafeReplace()` function returns an error for the name `John`
// and `isSafeReplace()` function returns an error for the name `John`.
table<Student> key(id)|error studentScoresTable = table key(id) from var student in students
select student
on conflict isSafeReplace(student.name);
Expand All @@ -36,15 +36,15 @@ public function main() {
];

// The value `100` of the key `Mike` will be replaced by the second occurrence value `200`
// since `isSafeReplace()` function returns `null` for the name 'Mike`
// since `isSafeReplace()` function returns `null` for the name 'Mike`.
map<int>|error lastRoundScore = map from var student in students2
select [student.name, student.score]
on conflict isSafeReplace(student.name);

io:println(lastRoundScore);

// The return value will be just the construct type if the `on conflict` clause
// always returns `()`
// always returns `()`.
map<int> lastRoundScore2 = map from var student in students2
select [student.name, student.score]
on conflict ();
Expand Down

0 comments on commit 962f3f1

Please sign in to comment.