Skip to content

Commit 52052d4

Browse files
committed
Change to processing context items
Signed-off-by: worksofliam <[email protected]>
1 parent ac6f693 commit 52052d4

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/aiProviders/context.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,6 @@ function splitUpUserInput(input: string): string[] {
168168
* @param {string} input - A string that may contain table references.
169169
*/
170170
export async function getSqlContextItems(input: string): Promise<ContextDefinition[]> {
171-
let contextItems: ContextDefinition[] = [];
172-
173171
// Parse all SCHEMA.TABLE references first
174172
const tokens = splitUpUserInput(input);
175173

@@ -203,23 +201,21 @@ export async function getSqlContextItems(input: string): Promise<ContextDefiniti
203201

204202
const allObjects = await Schemas.resolveObjects(possibleRefs);
205203

206-
await Promise.all(
204+
const contextItems = (await Promise.all(
207205
allObjects.map(async (o) => {
208206
try {
209207
const content = await Schemas.generateSQL(o.schema, o.name, o.sqlType);
210208

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,
217213
}
218214
} catch (e) {
219-
// ignore
215+
return undefined;
220216
}
221217
})
222-
);
218+
)).filter((item) => item !== undefined);
223219

224220
return contextItems;
225221
}

0 commit comments

Comments
 (0)