Orientdb: delete binary records via sql problem in 2.1.15

Created on 6 Apr 2016  Â·  7Comments  Â·  Source: orientechnologies/orientdb

Dear @luigidellaquila
based on https://github.com/orientechnologies/orientdb/issues/5748 I'd tested it now in 2.1.15
when i was try to delete via delete from 15:0 command everything works well :+1:

but when i was trying to delete record from a select that contains a linked field that contains row id of my blobs , delete not working yet :
delete from (select Blob from FileItem)
also when i try to write another kind query does not working and returns error
delete from cluster:BlobStorage where @rid in (select Blob from FileItem)
returns :
java.lang.ClassCastException: com.orientechnologies.orient.core.record.impl.ORecordBytes cannot be cast to com.orientechnologies.orient.core.record.impl.ODocument

for clearing what was happened i tried to run select @rid from cluster:BlobStorage that returns nothing but when i run select from cluster:BlobStorage returns a binary record that have @ rid and @ version and a base64 encoded string field . i'm wondered now . is it a new bug ?

how can i delete binary record via a nested select where query ?
please help me to write a true delete statement .

at the last :
Actually i have an opinion for select from Binary Record in Select Command .
*it's better select from blobstorage returns record id and record bytes size for binary records . now select from blobstorage (binary records) returns nothing *

thnaks

bug

All 7 comments

Hi @tglman
is its working on 2.1.16 ?

Thanks
Saeed

@saeedtabrizi

yes 2.1.16 contains this fix

could you verify? can we close this ?

Hi @tglman
Actually not :-1:
i'd tested in some of case :
1) delete from cluster:BlobStorage where @rid in (select Blob from FileItem limit 7) throws exception java.lang.ClassCastException: com.orientechnologies.orient.core.record.impl.ORecordBytes cannot be cast to com.orientechnologies.orient.core.record.impl.ODocument
2) delete from cluster:blobstorage limit 4 , works true :+1:
3) delete from (select Blob from FileItem limit 7) return 7 but not deleted really . it's buggy yet .

Thanks
Saeed

fixed the case 1 as well, for the case 3 the query is not exactly correct and actually from my tests it return 0, the correct query is elete from (select expand(Blob) from FileItem limit 7)

Can you double check that all the case are now covered ?

Regards

closing this, if there are some more issue please reopen

Hi @tglman
Sorry for late , I test it with ODB 2.2 and same database that contains blobstorage :
delete from (select expand(Blob) from FileItem limit 7)
only returns java.lang.NullPointerException
and
select from (select expand(Blob) from FileItem limit 7)
returns only 3 record but i have more than 900 records in FileItem class .
rr

and does not delete anything . it seems to remains buggy .

Thanks
Saeed Tabrizi

Hi @saeedtabrizi

I just tried this on 2.2.x branch (but I think nothing changed since 2.2.6)

 @Test
  public void testBinaryClusterSelect3() {
    database.command(new OCommandSQL("create class testBinaryClusterSelect3")).execute();
    database.command(new OCommandSQL("create blob cluster testBinaryClusterSelect3_blob")).execute();
    database.reload();
    OBlob bytes = new ORecordBytes(new byte[]{1,2,3});
    database.save(bytes, "testBinaryClusterSelect3_blob");

    ODocument doc = new ODocument("testBinaryClusterSelect3");
    doc.field("Blob", bytes);
    doc.save();

    ODocument doc2 = new ODocument("testBinaryClusterSelect3");
    doc2.save();

    List<OIdentifiable> result = database.query(
        new OSQLSynchQuery<OIdentifiable>("select from cluster:testBinaryClusterSelect3_blob"));

    Assert.assertEquals(result.size(), 1);

    database.command(new OCommandSQL("delete from (select expand(Blob) from testBinaryClusterSelect3)")).execute();
    result = database.query(
        new OSQLSynchQuery<OIdentifiable>("select from cluster:testBinaryClusterSelect3_blob"));

    Assert.assertEquals(result.size(), 0);
  }

And it succeeds.

Which 2.2 are you using? Did you try with latest stable?

Thanks

Luigi

Was this page helpful?
0 / 5 - 0 ratings