nhorvath / Pyrebase4

A simple python wrapper for the Firebase API. ⛺
254 stars 63 forks source link

Fixed a KeyError raised when the sort key is missing #21

Closed Reidsy closed 3 years ago

Reidsy commented 3 years ago

Existing Behavior: When fetching data and using a sort key that only exists on some items fetched, a KeyError will be raised.

New Behavior: Missing keys are sorted first to maintain consistency with the official firebase libraries.

A tuple is returned to the sorted function. The first key will be a boolean and the second key will be the value of the sort key or an empty string.

If the sort key is missing, the first key in the tuple will be False and ordered first which is the behavior documented in the official firebase documentation. The second key in the tuple will be an empty string giving all items without a sort key equal weighting.

If the sort key is available, the first key in the tuple will be true and the second value will be the value of the sort key to sort on.

nhorvath commented 3 years ago

Thanks. I'll cut a new version tomorrow. If I forget feel free to send me a reminder.