diff --git a/packages/compass-import-export/src/export/export-json.spec.ts b/packages/compass-import-export/src/export/export-json.spec.ts index ea630575ce5..fa8d96d868a 100644 --- a/packages/compass-import-export/src/export/export-json.spec.ts +++ b/packages/compass-import-export/src/export/export-json.spec.ts @@ -222,6 +222,7 @@ describe('exportJSON', function () { ); } catch (err) { console.log(expectedResultsPath); + console.log(resultText); throw err; } diff --git a/packages/compass-import-export/src/import/import-json.spec.ts b/packages/compass-import-export/src/import/import-json.spec.ts index 5b7efdad535..51525e6ca26 100644 --- a/packages/compass-import-export/src/import/import-json.spec.ts +++ b/packages/compass-import-export/src/import/import-json.spec.ts @@ -132,7 +132,7 @@ describe('importJSON', function () { hasUnboundArray: false, }); - const docs = await dataService.find(ns, {}); + const docs = await dataService.find(ns, {}, { promoteValues: false }); expect(docs).to.have.length(totalRows); @@ -158,7 +158,7 @@ describe('importJSON', function () { throw err; } - const expectedResult = EJSON.parse(text); + const expectedResult = EJSON.parse(text, { relaxed: false }); expect( docs, basename.replace(/\.((jsonl?)|(csv))$/, '.imported.ejson') diff --git a/packages/compass-import-export/src/import/import-json.ts b/packages/compass-import-export/src/import/import-json.ts index 7fe7e130ad1..aec7e66b026 100644 --- a/packages/compass-import-export/src/import/import-json.ts +++ b/packages/compass-import-export/src/import/import-json.ts @@ -78,7 +78,9 @@ export async function importJSON({ throw new Error('Value is not an object'); } - const doc = EJSON.deserialize(chunk.value); + const doc = EJSON.deserialize(chunk.value as Document, { + relaxed: false, + }); callback(null, doc); } catch (err: unknown) { processParseError({ diff --git a/packages/compass-import-export/test/fixtures.ts b/packages/compass-import-export/test/fixtures.ts index ffff0d54f0e..bc7d4d5e3f2 100644 --- a/packages/compass-import-export/test/fixtures.ts +++ b/packages/compass-import-export/test/fixtures.ts @@ -58,6 +58,7 @@ const fixtures = { json: { good: path.join(__dirname, 'json', 'good.json'), complex: path.join(__dirname, 'json', 'complex.json'), + promotable: path.join(__dirname, 'json', 'promotable.json'), }, // jsonl diff --git a/packages/compass-import-export/test/json/good.imported.ejson b/packages/compass-import-export/test/json/good.imported.ejson index 458e211807b..1d7b151457c 100644 --- a/packages/compass-import-export/test/json/good.imported.ejson +++ b/packages/compass-import-export/test/json/good.imported.ejson @@ -26,4 +26,4 @@ }, "name": "Kochka" } -] \ No newline at end of file +] diff --git a/packages/compass-import-export/test/json/promotable.exported.csv b/packages/compass-import-export/test/json/promotable.exported.csv new file mode 100644 index 00000000000..4ba6bdfb005 --- /dev/null +++ b/packages/compass-import-export/test/json/promotable.exported.csv @@ -0,0 +1,2 @@ +_id,doubleNum +1,-45 diff --git a/packages/compass-import-export/test/json/promotable.exported.ejson b/packages/compass-import-export/test/json/promotable.exported.ejson new file mode 100644 index 00000000000..816a0132602 --- /dev/null +++ b/packages/compass-import-export/test/json/promotable.exported.ejson @@ -0,0 +1,6 @@ +[{ + "_id": { + "$oid": "654d2167b25d1813f7c40749" + }, + "doubleNum": -45 +}] \ No newline at end of file diff --git a/packages/compass-import-export/test/json/promotable.gathered.json b/packages/compass-import-export/test/json/promotable.gathered.json new file mode 100644 index 00000000000..cd09f0178e7 --- /dev/null +++ b/packages/compass-import-export/test/json/promotable.gathered.json @@ -0,0 +1,9 @@ +{ + "paths": [["_id"], ["doubleNum"]], + "docsProcessed": 1, + "aborted": false, + "projection": { + "_id": 1, + "doubleNum": 1 + } +} diff --git a/packages/compass-import-export/test/json/promotable.imported.ejson b/packages/compass-import-export/test/json/promotable.imported.ejson new file mode 100644 index 00000000000..829c7e64ede --- /dev/null +++ b/packages/compass-import-export/test/json/promotable.imported.ejson @@ -0,0 +1,7 @@ +[ + { + "doubleNum": { + "$numberDouble": "-45.0" + } + } +] diff --git a/packages/compass-import-export/test/json/promotable.json b/packages/compass-import-export/test/json/promotable.json new file mode 100644 index 00000000000..ec9d820f4bf --- /dev/null +++ b/packages/compass-import-export/test/json/promotable.json @@ -0,0 +1,7 @@ +[ + { + "doubleNum": { + "$numberDouble": "-45" + } + } +]