summaryrefslogtreecommitdiff
path: root/public/vendor/codemirror/addon/hint/sql-hint.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/vendor/codemirror/addon/hint/sql-hint.js')
-rwxr-xr-xpublic/vendor/codemirror/addon/hint/sql-hint.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/public/vendor/codemirror/addon/hint/sql-hint.js b/public/vendor/codemirror/addon/hint/sql-hint.js
index cba27a0b..22124b58 100755
--- a/public/vendor/codemirror/addon/hint/sql-hint.js
+++ b/public/vendor/codemirror/addon/hint/sql-hint.js
@@ -112,9 +112,14 @@
string = nameParts.pop();
var table = nameParts.join(".");
+ var alias = false;
+ var aliasTable = table;
// Check if table is available. If not, find table by Alias
- if (!getItem(tables, table))
+ if (!getItem(tables, table)) {
+ var oldTable = table;
table = findTableByAlias(table, editor);
+ if (table !== oldTable) alias = true;
+ }
var columns = getItem(tables, table);
if (columns && columns.columns)
@@ -122,11 +127,13 @@
if (columns) {
addMatches(result, string, columns, function(w) {
+ var tableInsert = table;
+ if (alias == true) tableInsert = aliasTable;
if (typeof w == "string") {
- w = table + "." + w;
+ w = tableInsert + "." + w;
} else {
w = shallowClone(w);
- w.text = table + "." + w.text;
+ w.text = tableInsert + "." + w.text;
}
return useBacktick ? insertBackticks(w) : w;
});
@@ -205,6 +212,7 @@
CodeMirror.registerHelper("hint", "sql", function(editor, options) {
tables = (options && options.tables) || {};
var defaultTableName = options && options.defaultTable;
+ var disableKeywords = options && options.disableKeywords;
defaultTable = defaultTableName && getItem(tables, defaultTableName);
keywords = keywords || getKeywords(editor);
@@ -237,7 +245,8 @@
} else {
addMatches(result, search, tables, function(w) {return w;});
addMatches(result, search, defaultTable, function(w) {return w;});
- addMatches(result, search, keywords, function(w) {return w.toUpperCase();});
+ if (!disableKeywords)
+ addMatches(result, search, keywords, function(w) {return w.toUpperCase();});
}
return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)};