-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sql-Hint dont show autocomplete when having tab caracters and new line between alias and table #4712
Comments
Does attached patch help? |
You also needs to replace the previousWord logics. Because It was being updated with space, \n caracters and tabs. Here: if (wordUpperCase !== CONS.ALIAS_KEYWORD previous word should ignore anything like spaces, tabs and newlines. I also intend to modify the autocomplete which show columns from tables. When you press some key, it does not filter. When done, I will post changes. |
Are you sure? They way I wrote |
I will do more tests until tomorrow, sorry for the delay. |
There are special testcases to be tested for example: "SELECT p. FROM Plant "SELECT p. FROM Plant p,offerte o" After the point use ctrl-space. In my test findings below code works best: function eachWord(lineText, f) {
if (!lineText) return;
var excepted = /[,;]/g;
lineText=lineText.replace(excepted, ' ');
var words = lineText.split(/\s+/);
for (var i = 0; i < words.length; i++) {
if (words[i]) f(words[i]);
}
}
` |
Code above Works better. I found a situation where we may improve: select a.col_A, b.
from table1 a
inner join
(select table2.other_columns1 as outterColumn from table2) as b In the situation above, pressing dot after b does not bring autocomplete. it should show b.outterColumn |
When I use the following sentecen in sql mode:
select a. (here should show autocomplete)
from
table
a
Assuming between from and table there is a tab caracter (\t) or anything from unusual, it breaks the autocomplete, the autocomplete fails to bring the table columns.
I solved this by two changes:
The first is: I just update the previous word with a valid word
if (wordUpperCase !== CONS.ALIAS_KEYWORD
&& word !== ''
&& word !== ' '
&& word !== '\n'
&& word !== '\r\n')
The second is: replacing all tab caracters with space:
eachWord(lineText.replace(/[\t]+/, ' '), function(word) {
All this changes are located at: sql-hint.js, function findTableByAlias(alias, editor), line: 196
What do you guys think
The text was updated successfully, but these errors were encountered: