Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

fix(mongodb): nested ObjectId(...) / ISODate(...) in MQL reach the server as {$oid} / {$date} maps

Aberta
#1,667 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
68/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
dart, flutter, mongodb
Domínio
database, databases

Direção de pesquisa

Read lib/features/mongodb/mql_parser.dart to trace how nested Extended JSON wrappers become maps, then inspect mongo_ejson.dart for the existing conversion. Find where the query workspace passes parsed filters and documents, and add tests for nested ObjectId and ISODate values plus strings containing those expressions. Done means the nested values reach the query as BSON ObjectId and DateTime values while matching strings stay strings.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Problem

In the Mongo query workspace, ObjectId(...) and ISODate(...) nested inside a filter or document never become a BSON ObjectId or date:

db.users.find({ _id: ObjectId("5f1d7f0b9d3e2a0017a1b2c3") })
db.events.find({ at: { $gte: ISODate("2026-01-01") } })
db.users.insertOne({ owner: ObjectId("5f1d7f0b9d3e2a0017a1b2c3") })

MqlParser._normalizeJsObject (lib/features/mongodb/mql_parser.dart) turns them into Extended-JSON-shaped maps, {"$oid": "…"} and {"$date": "…"}, and json.decode keeps them as plain maps. Nothing on the MQL path converts them afterwards:

  • mongo_query_workspace.dart sends MqlCommand.filter / document as parsed;
  • mongo_ejson.dart / mongo_field_codec.dart, which do understand $oid, are used by the document views, not here.

So the server receives {_id: {$oid: "…"}}:

  • the find above matches nothing (or fails with an unknown-operator error, depending on the position);
  • an insert stores a sub-document { $oid: … } instead of an ObjectId.

Only a top-level argument that is itself ObjectId(...) / ISODate(...) is converted (MqlParser._parseRelaxedJson).

Noticed while fixing the normalizer in #1661 (#1513, #1539); not changed there.

Expected

After parsing, walk the filter / update / document / pipeline and convert Extended JSON wrappers into BSON values:

  • {"$oid": "<24 hex>"} → ObjectId;
  • {"$date": "<ISO>"} → DateTime (UTC);
  • optionally {"$numberLong": "…"}.

Reuse the conversion mongo_ejson.dart already has, so the document views and the query workspace agree.

Tests
  • find({ _id: ObjectId("…") }) gives a filter whose _id is an ObjectId;
  • an ISODate inside $gte is a DateTime;
  • insertOne with a nested ObjectId stores an ObjectId;
  • a string that merely contains ObjectId("…") stays a string.
Linguagem predominante
Dart
Estrelas
23
Forks
1
Merge médio
31min
PRs com merge (30d)
570

Preparar o ambiente

Abrir no Codespaces

Inicia o contêiner de desenvolvimento do projeto no navegador, com a sua própria conta do GitHub.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de QueryaHub/Querya-Desktop

Todas as issues de QueryaHub/Querya-Desktop

Issues semelhantes

Mais issues de Dart

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.