thevahidal / soul

🕉 A SQLite REST and realtime server
https://thevahidal.github.io/soul/
MIT License
1.51k stars 51 forks source link

Unexpected Empty Commas in Resulting String for Null Values #126

Closed TahaKhanAbdalli closed 1 year ago

TahaKhanAbdalli commented 1 year ago

Describe the bug I encountered an issue related to handling null values in the Object.values() method. The package appears to insert empty commas in the resulting string when a value in the input object is null.

To Reproduce Steps to reproduce the behavior:

  1. Go to swagger documentation
  2. Hit the /api/tables/{name}/rows POST api while sending in an object with one or more values as null

Expected behavior The valuesString should be a comma-separated string that contains the non-null values from the fields object. No empty commas should be present in the resulting valuesString.

Current behavior The valuesString contains empty commas when a value in the fields object is null. For example, if the fields object has a null value, the resulting valuesString would be: "value1, , value3". This behavior can lead to syntax errors or unexpected behavior.

Screenshots image

This is where the mapping is taking place: image

Desktop (please complete the following information):

Additional context The issue seems to be related to the handling of null values during the map() operation. When encountering a null value, the package should handle it appropriately by skipping the value or providing a valid representation instead of inserting an empty comma.

IanMayo commented 1 year ago

Hello @thevahidal - I'm pretty sure we have the skills to create a PR for the above issue.

Do you have a preference for whether:

  1. fields with undefined values should be omitted from the INSERT SQL
  2. or be included in INSERT SQL, and be provided with a null value.