parent
fa4703ccee
commit
fcf982e045
@ -34,6 +34,15 @@ Supported query string parameters:
|
||||
timestamp value in cache_buster for manual control of
|
||||
updates.
|
||||
|
||||
'rows_per_page':
|
||||
Limit the number of rows in output. Affects all formats,
|
||||
see also 'page'.
|
||||
|
||||
'page':
|
||||
When 'rows_per_page' is used to limit rows, 'page' can be
|
||||
used to specify which page to start returning rows from.
|
||||
First page has index 0.
|
||||
|
||||
Response formats
|
||||
----------------
|
||||
|
||||
|
@ -216,6 +216,28 @@ function(done){
|
||||
});
|
||||
});
|
||||
|
||||
// Test page and rows_per_page params
|
||||
test("paging", function(done){
|
||||
assert.response(app, {
|
||||
url: '/api/v1/sql?' + querystring.stringify({
|
||||
// note: select casing intentionally mixed
|
||||
q: 'SELECT * FROM (VALUES(1),(2),(3),(4),(5),(6),(7),(8),(9)) t(v)',
|
||||
rows_per_page: 3,
|
||||
page: 2
|
||||
}),
|
||||
headers: {host: 'vizzuality.cartodb.com'},
|
||||
method: 'GET'
|
||||
},{ }, function(res) {
|
||||
assert.equal(res.statusCode, 200, res.body);
|
||||
var parsed = JSON.parse(res.body);
|
||||
assert.equal(parsed.rows.length, 3);
|
||||
assert.equal(parsed.rows[0].v, 7);
|
||||
assert.equal(parsed.rows[1].v, 8);
|
||||
assert.equal(parsed.rows[2].v, 9);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('POST /api/v1/sql with SQL parameter on SELECT only. no database param, just id using headers', function(done){
|
||||
assert.response(app, {
|
||||
url: '/api/v1/sql',
|
||||
|
Loading…
Reference in New Issue
Block a user