* Convert a SET clause into a SetStep. * Supports three types of assignments: * 1. Individual property: n.prop = value * 2. Replace all properties: n = {props} * 3. Add/merge properties: n += {props}
(setClause: SetClause)
| 525 | * 3. Add/merge properties: n += {props} |
| 526 | */ |
| 527 | function convertSetClause(setClause: SetClause): SetStep { |
| 528 | const assignments: StepSetOperation[] = setClause.assignments.map((assignment) => { |
| 529 | // Check for SetAllProperties or SetAddProperties (map-based assignments) |
| 530 | if ("type" in assignment) { |
| 531 | if (assignment.type === "SetAllProperties") { |
| 532 | const setAll = assignment as SetAllProperties; |
| 533 | return { |
| 534 | type: "setAllProperties" as const, |
| 535 | variable: setAll.variable, |
| 536 | properties: convertSetMapValue(setAll.properties), |
| 537 | }; |
| 538 | } else if (assignment.type === "SetAddProperties") { |
| 539 | const setAdd = assignment as SetAddProperties; |
| 540 | return { |
| 541 | type: "setAddProperties" as const, |
| 542 | variable: setAdd.variable, |
| 543 | properties: convertSetMapValue(setAdd.properties), |
| 544 | }; |
| 545 | } |
| 546 | } |
| 547 | // Individual property assignment: n.prop = value |
| 548 | return { |
| 549 | variable: assignment.variable, |
| 550 | property: assignment.property, |
| 551 | value: convertSetValue(assignment.value), |
| 552 | }; |
| 553 | }); |
| 554 | |
| 555 | return new SetStep({ assignments }); |
| 556 | } |
| 557 | |
| 558 | /** |
| 559 | * Convert a SET map value (property map or parameter reference). |
no test coverage detected