aws-samples / amazon-documentdb-samples

MIT No Attribution
48 stars 32 forks source link

samples/docdb-dotnet-starter/data/restaurant.json -> wrong type with some documents and field name: address line 2 #36

Closed norberto-enomoto closed 1 year ago

norberto-enomoto commented 1 year ago

Inside samples/docdb-dotnet-starter/data/restaurant.json there are some documents with wrong type:

Example: "address": 130 -> breaking the code: File Locations.cs -> public string address { get; set; }. In the local machine is working fine. But when I deployed at AWS AppRunner using AWS DocumentDB, I'm getting the following error due this document type:

" ---> System.FormatException: Cannot deserialize a 'String' from BsonType 'Int32'. 02-21-2023 05:47:35 PM System.FormatException: An error occurred while deserializing the address property of class docdb_dotnet_starter.Models.Location: Cannot deserialize a 'String' from BsonType 'Int32'."

Record at /samples/docdb-dotnet-starter/data/restaurant.json file:

Example: {"URL":"http://www.just-eat.co.uk/restaurants-alcaponepizza/menu","_id":{"$oid":"55f14312c7447c3da7051ce9"},"address":130,"address line 2":"Birmingham","name":"Al Capone Pizza","outcode":"B13","postcode":"8EE","rating":4.5,"type_of_food":"Pizza"}

Also there is a column in the collection locations "address line 2" that it's breaking the code: { _id: ObjectId("55f14312c7447c3da7051b3f"), URL: 'http://www.just-eat.co.uk/restaurants-1st-class-pizza-and-kebab-house-nottingham/menu', address: '470 Vernon Road', 'address line 2': 'Old Basford', name: '1st Class Pizza & Kebab House', outcode: 'NG6', postcode: '0AT', rating: 4, type_of_food: 'Pizza' }

Corrections:

  1. Change some documents at restaurant.json file: exemple "address": 130 to "address": "130"
  2. Change column name address line 2 to address_line_2 at file restaurant.json
  3. Added the attribute public string address_line_2 { get; set; } at file Locations.cs

My github repository with changed files: https://github.com/norberto-enomoto/docdb-dotnet-starter

tmcallaghan commented 1 year ago

Norberto, please submit a PR for this change.

norberto-enomoto commented 1 year ago

Hi Tim. I have created the PR. Please let me know if you have any questions.

tmcallaghan commented 1 year ago

Approved and merged, thanks for fixing this. #37