Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fixed logic on addDataType function to set non-string values #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rrcalvo
Copy link

@rrcalvo rrcalvo commented Jan 11, 2021

I have a query that results nested objects, e.g.
SELECT id, item.id, item.label, item.price, order.quantity, order.subtotal FROM orders

The current behaviour resulting data from the Items collection is:
[{ id: "O-100", item: { id: "item-12345", label: "Printer", price: "123.99" }, order: { quantity: "1", subtotal: "123.99" qualifies_for_discount: "true" }, }]

I need the resulting nested objects non-string properties in the Items collection to be set as non-string, i.e. not in quotes.
Expected result:
[{ id: "O-100", item: { id: "item-12345", label: "Printer", price: 123.99 }, order: { quantity: 1, subtotal: 123.99 qualifies_for_discount: true }, }]
To accomplish this, it seems the record data has to be converted into a flat object map so the loop in the addDataType function can iterate through all properties including those in the nested objects.

@coveralls
Copy link

coveralls commented Jan 11, 2021

Pull Request Test Coverage Report for Build 139

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 100.0%

Totals Coverage Status
Change from base Build 136: 0.0%
Covered Lines: 3
Relevant Lines: 3

💛 - Coveralls

@rrcalvo
Copy link
Author

rrcalvo commented Jan 11, 2021

Also, not sure if this is the best way to do object flatten and unflatten. I just followed the example on the top answer on:
https://stackoverflow.com/questions/19098797/fastest-way-to-flatten-un-flatten-nested-json-objects
Let me know if there's a better way to do this.
Thanks.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants