Skip to content

Commit

Permalink
Merge branch 'master' into ddol/sankey_tooltip_bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ddol committed Dec 2, 2016
2 parents 96b58b4 + 95580a0 commit 442431d
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ While these may be phased out over time, these packages are currently not
managed with npm.

### Node/npm versions
Make sure you are using recent versions of node and npm. No problems have been found with node>=5.10 and npm>=3.9.
Make sure you are using recent versions of node and npm. No problems have been found with node>=5.10 and 4.0. > npm>=3.9.

### Using npm to generate bundled files

Expand Down
1 change: 0 additions & 1 deletion docs/img

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class TextField extends React.Component {
}
render() {
return (
<FormGroup controlId="formInlineName">
<FormGroup controlId="formInlineName" bsSize="small">
<ControlLabelWithTooltip
label={this.props.label}
description={this.props.description}
Expand Down
2 changes: 1 addition & 1 deletion superset/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"test": "mocha --require ignore-styles --compilers js:babel-core/register --require spec/helpers/browser.js --recursive spec/**/*_spec.*",
"cover": "babel-node ./node_modules/.bin/istanbul cover _mocha -- --require spec/helpers/browser.js --recursive spec/**/*_spec.*",
"dev": "NODE_ENV=dev webpack --watch --colors --progress --debug --output-pathinfo --source-map",
"dev": "NODE_ENV=dev webpack --watch --colors --progress --debug --output-pathinfo --devtool source-map",
"prod": "NODE_ENV=production node --max_old_space_size=4096 ./node_modules/webpack/bin/webpack.js -p --colors --progress",
"build": "NODE_ENV=production webpack --colors --progress",
"lint": "eslint --ignore-path=.eslintignore --ext .js,.jsx ."
Expand Down
24 changes: 23 additions & 1 deletion superset/sql_lab.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,35 @@
from sqlalchemy.orm import sessionmaker

from superset import (
app, db, models, utils, dataframe, results_backend, sql_parse, sm)
app, db, models, utils, dataframe, results_backend, sql_parse)
from superset.db_engine_specs import LimitMethod
from superset.jinja_context import get_template_processor
QueryStatus = models.QueryStatus

celery_app = celery.Celery(config_source=app.config.get('CELERY_CONFIG'))


def dedup(l, suffix='__'):
"""De-duplicates a list of string by suffixing a counter
Always returns the same number of entries as provided, and always returns
unique values.
>>> dedup(['foo', 'bar', 'bar', 'bar'])
['foo', 'bar', 'bar__1', 'bar__2']
"""
new_l = []
seen = {}
for s in l:
if s in seen:
seen[s] += 1
s += suffix + str(seen[s])
else:
seen[s] = 0
new_l.append(s)
return new_l


def create_table_as(sql, table_name, schema=None, override=False):
"""Reformats the query into the create table as query.
Expand Down Expand Up @@ -117,6 +138,7 @@ def handle_error(msg):
cdf = None
if result_proxy.cursor:
column_names = [col[0] for col in result_proxy.cursor.description]
column_names = dedup(column_names)
if db_engine_spec.limit_method == LimitMethod.FETCH_MANY:
data = result_proxy.fetchmany(query.limit)
else:
Expand Down
1 change: 0 additions & 1 deletion superset/static/coverage

This file was deleted.

1 change: 0 additions & 1 deletion superset/static/docs

This file was deleted.

4 changes: 3 additions & 1 deletion tests/base_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def revoke_public_access_to_table(self, table):
perm.view_menu and table.perm in perm.view_menu.name):
appbuilder.sm.del_permission_role(public_role, perm)

def run_sql(self, sql, client_id, user_name=None):
def run_sql(self, sql, client_id, user_name=None, raise_on_error=False):
if user_name:
self.logout()
self.login(username=(user_name if user_name else 'admin'))
Expand All @@ -208,6 +208,8 @@ def run_sql(self, sql, client_id, user_name=None):
data=dict(database_id=dbid, sql=sql, select_as_create_as=False,
client_id=client_id),
)
if raise_on_error and 'error' in resp:
raise Exception("run_sql failed")
return resp

def test_gamma_permissions(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/core_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from flask import escape

from superset import db, models, utils, appbuilder, sm, jinja_context
from superset import db, models, utils, appbuilder, sm, jinja_context, sql_lab
from superset.views import DatabaseView

from .base_tests import SupersetTestCase
Expand Down Expand Up @@ -165,7 +165,7 @@ def test_dashboard(self):
assert escape(title) in self.client.get(url).data.decode('utf-8')

def test_doctests(self):
modules = [utils, models]
modules = [utils, models, sql_lab]
for mod in modules:
failed, tests = doctest.testmod(mod)
if failed:
Expand Down
7 changes: 7 additions & 0 deletions tests/sqllab_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ def test_search_query_on_time(self):
self.assertLess(int(first_query_time), v['startDttm'])
self.assertLess(v['startDttm'], int(second_query_time))

def test_alias_duplicate(self):
self.run_sql(
"SELECT username as col, id as col, username FROM ab_user",
client_id='2e2df3',
user_name='admin',
raise_on_error=True)


if __name__ == '__main__':
unittest.main()

0 comments on commit 442431d

Please sign in to comment.