@zz1996/dbhub-dameng 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -217,6 +217,64 @@ var DamengConnector = class _DamengConnector {
217
217
  );
218
218
  return rows.map((row) => this.rowValue(row, "TABLE_NAME")).filter(this.isPresent).map((name) => ({ name, schema: owner }));
219
219
  }
220
+ async searchColumns(pattern, schema, table, limit = 100) {
221
+ const owner = await this.resolveSchema(schema);
222
+ const rowLimit = this.normalizeLimit(limit);
223
+ const bindValues = [
224
+ owner,
225
+ this.normalizeLikePattern(pattern),
226
+ ...table ? [this.normalizeIdentifier(table)] : []
227
+ ];
228
+ const tablePredicate = table ? "AND c.TABLE_NAME = :3" : "";
229
+ const rows = await this.queryRows(
230
+ `
231
+ SELECT COLUMN_NAME,
232
+ TABLE_NAME,
233
+ DATA_TYPE,
234
+ DATA_LENGTH,
235
+ DATA_PRECISION,
236
+ DATA_SCALE,
237
+ NULLABLE,
238
+ DATA_DEFAULT,
239
+ COMMENTS
240
+ FROM (
241
+ SELECT c.COLUMN_NAME,
242
+ c.TABLE_NAME,
243
+ c.DATA_TYPE,
244
+ c.DATA_LENGTH,
245
+ c.DATA_PRECISION,
246
+ c.DATA_SCALE,
247
+ c.NULLABLE,
248
+ c.DATA_DEFAULT,
249
+ cc.COMMENTS,
250
+ c.COLUMN_ID
251
+ FROM ALL_TAB_COLUMNS c
252
+ LEFT JOIN ALL_COL_COMMENTS cc
253
+ ON cc.OWNER = c.OWNER
254
+ AND cc.TABLE_NAME = c.TABLE_NAME
255
+ AND cc.COLUMN_NAME = c.COLUMN_NAME
256
+ WHERE c.OWNER = :1
257
+ AND c.COLUMN_NAME LIKE :2
258
+ ${tablePredicate}
259
+ ORDER BY c.TABLE_NAME, c.COLUMN_ID
260
+ )
261
+ WHERE ROWNUM <= ${rowLimit}
262
+ `,
263
+ bindValues
264
+ );
265
+ return rows.map((row) => {
266
+ const description = this.rowValue(row, "COMMENTS");
267
+ return {
268
+ name: this.rowValue(row, "COLUMN_NAME") ?? "",
269
+ table: this.rowValue(row, "TABLE_NAME") ?? "",
270
+ schema: owner,
271
+ type: this.formatDataType(row),
272
+ nullable: this.rowValue(row, "NULLABLE") === "Y",
273
+ default: this.rowValue(row, "DATA_DEFAULT") ?? null,
274
+ ...description ? { description } : {}
275
+ };
276
+ });
277
+ }
220
278
  async getViews(schema) {
221
279
  const owner = await this.resolveSchema(schema);
222
280
  const rows = await this.queryRows(
package/dist/index.js CHANGED
@@ -586,6 +586,36 @@ async function searchColumns(connector, pattern, schemaFilter, tableFilter, deta
586
586
  for (const schemaName of schemasToSearch) {
587
587
  if (results.length >= limit) break;
588
588
  try {
589
+ const searchableConnector = connector;
590
+ if (searchableConnector.searchColumns) {
591
+ const matchedColumns = await searchableConnector.searchColumns(
592
+ pattern,
593
+ schemaName,
594
+ tableFilter,
595
+ limit - results.length
596
+ );
597
+ for (const column of matchedColumns) {
598
+ if (results.length >= limit) break;
599
+ if (detailLevel === "names") {
600
+ results.push({
601
+ name: column.name,
602
+ table: column.table,
603
+ schema: column.schema
604
+ });
605
+ } else {
606
+ results.push({
607
+ name: column.name,
608
+ table: column.table,
609
+ schema: column.schema,
610
+ type: column.type,
611
+ nullable: column.nullable,
612
+ default: column.default,
613
+ ...column.description ? { description: column.description } : {}
614
+ });
615
+ }
616
+ }
617
+ continue;
618
+ }
589
619
  let tablesToSearch;
590
620
  if (tableFilter) {
591
621
  tablesToSearch = [tableFilter];
@@ -1835,7 +1865,7 @@ var connectorModules = [
1835
1865
  { load: () => import("./sqlite-IOUAYHGE.js"), name: "SQLite", driver: "node:sqlite" },
1836
1866
  { load: () => import("./mysql-A43SL7UM.js"), name: "MySQL", driver: "mysql2" },
1837
1867
  { load: () => import("./mariadb-7F72IRB4.js"), name: "MariaDB", driver: "mariadb" },
1838
- { load: () => import("./dameng-SOGGZUEW.js"), name: "Dameng", driver: "dmdb" }
1868
+ { load: () => import("./dameng-DTI47UV6.js"), name: "Dameng", driver: "dmdb" }
1839
1869
  ];
1840
1870
  loadConnectors(connectorModules).then(() => main()).catch((error) => {
1841
1871
  console.error("Fatal error:", error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zz1996/dbhub-dameng",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "mcpName": "io.github.zuozh11/dbhub-dameng",
5
5
  "description": "Local fork of DBHub with Dameng/DM8 database connector support",
6
6
  "repository": {