2

Is that something that is not allowed? Is it a bug?

I just tried and it did not seem to set anything.

The index of Named_Entity_Big__b is over the following, and I'd like to set Result__c to null:

  1. Entity_Name_Hash__c
  2. NLP_Data_Container__c
  3. SectionIndex__c
  4. Type__c

My code (Anonymous Apex) is below.

List<Named_Entity_Big__b> ents = new List<Named_Entity_Big__b>();

for (Named_Entity_Big__b ent : [SELECT Entity_Name__c, Context__c, Section__c,
                                         SectionIndex__c, Entity_Name_Hash__c,
                                         Result__c, Type__c, NLP_Data_Container__c,
                                         Automated_System__c, Automated_System_Version__c
                              FROM Named_Entity_Big__b]){

      ents.add(new Named_Entity_Big__b(
          Entity_Name_Hash__c = ent.Entity_Name_Hash__c,
          NLP_Data_Container__c = ent.NLP_Data_Container__c,
          SectionIndex__c = ent.SectionIndex__c,
          Type__c = ent.Type__c,
          Entity_Name__c = ent.Entity_Name__c,
          Section__c = ent.Section__c,
          Automated_System__c = ent.Automated_System__c,
          Automated_System_Version__c = ent.Automated_System_Version__c,
          Result__c = ''
      ));
}

List<Database.SaveResult> saveResults = Database.insertImmediate(ents);
for (Database.SaveResult res : saveResults) {
  System.assert(res.isSuccess());
}
  • Have you tried to set Result__c=null instead of Result__c=''? – Adrian Larson Apr 17 '18 at 21:49
  • @AdrianLarson yep. – Charles Koppelman Apr 17 '18 at 21:51
3

I suspect the behavior you are seeing is the result of the merging that occurs when re-inserting of the Big Object records where there is a matching index.

Re-inserting a record with the same index but different data results in behavior similar to an upsert operation. If a record with the index exists, the insert overwrites the index values with the new data.

As there is no data in the Result__c field it is merging in the existing value. Here the empty string and null both appear to be considered no data.

As a workaround, consider explicitly deleting the existing records and insert a new ones.

  • Ugh. I am afraid you're right. I wish there was a way to affirmatively set null. – Charles Koppelman Apr 18 '18 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.