orientechnologies / orientechnologies/orientdb

`UPDATE FROM` syntax to allow updates based on result set

Open
#9,569 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
5k
Forks
868
Avg merge
15h 6m
Merged PRs (30d)
18

Description

OrientDB Version: 3.1.10 (docker)

There doesn't seem to be a way to pass a result set to an UPDATE command, at least not from a subquery or a variable. The same applies for CREATE VERTEX. INSERT, however, does support this feature with the FROM keyword.

Practical impact: creating a batch script to handle updates from input records to output records seems to only be possible by using UPDATE Output SET ... to define each and every field.

So, for example, this does NOT work:

LET $inputItems = (SELECT FROM Input);
FOREACH ($inputItem in $inputItems) {
  UPDATE Output FROM $inputItem WHERE id = $inputItem.id;
}

Question: Is there a syntax to do this that works with UPDATE? CREATE VERTEX can be worked around using INSERT, but that doesn't work when updating existing records.

These kinda make sense as syntaxes, but don't work, either:

CREATE VERTEX Output CONTENT $inputItem;
CREATE VERTEX Output CONTENT $inputItem.toJSON();
CREATE VERTEX Output CONTENT (SELECT FROM Input);

Just like other parse errors, these produce a a misleading error about whatever expression is first in the block in which the error occurs.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the UPDATE and CREATE VERTEX examples against OrientDB 3.1.10 in Docker, then trace how UPDATE, INSERT, and subquery result sets are parsed and executed. Done means UPDATE can consume a result set or variable as requested, with parse errors reporting the actual syntax problem.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.