datahuborg / datahub

An experimental hosted platform (GitHub-like) for organizing, managing, sharing, collaborating, and making sense of data.
https://datahub.csail.mit.edu
MIT License
210 stars 60 forks source link

LIMIT statements do not work in repo interface #23

Closed RogerTangos closed 9 years ago

RogerTangos commented 9 years ago

DataHub adds automatic limit statements to all sql statements in repository interface (http://datahub.csail.mit.edu/browse/USERNAME/REPONAME/), to support pagination. As a result, a statement like select * from getfit.deviceinfo LIMIT 1; should work, but instead returns an error:

{"error": "syntax error at or near \"LIMIT\"\nLINE 1: select * from getfit.deviceinfo LIMIT 1 LIMIT 50 OFFSET 0\n ^\n"}

RogerTangos commented 9 years ago

fixed in e63c7d3b42f56c38b377450a0526ef66d30998ee on the sp1_bug_squash branch by wrapping statements in another select statement. This way, the user's limit statement and datahub's pagination feature still work.

db_query = 'select * from (' + query + ') as BXCQWVPEMWVKFBEBNKZSRPYBSB' db_query = '%s LIMIT %s OFFSET %s' %(db_query, limit, (current_page -1) * limit)