@petradb/knex 1.2.0 → 1.2.1
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.
- package/README.md +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,10 @@ declare class QueryCompiler_PetraDB extends QueryCompilerBase {
|
|
|
57
57
|
sql: string;
|
|
58
58
|
returning: any;
|
|
59
59
|
};
|
|
60
|
+
columnInfo(): {
|
|
61
|
+
sql: string;
|
|
62
|
+
output(resp: any): any;
|
|
63
|
+
};
|
|
60
64
|
_returning(value: any): string;
|
|
61
65
|
}
|
|
62
66
|
declare class PetraDBClient extends ClientBase {
|
package/dist/index.js
CHANGED
|
@@ -263,6 +263,31 @@ class QueryCompiler_PetraDB extends QueryCompilerBase {
|
|
|
263
263
|
returning,
|
|
264
264
|
};
|
|
265
265
|
}
|
|
266
|
+
columnInfo() {
|
|
267
|
+
const column = this.single.columnInfo;
|
|
268
|
+
const table = this.client.customWrapIdentifier(this.single.table, (v) => v);
|
|
269
|
+
return {
|
|
270
|
+
sql: `SHOW COLUMNS FROM "${table}"`,
|
|
271
|
+
output(resp) {
|
|
272
|
+
const rows = resp.rows || resp;
|
|
273
|
+
const out = rows.reduce((columns, val) => {
|
|
274
|
+
let type = val.type || "";
|
|
275
|
+
const maxLengthMatch = type.match(/.*\((\d+)\)/);
|
|
276
|
+
const maxLength = maxLengthMatch ? maxLengthMatch[1] : null;
|
|
277
|
+
if (maxLength)
|
|
278
|
+
type = type.split("(")[0];
|
|
279
|
+
columns[val.name] = {
|
|
280
|
+
type: type.toLowerCase(),
|
|
281
|
+
maxLength,
|
|
282
|
+
nullable: !val.required,
|
|
283
|
+
defaultValue: val.default_value || null,
|
|
284
|
+
};
|
|
285
|
+
return columns;
|
|
286
|
+
}, {});
|
|
287
|
+
return (column && out[column]) || out;
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
}
|
|
266
291
|
_returning(value) {
|
|
267
292
|
return value ? ` returning ${this.formatter.columnize(value)}` : "";
|
|
268
293
|
}
|