Skip to content

Commit

Permalink
version 0.2.1 - bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielfalcao committed Mar 21, 2010
1 parent cc00241 commit e479580
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes since latest release:

## version 0.2.1

* Some bug fixes

## version 0.2

* Now it works with any tables, unless its JSONP support is screwed.
Expand Down
7 changes: 3 additions & 4 deletions jquery.yql.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* http://www.gnu.org/copyleft/gpl.html
*
* Version: 0.2
* Version: 0.2.1
*/

(function($){
Expand All @@ -17,8 +17,8 @@
$.each(
params, function (key) {
var name = "#{" + key + "}";
var value = this;
if (isNaN(parseInt(value))) {
var value = $.trim(this);
if (!value.match(/^[0-9]+$/)) {
value = '"' + value + '"';
}
query = query.replace(name, value);
Expand All @@ -28,7 +28,6 @@
},
yql: function (query) {
var $self = this;
var params = {};
var successCallback = null;

if (typeof arguments[1] == 'object') {
Expand Down
40 changes: 40 additions & 0 deletions tests/test.yql.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,43 @@ asyncTest('Querying a community table (github)', function () {
});
});


test('It should cast into integer only when is suitable', function() {
expect(1);

$.ajax = function (params){
equals(params.data.q, 'SELECT * FROM flickr.photos.search WHERE lat = "-12.55" AND lon = "100.23"');
}

$.yql(
"SELECT * FROM flickr.photos.search WHERE lat = #{latitude} AND lon = #{longitude}",
{
latitude: "-12.55",
longitude: "100.23",
}
);

$.ajax = oldAjax;
});

asyncTest('It can fetch lastfm data', function() {
expect(1);

$.yql(
"SELECT * FROM lastfm.geo.getevents WHERE api_key=#{key} AND lat=#{latitude} AND long=#{longitude}",
{
key: "5a2242815c81e144c48b34716014ec7e",
latitude: "-23.550511",
longitude: "-46.633428"
},
function (data){
try {
equal(data.query.results.lfm.status, "ok");
}catch (e) {
ok(false, "should not reach here");
}
start();
}
);

});

0 comments on commit e479580

Please sign in to comment.