@@ -188,91 +188,6 @@ export async function generateTableDefinition(schema: string, input: string[]) {
188
188
return tables ;
189
189
}
190
190
191
- // depreciated
192
- export async function findPossibleTables (
193
- stream : vscode . ChatResponseStream ,
194
- schema : string ,
195
- words : string [ ]
196
- ) {
197
- let tables : TableRefs = { } ;
198
-
199
- // Parse all SCHEMA.TABLE references first
200
- const schemaTableRefs = words . filter ( ( word ) => word . includes ( "." ) ) ;
201
- const justWords = words . map ( ( word ) =>
202
- word . replace ( / [ , \/ # ! ? $ % \^ & \* ; : { } = \- _ ` ~ ( ) ] / g, "" )
203
- ) ;
204
-
205
- // Remove plurals from words
206
- justWords . push (
207
- ...justWords
208
- . filter ( ( word ) => word . endsWith ( "s" ) )
209
- . map ( ( word ) => word . slice ( 0 , - 1 ) )
210
- ) ;
211
-
212
- // Filter prompt for possible refs to tables
213
- const validWords = justWords
214
- . filter (
215
- ( word ) => word . length > 2 && ! word . endsWith ( "s" ) && ! word . includes ( `'` )
216
- )
217
- . map ( ( word ) => `'${ Statement . delimName ( word , true ) } '` ) ;
218
-
219
- const objectFindStatement = [
220
- `SELECT ` ,
221
- ` column.TABLE_SCHEMA,` ,
222
- ` column.TABLE_NAME,` ,
223
- ` column.COLUMN_NAME,` ,
224
- ` key.CONSTRAINT_NAME,` ,
225
- ` column.DATA_TYPE, ` ,
226
- ` column.CHARACTER_MAXIMUM_LENGTH,` ,
227
- ` column.NUMERIC_SCALE, ` ,
228
- ` column.NUMERIC_PRECISION,` ,
229
- ` column.IS_NULLABLE, ` ,
230
- // ` column.HAS_DEFAULT, `,
231
- // ` column.COLUMN_DEFAULT, `,
232
- ` column.COLUMN_TEXT, ` ,
233
- ` column.IS_IDENTITY` ,
234
- `FROM QSYS2.SYSCOLUMNS2 as column` ,
235
- `LEFT JOIN QSYS2.syskeycst as key` ,
236
- ` on ` ,
237
- ` column.table_schema = key.table_schema and` ,
238
- ` column.table_name = key.table_name and` ,
239
- ` column.column_name = key.column_name` ,
240
- `WHERE column.TABLE_SCHEMA = '${ Statement . delimName ( schema , true ) } '` ,
241
- ...[
242
- schemaTableRefs . length > 0
243
- ? `AND (column.TABLE_NAME in (${ validWords . join (
244
- `, `
245
- ) } ) OR (${ schemaTableRefs
246
- . map ( ( ref ) => {
247
- const [ schema , table ] = ref . split ( "." ) ;
248
- const cleanedTable = table . replace (
249
- / [ , \/ # ! ? $ % \^ & \* ; : { } = \- _ ` ~ ( ) ] / g,
250
- ""
251
- ) ;
252
- return `(column.TABLE_SCHEMA = '${ Statement . delimName (
253
- schema ,
254
- true
255
- ) } ' AND column.TABLE_NAME = '${ Statement . delimName (
256
- cleanedTable ,
257
- true
258
- ) } ')`;
259
- } )
260
- . join ( " OR " ) } ))`
261
- : `AND column.TABLE_NAME in (${ validWords . join ( `, ` ) } )` ,
262
- ] ,
263
- `ORDER BY column.ORDINAL_POSITION` ,
264
- ] . join ( ` ` ) ;
265
- // TODO
266
- const result : TableColumn [ ] = await JobManager . runSQL ( objectFindStatement ) ;
267
-
268
- result . forEach ( ( row ) => {
269
- const tableName = row . TABLE_NAME . toLowerCase ( ) ;
270
- if ( ! tables [ tableName ] ) tables [ tableName ] = [ ] ;
271
- tables [ tableName ] . push ( row ) ;
272
- } ) ;
273
- return tables ;
274
- }
275
-
276
191
/**
277
192
* Converts a given set of table references to a Markdown string.
278
193
*
0 commit comments