Skip to content

Commit

Permalink
[sqllab] reserved words should be upper case (#2316)
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch authored Mar 3, 2017
1 parent b62f7e2 commit 492df94
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions superset/assets/javascripts/SqlLab/components/AceEditorWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ import { areArraysShallowEqual } from '../../reduxUtils';

const langTools = ace.acequire('ace/ext/language_tools');

const keywords = (
'SELECT|INSERT|UPDATE|DELETE|FROM|WHERE|AND|OR|GROUP|BY|ORDER|LIMIT|OFFSET|HAVING|AS|CASE|' +
'WHEN|ELSE|END|TYPE|LEFT|RIGHT|JOIN|ON|OUTER|DESC|ASC|UNION|CREATE|TABLE|PRIMARY|KEY|IF|' +
'FOREIGN|NOT|REFERENCES|DEFAULT|NULL|INNER|CROSS|NATURAL|DATABASE|DROP|GRANT'
);

const dataTypes = (
'INT|NUMERIC|DECIMAL|DATE|VARCHAR|CHAR|BIGINT|FLOAT|DOUBLE|BIT|BINARY|TEXT|SET|TIMESTAMP|' +
'MONEY|REAL|NUMBER|INTEGER'
);

const sqlKeywords = [].concat(keywords.split('|'), dataTypes.split('|'));
const sqlWords = sqlKeywords.map(s => ({
name: s, value: s, score: 60, meta: 'sql',
}));

const propTypes = {
actions: React.PropTypes.object.isRequired,
onBlur: React.PropTypes.func,
Expand Down Expand Up @@ -80,14 +96,14 @@ class AceEditorWrapper extends React.PureComponent {
});
words = words.concat(Object.keys(columns).map(col => (
{ name: col, value: col, score: 50, meta: 'column' }
)));
)), sqlWords);

this.setState({ words }, () => {
const completer = {
getCompletions: this.getCompletions.bind(this),
};
if (langTools) {
langTools.setCompleters([completer, langTools.keyWordCompleter]);
langTools.setCompleters([completer]);
}
});
}
Expand Down

0 comments on commit 492df94

Please sign in to comment.