While testing some SOQL queries I noticed that the Equal operator behaves like the IN operator when using a list bind variable
All the queries below run without any error and return the same result
List<String> accNames=new List<String>{'Acme Corporation','Smith Enterprises'};
System.debug('Dynamic Query bind list with Equal operator :'+Database.query('select Name from account where Name = :accNames'));
System.debug('Static Query bind list with Equal operator :'+[select name from account where name = :accNames]);
System.debug('Dynamic Query bind list with IN operator :'+Database.query('select Name from account where Name in :accNames'));
System.debug('Static Query bind list with IN operator :'+[select name from account where name in :accNames]);
Debug
DEBUG|Dynamic Query bind list with Equal operator :(Account:{Name=Acme Corporation, Id=0010Y00000E7whoQAB}, Account:{Name=Smith Enterprises, Id=0010Y00000E7wXsQAJ})
DEBUG|Static Query bind list with Equal operator :(Account:{Name=Acme Corporation, Id=0010Y00000E7whoQAB}, Account:{Name=Smith Enterprises, Id=0010Y00000E7wXsQAJ})
DEBUG|Dynamic Query bind list with IN operator :(Account:{Name=Acme Corporation, Id=0010Y00000E7whoQAB}, Account:{Name=Smith Enterprises, Id=0010Y00000E7wXsQAJ})
DEBUG|Static Query bind list with IN operator :(Account:{Name=Acme Corporation, Id=0010Y00000E7whoQAB}, Account:{Name=Smith Enterprises, Id=0010Y00000E7wXsQAJ})
Are the IN
and =
operators equal when using a list bind variable?