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

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

diff --git a/assets/javascripts/discourse/components/query-result.js.es6 b/assets/javascripts/discourse/components/query-result.js.es6
index d3a11fa..a0cbba6 100644
--- a/assets/javascripts/discourse/components/query-result.js.es6
+++ b/assets/javascripts/discourse/components/query-result.js.es6
@@ -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 });
diff --git a/plugin.rb b/plugin.rb
index e5162b7..e67cb0e 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -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)

GitHub sha: a285a38e