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)
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.
Assignee | ||
Comment 1•12 years ago
|
||
{} is falsey
Reporter | ||
Comment 2•12 years ago
|
||
Not in JavaScript.
Comment 3•12 years ago
|
||
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?
Reporter | ||
Comment 4•12 years ago
|
||
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.
Comment 5•12 years ago
|
||
(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.
Reporter | ||
Comment 6•12 years ago
|
||
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 | ||
Updated•12 years ago
|
Assignee: nobody → amckay
Whiteboard: p=1
Target Milestone: --- → 2013-04-11
Assignee | ||
Comment 7•12 years ago
|
||
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Updated•12 years ago
|
Whiteboard: p=1 → [fireplace] p=1
You need to log in
before you can comment on or make changes to this bug.
Description
•