Create edge upsert not working in 3.0.16

I haven’t managed to create new edges or skip them if they exist. I’m using pyorient with batch commands and haven’t managed to get it working.

"let A = update software_subcategory set name = \"%s\",segmentId = \"PADU\""
", domain=\"PADU\", modifiedByProcess=\"PADU\" upsert return after @rid where name = \"%s\"\n"
"let B = update software set name = \"%s\", version = \"%s\", segmentId = \"PADU\""
", domain=\"PADU\", modifiedByProcess=\"PADU\" upsert return after @rid where name = \"%s\" "
"AND version = \"%s\"\n"
"   let F = create edge containsThis upsert from $A to $B\n"

the error I get is:

pyorient.exceptions.PyOrientORecordDuplicatedException: com.orientechnologies.orient.core.storage.ORecordDuplicatedException - Cannot index record #262:1562: found duplicated key 'OCompositeKey{keys=[#249:0, #259:9]}' in index 'containsThis.in_out' previously assigned to the record #261:0
	DB name="test-padu"

my schema looks like this:

Hi,
regarding the error, seems that the record you’re trying to create already exists. That error is returned due to your UNIQUE Index.

Regards,
Michela

right, I was under the impression that the upsert will skip them.

Hi @joshhw

Pyorient still uses the old SQL executor, that does not support CREATE EDGE UPSERT properly.
I’m afraid you will have to find a work-around (eg. manage the unique index violation at application level) or use the REST API

Thanks

Luigi