fix: #301 pgsql truncate table suggestion (#302)

This commit is contained in:
琉易 2024-04-26 09:38:15 +08:00 committed by GitHub
parent 8baabd027b
commit 25358ec653
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 521 additions and 107 deletions

View File

@ -5556,7 +5556,6 @@ plsql_unreserved_keyword
| KW_SLICE
| KW_SQLSTATE
| KW_STACKED
| KW_TABLE
//| TABLE_NAME
| KW_TYPE
| KW_USE_COLUMN

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -75,3 +75,7 @@ UPDATE tablename SET columnname = a + b, (col1, col2) = (a+3, b+4);
VACUUM tablename (col1, col2);
SELECT * FROM db.tbs GROUP BY (col1, col2) ORDER BY col3;
TRUNCATE TABLE ;
TRUNCATE TABLE t1;

View File

@ -970,4 +970,36 @@ describe('Postgre SQL Syntax Suggestion', () => {
expect(suggestion3).not.toBeUndefined();
expect(suggestion3?.wordRanges.map((token) => token.text)).toEqual(['col3']);
});
test('TRUNCATE TABLE', () => {
const pos1: CaretPosition = {
lineNumber: 79,
column: 16,
};
const pos2: CaretPosition = {
lineNumber: 81,
column: 18,
};
const syntaxes1 = postgresql.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos1.lineNumber),
pos1
)?.syntax;
const syntaxes2 = postgresql.getSuggestionAtCaretPosition(
commentOtherLine(syntaxSql, pos2.lineNumber),
pos2
)?.syntax;
const suggestion1 = syntaxes1?.find(
(syn) => syn.syntaxContextType === EntityContextType.TABLE
);
const suggestion2 = syntaxes2?.find(
(syn) => syn.syntaxContextType === EntityContextType.TABLE
);
expect(suggestion1).not.toBeUndefined();
expect(suggestion1?.wordRanges.map((token) => token.text)).toEqual([]);
expect(suggestion2).not.toBeUndefined();
expect(suggestion2?.wordRanges.map((token) => token.text)).toEqual(['t1']);
});
});