@@ -10,7 +10,7 @@ import Table from "../../database/table";
10
10
import Document from "../sql/document" ;
11
11
import * as LanguageStatement from "../sql/statement" ;
12
12
import { CTEReference , CallableReference , ClauseType , ObjectRef , StatementType } from "../sql/types" ;
13
- import CompletionItemCache , { changedCache } from "./completionItemCache" ;
13
+ import CompletionItemCache , { changedCache , toKey } from "./completionItemCache" ;
14
14
import Callable , { CallableType } from "../../database/callable" ;
15
15
import { ServerComponent } from "../../connection/serverComponent" ;
16
16
import { prepareParamType , createCompletionItem , getParmAttributes , completionItemCache } from "./completion" ;
@@ -91,10 +91,11 @@ async function getObjectColumns(
91
91
isUDTF = false
92
92
) : Promise < CompletionItem [ ] > {
93
93
94
- const databaseObj = ( schema + name ) . toUpperCase ( ) ;
95
- const tableUpdate : boolean = changedCache . delete ( databaseObj ) ;
94
+ const cacheKey = toKey ( `columns` , schema + name )
95
+ const tableUpdate : boolean = changedCache . delete ( cacheKey ) ;
96
+ const isCached = completionItemCache . has ( cacheKey ) ;
96
97
97
- if ( ! completionItemCache . has ( databaseObj ) || tableUpdate ) {
98
+ if ( ! isCached || tableUpdate ) {
98
99
schema = Statement . noQuotes ( Statement . delimName ( schema , true ) ) ;
99
100
name = Statement . noQuotes ( Statement . delimName ( name , true ) ) ;
100
101
@@ -104,7 +105,7 @@ async function getObjectColumns(
104
105
const resultSet = await Callable . getResultColumns ( schema , name , true ) ;
105
106
106
107
if ( ! resultSet ?. length ? true : false ) {
107
- completionItemCache . set ( databaseObj , [ ] ) ;
108
+ completionItemCache . set ( cacheKey , [ ] ) ;
108
109
return [ ] ;
109
110
}
110
111
@@ -122,7 +123,7 @@ async function getObjectColumns(
122
123
const columns = await Table . getItems ( schema , name ) ;
123
124
124
125
if ( ! columns ?. length ? true : false ) {
125
- completionItemCache . set ( databaseObj , [ ] ) ;
126
+ completionItemCache . set ( cacheKey , [ ] ) ;
126
127
return [ ] ;
127
128
}
128
129
@@ -139,9 +140,10 @@ async function getObjectColumns(
139
140
140
141
const allCols = getAllColumns ( name , schema , completionItems ) ;
141
142
completionItems . push ( allCols ) ;
142
- completionItemCache . set ( databaseObj , completionItems ) ;
143
+ completionItemCache . set ( cacheKey , completionItems ) ;
143
144
}
144
- return completionItemCache . get ( databaseObj ) ;
145
+
146
+ return completionItemCache . get ( cacheKey ) ;
145
147
}
146
148
147
149
/**
@@ -172,6 +174,7 @@ async function getObjectCompletions(
172
174
. filter ( ( result ) => result . status == "fulfilled" )
173
175
. map ( ( result ) => ( result as PromiseFulfilledResult < any > ) . value )
174
176
. flat ( ) ;
177
+
175
178
completionItemCache . set ( forSchema , list ) ;
176
179
}
177
180
return completionItemCache . get ( forSchema ) ;
0 commit comments