We have a public custom settings Batch_Settings__c of type Hierarchy (Organisation level) and it has a date/time field called "Last_Run__c".
The field Last_Run__c is null, but SOQL filtered on this date still returns data. We have this issue both when executing SOQL from Execute Anonymous script or from batch apex.
API version: 46
Refer to this sample script to illustrate this issue.
Batch_Settings__c settings = Batch_Settings__c.getOrgDefaults(); system.debug('settings.Last_Run__c = '+ settings.Last_Run__c); //settings.Last_Run__c = null List<Contact> contactList = [select id, name from contact where LastModifiedDate >= :settings.Last_Run__c limit 5]; system.debug('contactList.size= '+contactList.size()); //size=5 system.debug('contactList= '+contactList);
Can anyone explain why this is happening ?