0

Issue with y.query hashmap

Is there a reason why in the sample below the @name fields aren't replaced?

CODE
y.query("select * from geo.places where text=\"@city,@countrycode\"", {city:place,countrycode:code});

by
1 Reply
  • QUOTE (Ivo @ Jun 11 2009, 07:00 AM) <{POST_SNAPBACK}>
    Is there a reason why in the sample below the @name fields aren't replaced?

    CODE
    y.query("select * from geo.places where text=\"@city,@countrycode\"", {city:place,countrycode:code});


    Since you have it inside the quotes as a literal, the compiler treats it just as a string literal and text passed to the webservice would be "@city, @countrycode"
    Variables be specified as ids instead of literals, so in your case you'd have

    CODE
    y.query("select * from geo.places where text=@city_and_countrycode", {city_and_countrycode:place +',' + code});


    Also since the right hand side can take only one varialbe such as @foo, I've modified your statement to concatenate the city and country code and pass in a single variable to the query

    -- Nagesh
    0

Recent Posts

in YQL