Closed Bug 859936 Opened 12 years ago Closed 12 years ago

API should return null or false instead of {} for content_ratings field (when no ratings)

Categories

(Marketplace Graveyard :: API, defect)

x86_64
Windows 7
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
2013-04-11

People

(Reporter: basta, Assigned: andy+bugzilla)

References

Details

(Whiteboard: [fireplace] p=1)

If an app doesn't have content ratings, the API currently returns an empty object `{}`. It should instead return null or a falsey value.
{} is falsey
Not in JavaScript.
Yeah ... >>> !!{} true We'd have to say, hey this an object, and do >>> Object.keys({}).length 0 I can see how this would complicate our existing logic, which is unfortunate. Curious: where exactly in the code are we tripping up on this?
Basically, our template says {% if this.content_ratings %} ... DEJUS this ... ... DEJUS that ... {% endif %} I realllyyy don't want to have to teach nunjucks to perform a separate truthiness test on objects.
(In reply to Matt Basta [:basta] from comment #4) > I realllyyy don't want to have to teach nunjucks to perform a separate > truthiness test on objects. Can you file a bug against nunjucks? That'd be hella sweet addition I think.
James has already said that he's not interested in changing the JS mechanics that exist in Nunjucks to match the ones in Python. That's why we have to shim in things like `.items()` and `.keys()` for objects. And unlike those bits, we couldn't just stick this in nunjucks.compat.js, we'd have to modify the compiler to generate a wrapper around conditionals.
Assignee: nobody → amckay
Whiteboard: p=1
Target Milestone: --- → 2013-04-11
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Whiteboard: p=1 → [fireplace] p=1
You need to log in before you can comment on or make changes to this bug.