FIX: Allow the Data Explorer API to set LIMIT to "ALL"

Fixes a bug that prevented returning unlimited rows.

Example request:
{{base_url}}/admin/plugins/explorer/queries/6/run?api_key={{api_key}}&api_username={{api_username}}&limit=ALL

From the PostgreSQL docs: "LIMIT ALL" is treated as no limit
https://www.postgresql.org/docs/current/static/sql-select.html#SQL-LIMIT
This commit is contained in:
Rishabh 2019-01-23 16:09:20 +05:30
parent a96bfdf6d5
commit a285a38e9c
2 changed files with 8 additions and 4 deletions

View File

@ -34,7 +34,7 @@ const QueryResultComponent = Ember.Component.extend({
@computed("content.result_count")
resultCount: function(count) {
if (count === this.get("content.result_limit")) {
if (count === this.get("content.default_limit")) {
return I18n.t("explorer.max_result_count", { count });
} else {
return I18n.t("explorer.result_count", { count });

View File

@ -1070,8 +1070,12 @@ SQL
opts = { current_user: current_user.username }
opts[:explain] = true if params[:explain] == "true"
opts[:limit] = "ALL" if params[:format] == "csv"
opts[:limit] = params[:limit].to_i if params[:limit]
opts[:limit] =
if params[:limit] == "ALL" || params[:format] == "csv"
"ALL"
elsif params[:limit]
params[:limit].to_i
end
result = DataExplorer.run_query(query, query_params, opts)
@ -1108,7 +1112,7 @@ SQL
result_count: pg_result.values.length || 0,
params: query_params,
columns: cols,
result_limit: DataExplorer::QUERY_RESULT_MAX_LIMIT
default_limit: DataExplorer::QUERY_RESULT_MAX_LIMIT
}
json[:explain] = result[:explain] if opts[:explain]
ext = DataExplorer.add_extra_data(pg_result)