Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating new Vertex that links existing Vertex in LINKMAP modifies existing Vertex #6272

Closed
Eric24 opened this issue Jun 8, 2016 · 4 comments
Assignees
Labels

Comments

@Eric24
Copy link

Eric24 commented Jun 8, 2016

Expected new Vertex to be created without modifying existing Vertex.

State before 'create vertex' (notice data in #23:1 Samples EMBEDDEDMAP property):

{
    "result": [
        {
            "@type": "d",
            "@rid": "#23:0",
            "@version": 5,
            "@class": "VData",
            "Samples": {
                "00": {
                    "@type": "d",
                    "@version": 0,
                    "@class": "VSample",
                    "Count": 1,
                    "Scale": 0,
                    "Sum16": 12345,
                    "@fieldTypes": "Scale=b,Sum16=s"
                }
            }
        },
        {
            "@type": "d",
            "@rid": "#23:1",
            "@version": 3,
            "@class": "VData",
            "Samples": {
                "00": {
                    "@type": "d",
                    "@version": 0,
                    "@class": "VSample",
                    "Count": 1,
                    "Scale": 0,
                    "Sum16": 12345,
                    "@fieldTypes": "Scale=b,Sum16=s"
                }
            }
        },
        {
            "@type": "d",
            "@rid": "#23:2",
            "@version": 1,
            "@class": "VData",
            "Children": {
                "456": "#23:1"
            }
        },
        {
            "@type": "d",
            "@rid": "#23:3",
            "@version": 1,
            "@class": "VData",
            "Children": {
                "789": "#23:1"
            }
        }
    ]
}

Command executed:
create vertex VData content {"Children": {"234": {"@type":"d", "@class":"VData", "@rid": "#23:1"}}}

State after 'create vertex' (notice incremented version and missing data in #23:1 Samples property):

{
    "result": [
        {
            "@type": "d",
            "@rid": "#23:0",
            "@version": 5,
            "@class": "VData",
            "Samples": {
                "00": {
                    "@type": "d",
                    "@version": 0,
                    "@class": "VSample",
                    "Count": 1,
                    "Scale": 0,
                    "Sum16": 12345,
                    "@fieldTypes": "Scale=b,Sum16=s"
                }
            }
        },
        {
            "@type": "d",
            "@rid": "#23:1",
            "@version": 4,
            "@class": "VData"
        },
        {
            "@type": "d",
            "@rid": "#23:2",
            "@version": 1,
            "@class": "VData",
            "Children": {
                "456": "#23:1"
            }
        },
        {
            "@type": "d",
            "@rid": "#23:3",
            "@version": 1,
            "@class": "VData",
            "Children": {
                "789": "#23:1"
            }
        },
        {
            "@type": "d",
            "@rid": "#23:4",
            "@version": 1,
            "@class": "VData",
            "Children": {
                "234": "#23:1"
            }
        }
    ]
}

Version number in referenced Vertex is incremented, so ODB is clearly updating it, but why? This is repeatable and the modified Vertex is always the one referenced in the new Vertex.

Notes on schema:

  1. Children is an LINKMAP of VData
  2. Samples is an EMBEDDEDMAP of VSample

Runninng Mode: Embedded, using PLOCAL access mode; running SQL from Studio

OrientDB Version: v2.2.0 on Linux (CentOS)

Java Version:
openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)

@Eric24
Copy link
Author

Eric24 commented Jun 8, 2016

PS - I verified that this issue affects any/all properties in the referenced Vertex. If any properties exist, they will be removed upon creating the new Vertex with the reference. But if the referenced Vertex does not contain any properties (i.e. the "empty" state it's left in after the create), then it is apparently untouched, as evidenced by the version number not being updated.

@Eric24
Copy link
Author

Eric24 commented Jun 9, 2016

PPS - I tried one more test: If I create the new Vertex first, without including the Children property, and then later update the new Vertex and update the Children property (using PUT), it adds the reference without affecting the referenced Vertex. So the issue appears to only happen if the reference is included in the initial create operation.

@Eric24
Copy link
Author

Eric24 commented Jun 9, 2016

Also, just to confirm that this wasn't specifically related to 'create vertex', I tried this approach too:

insert into VData content {"Children": {"234": {"@type":"d", "@class":"VData", "@rid": "#23:1"}}}

Which has the same effect of "clearing" any existing properties from the referenced rid.

@Eric24
Copy link
Author

Eric24 commented Jun 9, 2016

One more test that I thought of: If I do the same operation in a custom function (below), it works just fine (and no difference between 'create vertex' and 'insert into').

begin;
let r1 = insert into VData set Notes = 'R1', Samples = {"01":{"@type":"d", "@class":"VSample", "Count": 1, "Scale": 0, "Sum16": 111}};
let r2 = insert into VData set Notes = 'R2', Samples = {"02":{"@type":"d", "@class":"VSample", "Count": 1, "Scale": 0, "Sum16": 222}}, Children = {"01": $r1};
commit;

@lvca lvca added the bug label Jun 10, 2016
@luigidellaquila luigidellaquila self-assigned this Jun 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants