Fix: auto-trigger hints while typing
This commit is contained in:
@@ -388,20 +388,19 @@ async function initSqlEditor() {
|
|||||||
indentWithTabs: true,␍
|
indentWithTabs: true,␍
|
||||||
smartIndent: true,␍
|
smartIndent: true,␍
|
||||||
lineWrapping: true,␍
|
lineWrapping: true,␍
|
||||||
extraKeys: {␍
|
extraKeys: {'Ctrl-Space': 'autocomplete'}␍
|
||||||
'Ctrl-Space': 'autocomplete'␍
|
|
||||||
},␍
|
|
||||||
hintOptions: {␍
|
|
||||||
tables: {},␍
|
|
||||||
words: ['SELECT','FROM','WHERE','AND','OR','JOIN','LEFT','RIGHT','INNER','OUTER','ON','AS','IN','NOT','NULL','IS','LIKE','BETWEEN','INTO','VALUES','SET','UPDATE','DELETE','INSERT','CREATE','ALTER','DROP','TABLE','INDEX','VIEW','ORDER','BY','GROUP','HAVING','DISTINCT','COUNT','SUM','AVG','MIN','MAX','BETWEEN','EXISTS','UNION','ALL','ANY','CASE','WHEN','THEN','ELSE','END','CAST','COALESCE','NULLIF','DESC','ASC']␍
|
|
||||||
}␍
|
|
||||||
});␍
|
});␍
|
||||||
␍
|
␍
|
||||||
sqlEditor.on('change', function() {␍
|
sqlEditor.on('change', function() {␍
|
||||||
document.getElementById('q_text').value = sqlEditor.getValue();␍
|
document.getElementById('q_text').value = sqlEditor.getValue();␍
|
||||||
});␍
|
});␍
|
||||||
␍
|
␍
|
||||||
// Cargar esquema para autocomplete␍
|
sqlEditor.on('inputRead', function(cm, change) {␍
|
||||||
|
if (change.text.length && /\w/.test(change.text[0])) {␍
|
||||||
|
cm.showHint({hint: CodeMirror.hint.sql, completeSingle: false});␍
|
||||||
|
}␍
|
||||||
|
});␍
|
||||||
|
␍
|
||||||
try {␍
|
try {␍
|
||||||
const resp = await fetch('/queries/esquema', { method: 'POST' });␍
|
const resp = await fetch('/queries/esquema', { method: 'POST' });␍
|
||||||
const data = await resp.json();␍
|
const data = await resp.json();␍
|
||||||
@@ -410,7 +409,9 @@ async function initSqlEditor() {
|
|||||||
data.tablas.forEach(t => {␍
|
data.tablas.forEach(t => {␍
|
||||||
tables[t.tabla] = t.columnas.map(c => c.nombre);␍
|
tables[t.tabla] = t.columnas.map(c => c.nombre);␍
|
||||||
});␍
|
});␍
|
||||||
sqlEditor.setOption('hintOptions', { tables });␍
|
sqlEditor.setOption('hintOptions', { tables,␍
|
||||||
|
words: ['SELECT','FROM','WHERE','AND','OR','JOIN','LEFT','RIGHT','INNER','OUTER','ON','AS','IN','NOT','NULL','IS','LIKE','BETWEEN','ORDER','BY','GROUP','HAVING','DISTINCT','COUNT','SUM','AVG','MIN','MAX','UNION','ALL','CASE','WHEN','THEN','ELSE','END','CAST','COALESCE','NULLIF','DESC','ASC']␍
|
||||||
|
});␍
|
||||||
}␍
|
}␍
|
||||||
} catch(e) {}␍
|
} catch(e) {}␍
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user