Skip to content

Commit

Permalink
fix for enable tracking in insert for records coming from a select, i…
Browse files Browse the repository at this point in the history
…ssue #7538
  • Loading branch information
tglman committed Jul 17, 2017
1 parent ba6c02a commit 2a52fa5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.orientechnologies.orient.core.metadata.OMetadataInternal;
import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.record.ORecord;
import com.orientechnologies.orient.core.record.ORecordInternal;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.serialization.serializer.OStringSerializerHelper;
import com.orientechnologies.orient.core.sql.filter.OSQLFilterItemField;
Expand Down Expand Up @@ -286,9 +287,10 @@ public boolean result(final Object iRecord) {
// RESET THE IDENTITY TO AVOID UPDATE
rec.getIdentity().reset();

if (rec instanceof ODocument && className != null)
if (rec instanceof ODocument && className != null) {
((ODocument) rec).setClassName(className);

((ODocument) rec).setTrackingChanges(true);
}
rec.setDirty();
synchronized (this) {
saveRecord(rec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.orientechnologies.orient.core.command.script.OCommandScript;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.exception.OValidationException;
import com.orientechnologies.orient.core.id.ORID;
import com.orientechnologies.orient.core.id.ORecordId;
import com.orientechnologies.orient.core.iterator.ORecordIteratorCluster;
Expand Down Expand Up @@ -298,6 +299,15 @@ public void insertSelect() {
}
}

@Test(expectedExceptions = OValidationException.class)
public void insertSelectFromProjection() {
database.command(new OCommandSQL("CREATE CLASS ProjectedInsert")).execute();
database.command(new OCommandSQL("CREATE property ProjectedInsert.a Integer (max 3)")).execute();
database.getMetadata().getSchema().reload();

database.command(new OCommandSQL("INSERT INTO ProjectedInsert FROM select 10 as a ")).execute();
}

public void insertWithReturn() {

if (!database.getMetadata().getSchema().existsClass("actor2")) {
Expand Down

0 comments on commit 2a52fa5

Please sign in to comment.