-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Environment:OS:
node.js / npm versions:
Additional info:
-
1
-
Not Needed
-
Developer Tools
Problem Statement/Rationale
What is going wrong? What action would you like the Engineering team to take?
When the query uses the .iterator method, the Java parser does not know where the actual query predicate is. It seems to be an issue with the method `findMongoDbCollectionMethodCallForCommand`.
Steps to Reproduce
How could an engineer replicate the issue you’re reporting?
@ParsingTest( fileName = "Repository.java", value = """ import com.mongodb.client.MongoClient; import com.mongodb.client.MongoCollection; import com.mongodb.client.MongoCursor; import org.bson.types.ObjectId; import java.util.ArrayList; import static com.mongodb.client.model.Filters.*; public final class Repository { private final MongoClient client; public Repository(MongoClient client) { this.client = client; } public MongoCursor<Document> findBookById(ObjectId id) { return getCollection().find(eq("_id", id)).iterator(); } private MongoCollection<Document> getCollection() { return client.getDatabase("simple").getCollection("books"); } } """, ) fun `correctly parses a query with iterator() as FIND_MANY command`(psiFile: PsiFile) { val query = psiFile.getQueryAtMethod("Repository", "findBookById") val parsedQuery = JavaDriverDialect.parser.parse(query) val command = parsedQuery.component<IsCommand>() assertEquals(IsCommand.CommandType.FIND_MANY, command?.type) val filters = parsedQuery.component<HasFilter<PsiElement>>()!! val filterById = filters.children[0].component<HasFieldReference<PsiElement>>()!!.reference assertEquals("_id", (filterById as HasFieldReference.FromSchema).fieldName) }
Expected Results
What do you expect to happen?
It should be able to detect the query predicate.
Actual Results
What do you observe is happening?
When generating queries and creating indexes for queries using .iterator, it shows empty.
Additional Notes
Any additional information that may be useful to include.