orientechnologies/orientdb — pull request #2325 by kowalot (2014-05-10 07:23:32+00:00)
Title: #2319 UPDATE RETURN <expression> syntax

In this pull request you may find implementation of #2319 UPDATE RETURN syntax.
Now it's possible to define what will be returned using record attributes and $current record potentially enriched by functions.
Please find below possible variants of usage:

Existing syntax

UPDATE ♯7:0 SET gender='male' RETURN AFTER
UPDATE ♯7:0 SET gender='male' RETURN BEFORE
UPDATE ♯7:0 SET gender='male' RETURN COUNT

enhanced by optional expressions

UPDATE ♯7:0 SET gender='male' RETURN AFTER @rid
UPDATE ♯7:0 SET gender='male' RETURN AFTER @version
UPDATE ♯7:0 SET gender='male' RETURN AFTER @this
UPDATE ♯7:0 INCREMENT Counter = 123 RETURN BEFORE $current.Counter
UPDATE ♯7:0 SET gender='male' RETURN AFTER $current.exclude(„really_big_field”)
UPDATE ♯7:0 ADD out_Edge = ♯12:1 RETURN AFTER $current.outE(„Edge”)

In case when single field is returned, the result is wrapped in a record storing value in „result” field (Just to avoid introducing new serialisation – there is no primitive-values collection serialization in binary protocol). Additionally to that usefull fields like version and rid of original record is provided in corresponding fields. New syntax will allow to optimise client-server network traffic.

## Additional notes: ##
Result projections are processed after releasing locks just to avoid potential locks.
The meaning of $current variable is compatible to equivalent traverse's command variable.
New test cases has been added to cover mentioned syntax.
All tests passed.