Skip to content
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

Fix for auto-complete on empty words so behavior is consistent with previous DuckDB #10502

Merged
merged 1 commit into from Feb 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions extension/autocomplete/autocomplete_extension.cpp
Expand Up @@ -90,7 +90,10 @@ static vector<AutoCompleteCandidate> SuggestKeyword(ClientContext &context) {
vector<AutoCompleteCandidate> result;
for (auto &kw : keywords) {
auto score = 0;
if (kw == "FROM" || kw == "SELECT" || kw == "DELETE" || kw == "INSERT" || kw == "UPDATE") {
if (kw == "SELECT") {
score = 2;
}
if (kw == "FROM" || kw == "DELETE" || kw == "INSERT" || kw == "UPDATE") {
score = 1;
}
result.emplace_back(kw + " ", score);
Expand Down Expand Up @@ -361,8 +364,8 @@ process_word : {
D_ASSERT(false);
throw NotImplementedException("last_pos out of range");
}
if (std::all_of(last_word.begin(), last_word.end(), ::isdigit)) {
// Numbers are OK
if (!last_word.empty() && std::all_of(last_word.begin(), last_word.end(), ::isdigit)) {
// avoid giving auto-complete suggestion for digits
suggestions.clear();
}
return make_uniq<SQLAutoCompleteFunctionData>(std::move(suggestions), last_pos);
Expand Down