- changed title to SOSL[0]
SOSL[0]
Hey there! Minor to moderate issue - it's my first dive into SOSL, and I found the following:
Search.query() or a hardcoded SOSL using square brackets both return List<List<SObject>>. If the query returns no results, then the outer list length will be the number of returning objects and the inner will be empty (but not null) so the following should be safe (and it does compile):
IJ/IC says that it's an illegal conversion from List<List<SObject>> to List<SObject>, since the variable "contacts" in this context is a List<SObject>. However when I replace [0] with .get(0):
There are no issues.
Comments (3)
-
reporter -
repo owner Turns out this was a more insidious issue than it seemed at first. The following also causes the issue:
List<List<SObject>> results = new List<List<SObject>>(); List<Contact> contacts = results[0];
Basically when you index into a list of lists, it was incorrectly inferring a data type of
List<ElementType>[]
instead ofList<ElementType>
.Thanks for bringing this to my attention! Fix submitted for inclusion in the next build.
-
repo owner - changed status to resolved
Delivered in 2.0.1.2 and 1.8.2.1.
- Log in to comment