superset-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maximebeauche...@apache.org
Subject [incubator-superset] branch master updated: [SQLLab] Fix, database api unlimited page size v2 (#8002)
Date Thu, 08 Aug 2019 18:37:15 GMT
This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 73cdad2  [SQLLab] Fix, database api unlimited page size v2 (#8002)
73cdad2 is described below

commit 73cdad2375d0e87809e4a12c180b89747a83cc4f
Author: Daniel Vaz Gaspar <danielvazgaspar@gmail.com>
AuthorDate: Thu Aug 8 19:37:00 2019 +0100

    [SQLLab] Fix, database api unlimited page size v2 (#8002)
    
    * [database] Fix, Removes the limit for the page size, Bump FAB to 2.1.8
    
    Old FAB API had no limits by default, this will keep this behaviour
    but only for this endpoint
    
    * [sqllab] Add test for database API
    
    * [sqllab] Add test for database API
    
    * [sqllab] Include page zero on request
    
    * [sqllab] Fix, Black and requirements
    
    * [sqllab] Make database API return unlimited results
    
    * [sqllab] just a test
    
    * [sqllab] Bump FAB to 2.1.9
    
    * [sqllab] Remove unused import
---
 requirements.txt                                 | 11 +++--------
 setup.py                                         |  2 +-
 superset/assets/src/components/TableSelector.jsx |  2 +-
 superset/views/database/api.py                   |  2 ++
 tests/sqllab_tests.py                            | 18 ++++++++++++++++++
 5 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/requirements.txt b/requirements.txt
index d1454eb..74c327e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -13,9 +13,7 @@ babel==2.7.0              # via flask-babel
 billiard==3.6.0.0         # via celery
 bleach==3.1.0
 celery==4.3.0
-certifi==2019.6.16        # via requests
 cffi==1.12.3              # via cryptography
-chardet==3.0.4            # via requests
 click==6.7
 colorama==0.4.1
 contextlib2==0.5.5
@@ -23,7 +21,7 @@ croniter==0.3.30
 cryptography==2.7
 decorator==4.4.0          # via retry
 defusedxml==0.6.0         # via python3-openid
-flask-appbuilder==2.1.7
+flask-appbuilder==2.1.9
 flask-babel==0.12.2       # via flask-appbuilder
 flask-caching==1.7.2
 flask-compress==1.4.0
@@ -72,16 +70,13 @@ pyyaml==5.1.2
 retry==0.9.2
 selenium==3.141.0
 simplejson==3.16.0
-six==1.12.0               # via bleach, cryptography, flask-jwt-extended, flask-talisman,
isodate, jsonschema, pathlib2, polyline, prison, pydruid, pyrsistent, python-dateutil, sqlalchemy-utils,
wtforms-json
+six==1.12.0               # via bleach, cryptography, flask-jwt-extended, flask-talisman,
isodate, jsonschema, pathlib2, polyline, prison, pyrsistent, python-dateutil, sqlalchemy-utils,
wtforms-json
 sqlalchemy-utils==0.34.1
 sqlalchemy==1.3.6
 sqlparse==0.3.0
-urllib3==1.25.3           # via requests, selenium
+urllib3==1.25.3           # via selenium
 vine==1.3.0               # via amqp, celery
 webencodings==0.5.1       # via bleach
 werkzeug==0.15.5          # via flask, flask-jwt-extended
 wtforms-json==0.3.3
 wtforms==2.2.1            # via flask-wtf, wtforms-json
-
-# The following packages are considered to be unsafe in a requirements file:
-# setuptools==41.0.1        # via jsonschema, markdown
diff --git a/setup.py b/setup.py
index a0c02ff..c3a40ad 100644
--- a/setup.py
+++ b/setup.py
@@ -73,7 +73,7 @@ setup(
         "croniter>=0.3.28",
         "cryptography>=2.4.2",
         "flask>=1.0.0, <2.0.0",
-        "flask-appbuilder>=2.1.6, <2.3.0",
+        "flask-appbuilder>=2.1.9, <2.3.0",
         "flask-caching",
         "flask-compress",
         "flask-talisman",
diff --git a/superset/assets/src/components/TableSelector.jsx b/superset/assets/src/components/TableSelector.jsx
index d380241..bd66eb8 100644
--- a/superset/assets/src/components/TableSelector.jsx
+++ b/superset/assets/src/components/TableSelector.jsx
@@ -218,7 +218,7 @@ export default class TableSelector extends React.PureComponent {
           '/api/v1/database/?q=' +
           '(keys:!(none),' +
           'filters:!((col:expose_in_sqllab,opr:eq,value:!t)),' +
-          'order_columns:database_name,order_direction:asc)'
+          'order_columns:database_name,order_direction:asc,page:0,page_size:-1)'
         }
         onChange={this.onDatabaseChange}
         onAsyncError={() => this.props.handleError(t('Error while fetching database list'))}
diff --git a/superset/views/database/api.py b/superset/views/database/api.py
index dea17ba..2bb8ea5 100644
--- a/superset/views/database/api.py
+++ b/superset/views/database/api.py
@@ -50,6 +50,8 @@ class DatabaseRestApi(DatabaseMixin, ModelRestApi):
         "allows_subquery",
         "backend",
     ]
+    # Removes the local limit for the page size
+    max_page_size = -1
 
 
 appbuilder.add_api(DatabaseRestApi)
diff --git a/tests/sqllab_tests.py b/tests/sqllab_tests.py
index b16b796..1774c26 100644
--- a/tests/sqllab_tests.py
+++ b/tests/sqllab_tests.py
@@ -20,6 +20,7 @@ import json
 import unittest
 
 from flask_appbuilder.security.sqla import models as ab_models
+import prison
 
 from superset import db, security_manager
 from superset.dataframe import SupersetDataFrame
@@ -403,6 +404,23 @@ class SqlLabTests(SupersetTestCase):
 
         session.commit()
 
+    def test_api_database(self):
+        self.login("admin")
+
+        arguments = {
+            "keys": [],
+            "filters": [{"col": "expose_in_sqllab", "opr": "eq", "value": True}],
+            "order_column": "database_name",
+            "order_direction": "asc",
+            "page": 0,
+            "page_size": -1,
+        }
+        expected_results = ["examples", "fake_db_100", "main"]
+        url = "api/v1/database/?{}={}".format("q", prison.dumps(arguments))
+        data = self.get_json_resp(url)
+        for i, expected_result in enumerate(expected_results):
+            self.assertEquals(expected_result, data["result"][i]["database_name"])
+
 
 if __name__ == "__main__":
     unittest.main()


Mime
View raw message