File tree Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Expand file tree Collapse file tree 1 file changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -168,8 +168,6 @@ function splitUpUserInput(input: string): string[] {
168
168
* @param {string } input - A string that may contain table references.
169
169
*/
170
170
export async function getSqlContextItems ( input : string ) : Promise < ContextDefinition [ ] > {
171
- let contextItems : ContextDefinition [ ] = [ ] ;
172
-
173
171
// Parse all SCHEMA.TABLE references first
174
172
const tokens = splitUpUserInput ( input ) ;
175
173
@@ -203,23 +201,21 @@ export async function getSqlContextItems(input: string): Promise<ContextDefiniti
203
201
204
202
const allObjects = await Schemas . resolveObjects ( possibleRefs ) ;
205
203
206
- await Promise . all (
204
+ const contextItems = ( await Promise . all (
207
205
allObjects . map ( async ( o ) => {
208
206
try {
209
207
const content = await Schemas . generateSQL ( o . schema , o . name , o . sqlType ) ;
210
208
211
- if ( content ) {
212
- contextItems . push ( {
213
- id : o . name ,
214
- type : o . sqlType ,
215
- content : content ,
216
- } ) ;
209
+ return {
210
+ id : o . name ,
211
+ type : o . sqlType ,
212
+ content : content ,
217
213
}
218
214
} catch ( e ) {
219
- // ignore
215
+ return undefined ;
220
216
}
221
217
} )
222
- ) ;
218
+ ) ) . filter ( ( item ) => item !== undefined ) ;
223
219
224
220
return contextItems ;
225
221
}
You can’t perform that action at this time.
0 commit comments