ql-io / ql.io

A node.js based declarative, data-retrieval and aggregation gateway for quickly consuming HTTP APIs
http://ql.io
Other
931 stars 112 forks source link

Variable references of falsey values disappear from response #590

Closed wrighty closed 6 years ago

wrighty commented 11 years ago

Variable references that have falsey values appear to disappear from returned responses

Route:

foo = {
    'false' : false,
    'zero' : 0,
    'null' : null
};

return {
    'false' : '{foo.false}',
    'zero' : '{foo.zero}',
    'null' : '{foo.null}',
    'original' : '{foo}'
} via route '/typetest' using method get;

Actual response from curling http://localhost:3000/typetest:

{"original":{"false":false,"zero":0,"null":null}}

Expected response:

{"false":false,"zero":0,"null":null,"original":{"false":false,"zero":0,"null":null}}

Is there a more appropriate way of accessing a single value from a variable reference?

wrighty commented 11 years ago

I extended the test case to include non-falsey values and it appears that they are type juggled to strings:

foo = {
    'true' : true,
    'one' : 1,
    'false' : false,
    'zero' : 0,
    'null' : null
};

return {
    'true' : '{foo.true}',
    'one' : '{foo.one}',
    'false' : '{foo.false}',
    'zero' : '{foo.zero}',
    'null' : '{foo.null}',
    'original' : '{foo}'
} via route '/typetest' using method get;

Actual response:

{"true":"true","one":"1","original":{"true":true,"one":1,"false":false,"zero":0,"null":null}}

Expected response:

{"true":true,"one":1,"false":false,"zero":0,"null":null,"original":{"true":true,"one":1,"false":false,"zero":0,"null":null}}