[COMPASS-5076] Importing a document with mixed numeric and string keys causes the object to be converted to array when numeric keys are first in the list of keys Created: 08/Sep/21 Updated: 29/Oct/23 Resolved: 20/Jun/22 |
|
| Status: | Closed |
| Project: | Compass |
| Component/s: | Import/Export |
| Affects Version/s: | None |
| Fix Version/s: | 1.32.3 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Sergey Petushkov | Assignee: | Le Roux Bodenstein |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Story Points: | 3 | ||||||||
| Documentation Changes: | Not Needed | ||||||||
| Sprint: | Iteration Dolphin | ||||||||
| Description |
Problem Statement/RationaleImporting from JSON file a document that looks something like this:
will result in the property foo being converted to the array during the import Steps to ReproduceCreate a json file with documents that have mixed number-like and string keys Expected ResultsDocument is uploaded, all values are present in the imported documents, objects are still objects Actual ResultsIf a document has mixed keys, it will be converted to an array and all string keys will be lost Additional NotesHere's the root cause: https://github.com/mongodb-js/compass/blob/0c6483f7aaea2d9e00a6d09520428111fc808b09/packages/compass-import-export/src/utils/import-apply-types-and-projection.js#L66 If this set encounters a path that ends in a number-like key, it will create an array, if not, it will create an object. If an object has mixed keys, first one will always be a number-like one in this part of the code |
| Comments |
| Comment by Githook User [ 06/Jul/22 ] |
|
Author: {'name': 'Le Roux Bodenstein', 'email': 'lerouxb@gmail.com', 'username': 'lerouxb'}Message: fix(import): pre-create an empty object before creating its properties
|
| Comment by Githook User [ 06/Jul/22 ] |
|
Author: {'name': 'Le Roux Bodenstein', 'email': 'lerouxb@gmail.com', 'username': 'lerouxb'}Message: fix(import): pre-create an empty object before creating its properties
|
| Comment by Githook User [ 30/Jun/22 ] |
|
Author: {'name': 'Le Roux Bodenstein', 'email': 'lerouxb@gmail.com', 'username': 'lerouxb'}Message: fix(import): pre-create an empty object before creating its properties
|
| Comment by Githook User [ 29/Jun/22 ] |
|
Author: {'name': 'Le Roux Bodenstein', 'email': 'lerouxb@gmail.com', 'username': 'lerouxb'}Message: fix(import): pre-create an empty object before creating its properties
|
| Comment by Githook User [ 26/Jun/22 ] |
|
Author: {'name': 'Le Roux Bodenstein', 'email': 'lerouxb@gmail.com', 'username': 'lerouxb'}Message: fix(import): pre-create an empty object before creating its properties
|
| Comment by Githook User [ 22/Jun/22 ] |
|
Author: {'name': 'Le Roux Bodenstein', 'email': 'lerouxb@gmail.com', 'username': 'lerouxb'}Message: fix(import): pre-create an empty object before creating its properties
|
| Comment by Githook User [ 22/Jun/22 ] |
|
Author: {'name': 'Le Roux Bodenstein', 'email': 'lerouxb@gmail.com', 'username': 'lerouxb'}Message: fix(import): pre-create an empty object before creating its properties
|
| Comment by Githook User [ 20/Jun/22 ] |
|
Author: {'name': 'Le Roux Bodenstein', 'email': 'lerouxb@gmail.com', 'username': 'lerouxb'}Message: fix(import): pre-create an empty object before creating its properties
|
| Comment by Githook User [ 18/Jun/22 ] |
|
Author: {'name': 'Le Roux Bodenstein', 'email': 'lerouxb@gmail.com', 'username': 'lerouxb'}Message: fix(import): pre-create an empty object before creating its properties
|