@nshiab/simple-data-analysis-core 2.0.5 → 2.0.7
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 +118 -12
- package/esm/class/Simple.d.ts +8 -2
- package/esm/class/Simple.d.ts.map +1 -1
- package/esm/class/Simple.js +9 -3
- package/esm/class/SimpleDB.d.ts +72 -1
- package/esm/class/SimpleDB.d.ts.map +1 -1
- package/esm/class/SimpleDB.js +81 -1
- package/esm/class/SimpleTable.d.ts +271 -288
- package/esm/class/SimpleTable.d.ts.map +1 -1
- package/esm/class/SimpleTable.js +269 -340
- package/esm/helpers/LogValue.d.ts +8 -0
- package/esm/helpers/LogValue.d.ts.map +1 -0
- package/esm/helpers/LogValue.js +23 -0
- package/esm/helpers/cacheTableDependencies.d.ts +9 -0
- package/esm/helpers/cacheTableDependencies.d.ts.map +1 -1
- package/esm/helpers/cacheTableDependencies.js +131 -21
- package/esm/helpers/cleanSQL.d.ts +1 -1
- package/esm/helpers/cleanSQL.d.ts.map +1 -1
- package/esm/helpers/cleanSQL.js +268 -23
- package/esm/helpers/flushAllTables.d.ts.map +1 -1
- package/esm/helpers/flushAllTables.js +23 -28
- package/esm/helpers/foldIdentifier.d.ts +3 -0
- package/esm/helpers/foldIdentifier.d.ts.map +1 -0
- package/esm/helpers/foldIdentifier.js +4 -0
- package/esm/helpers/geometryFromJSON.d.ts +3 -0
- package/esm/helpers/geometryFromJSON.d.ts.map +1 -0
- package/esm/helpers/geometryFromJSON.js +4 -0
- package/esm/helpers/index.d.ts +1 -0
- package/esm/helpers/index.d.ts.map +1 -1
- package/esm/helpers/index.js +1 -0
- package/esm/helpers/logData.d.ts.map +1 -1
- package/esm/helpers/logData.js +45 -44
- package/esm/helpers/makeLogConverter.d.ts +5 -0
- package/esm/helpers/makeLogConverter.d.ts.map +1 -0
- package/esm/helpers/makeLogConverter.js +64 -0
- package/esm/helpers/osmFiles.d.ts.map +1 -1
- package/esm/helpers/parseTypes.d.ts +1 -1
- package/esm/helpers/parseTypes.d.ts.map +1 -1
- package/esm/helpers/parseTypes.js +4 -0
- package/esm/helpers/pendingOps.d.ts +4 -2
- package/esm/helpers/pendingOps.d.ts.map +1 -1
- package/esm/helpers/prepareGeometry.d.ts +3 -0
- package/esm/helpers/prepareGeometry.d.ts.map +1 -0
- package/esm/helpers/prepareGeometry.js +99 -0
- package/esm/helpers/prepareJSON.d.ts +3 -0
- package/esm/helpers/prepareJSON.d.ts.map +1 -0
- package/esm/helpers/prepareJSON.js +50 -0
- package/esm/helpers/printTable.d.ts +5 -4
- package/esm/helpers/printTable.d.ts.map +1 -1
- package/esm/helpers/printTable.js +32 -36
- package/esm/helpers/queryDB.js +1 -1
- package/esm/helpers/queueAsyncBarrier.d.ts +4 -0
- package/esm/helpers/queueAsyncBarrier.d.ts.map +1 -1
- package/esm/helpers/queueAsyncBarrier.js +4 -0
- package/esm/helpers/queueOp.d.ts.map +1 -1
- package/esm/helpers/queueOp.js +5 -3
- package/esm/helpers/readMutationRows.d.ts +9 -0
- package/esm/helpers/readMutationRows.d.ts.map +1 -0
- package/esm/helpers/readMutationRows.js +94 -0
- package/esm/helpers/referencedTables.d.ts +9 -0
- package/esm/helpers/referencedTables.d.ts.map +1 -0
- package/esm/helpers/referencedTables.js +22 -0
- package/esm/helpers/runQuery.d.ts.map +1 -1
- package/esm/helpers/runQuery.js +11 -13
- package/esm/helpers/scanSQL.d.ts +7 -0
- package/esm/helpers/scanSQL.d.ts.map +1 -0
- package/esm/helpers/scanSQL.js +71 -0
- package/esm/helpers/tableRegistry.d.ts +2 -0
- package/esm/helpers/tableRegistry.d.ts.map +1 -1
- package/esm/helpers/tableRegistry.js +12 -4
- package/esm/helpers/updateColumnsWithJS.d.ts +52 -0
- package/esm/helpers/updateColumnsWithJS.d.ts.map +1 -0
- package/esm/helpers/updateColumnsWithJS.js +139 -0
- package/esm/methods/addColumn.d.ts +1 -1
- package/esm/methods/addColumn.d.ts.map +1 -1
- package/esm/methods/bins.d.ts +1 -1
- package/esm/methods/bins.d.ts.map +1 -1
- package/esm/methods/bins.js +45 -29
- package/esm/methods/bm25.d.ts.map +1 -1
- package/esm/methods/bm25.js +1 -2
- package/esm/methods/cache.d.ts.map +1 -1
- package/esm/methods/cache.js +4 -6
- package/esm/methods/convert.d.ts +2 -2
- package/esm/methods/convert.d.ts.map +1 -1
- package/esm/methods/convert.js +5 -0
- package/esm/methods/getBottom.d.ts +1 -1
- package/esm/methods/getBottom.d.ts.map +1 -1
- package/esm/methods/getBottom.js +2 -2
- package/esm/methods/getData.d.ts +1 -1
- package/esm/methods/getData.d.ts.map +1 -1
- package/esm/methods/getData.js +2 -2
- package/esm/methods/join.d.ts.map +1 -1
- package/esm/methods/join.js +8 -16
- package/esm/methods/joinGeo.d.ts.map +1 -1
- package/esm/methods/joinGeo.js +10 -19
- package/esm/methods/loadArray.d.ts +1 -1
- package/esm/methods/loadArray.d.ts.map +1 -1
- package/esm/methods/loadArray.js +74 -19
- package/esm/methods/loadData.js +3 -0
- package/esm/methods/log.d.ts +7 -0
- package/esm/methods/log.d.ts.map +1 -0
- package/esm/methods/log.js +63 -0
- package/esm/methods/logBottom.d.ts +5 -0
- package/esm/methods/logBottom.d.ts.map +1 -0
- package/esm/methods/logBottom.js +9 -0
- package/esm/methods/removeTable.d.ts.map +1 -1
- package/esm/methods/removeTable.js +2 -0
- package/esm/methods/removeTables.d.ts.map +1 -1
- package/esm/methods/removeTables.js +7 -0
- package/esm/methods/renameTable.d.ts.map +1 -1
- package/esm/methods/renameTable.js +4 -0
- package/esm/methods/rowToText.js +2 -2
- package/esm/methods/selectTables.d.ts.map +1 -1
- package/esm/methods/selectTables.js +6 -0
- package/esm/methods/setTypes.d.ts +1 -1
- package/esm/methods/setTypes.d.ts.map +1 -1
- package/esm/methods/stream.d.ts.map +1 -1
- package/esm/methods/stream.js +2 -1
- package/esm/methods/updateWithJS.d.ts +1 -3
- package/esm/methods/updateWithJS.d.ts.map +1 -1
- package/esm/methods/updateWithJS.js +123 -37
- package/llm.md +365 -461
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/script/class/Simple.d.ts +8 -2
- package/script/class/Simple.d.ts.map +1 -1
- package/script/class/Simple.js +9 -3
- package/script/class/SimpleDB.d.ts +72 -1
- package/script/class/SimpleDB.d.ts.map +1 -1
- package/script/class/SimpleDB.js +81 -1
- package/script/class/SimpleTable.d.ts +271 -288
- package/script/class/SimpleTable.d.ts.map +1 -1
- package/script/class/SimpleTable.js +269 -340
- package/script/helpers/LogValue.d.ts +8 -0
- package/script/helpers/LogValue.d.ts.map +1 -0
- package/script/helpers/LogValue.js +26 -0
- package/script/helpers/cacheTableDependencies.d.ts +9 -0
- package/script/helpers/cacheTableDependencies.d.ts.map +1 -1
- package/script/helpers/cacheTableDependencies.js +170 -20
- package/script/helpers/cleanSQL.d.ts +1 -1
- package/script/helpers/cleanSQL.d.ts.map +1 -1
- package/script/helpers/cleanSQL.js +271 -23
- package/script/helpers/flushAllTables.d.ts.map +1 -1
- package/script/helpers/flushAllTables.js +24 -29
- package/script/helpers/foldIdentifier.d.ts +3 -0
- package/script/helpers/foldIdentifier.d.ts.map +1 -0
- package/script/helpers/foldIdentifier.js +7 -0
- package/script/helpers/geometryFromJSON.d.ts +3 -0
- package/script/helpers/geometryFromJSON.d.ts.map +1 -0
- package/script/helpers/geometryFromJSON.js +7 -0
- package/script/helpers/index.d.ts +1 -0
- package/script/helpers/index.d.ts.map +1 -1
- package/script/helpers/index.js +3 -1
- package/script/helpers/logData.d.ts.map +1 -1
- package/script/helpers/logData.js +45 -44
- package/script/helpers/makeLogConverter.d.ts +5 -0
- package/script/helpers/makeLogConverter.d.ts.map +1 -0
- package/script/helpers/makeLogConverter.js +70 -0
- package/script/helpers/osmFiles.d.ts.map +1 -1
- package/script/helpers/parseTypes.d.ts +1 -1
- package/script/helpers/parseTypes.d.ts.map +1 -1
- package/script/helpers/parseTypes.js +4 -0
- package/script/helpers/pendingOps.d.ts +4 -2
- package/script/helpers/pendingOps.d.ts.map +1 -1
- package/script/helpers/prepareGeometry.d.ts +3 -0
- package/script/helpers/prepareGeometry.d.ts.map +1 -0
- package/script/helpers/prepareGeometry.js +102 -0
- package/script/helpers/prepareJSON.d.ts +3 -0
- package/script/helpers/prepareJSON.d.ts.map +1 -0
- package/script/helpers/prepareJSON.js +53 -0
- package/script/helpers/printTable.d.ts +5 -4
- package/script/helpers/printTable.d.ts.map +1 -1
- package/script/helpers/printTable.js +32 -36
- package/script/helpers/queryDB.js +1 -1
- package/script/helpers/queueAsyncBarrier.d.ts +4 -0
- package/script/helpers/queueAsyncBarrier.d.ts.map +1 -1
- package/script/helpers/queueAsyncBarrier.js +4 -0
- package/script/helpers/queueOp.d.ts.map +1 -1
- package/script/helpers/queueOp.js +4 -2
- package/script/helpers/readMutationRows.d.ts +9 -0
- package/script/helpers/readMutationRows.d.ts.map +1 -0
- package/script/helpers/readMutationRows.js +97 -0
- package/script/helpers/referencedTables.d.ts +9 -0
- package/script/helpers/referencedTables.d.ts.map +1 -0
- package/script/helpers/referencedTables.js +28 -0
- package/script/helpers/runQuery.d.ts.map +1 -1
- package/script/helpers/runQuery.js +11 -13
- package/script/helpers/scanSQL.d.ts +7 -0
- package/script/helpers/scanSQL.d.ts.map +1 -0
- package/script/helpers/scanSQL.js +74 -0
- package/script/helpers/tableRegistry.d.ts +2 -0
- package/script/helpers/tableRegistry.d.ts.map +1 -1
- package/script/helpers/tableRegistry.js +16 -4
- package/script/helpers/updateColumnsWithJS.d.ts +52 -0
- package/script/helpers/updateColumnsWithJS.d.ts.map +1 -0
- package/script/helpers/updateColumnsWithJS.js +145 -0
- package/script/methods/addColumn.d.ts +1 -1
- package/script/methods/addColumn.d.ts.map +1 -1
- package/script/methods/bins.d.ts +1 -1
- package/script/methods/bins.d.ts.map +1 -1
- package/script/methods/bins.js +45 -29
- package/script/methods/bm25.d.ts.map +1 -1
- package/script/methods/bm25.js +1 -2
- package/script/methods/cache.d.ts.map +1 -1
- package/script/methods/cache.js +3 -5
- package/script/methods/convert.d.ts +2 -2
- package/script/methods/convert.d.ts.map +1 -1
- package/script/methods/convert.js +5 -0
- package/script/methods/getBottom.d.ts +1 -1
- package/script/methods/getBottom.d.ts.map +1 -1
- package/script/methods/getBottom.js +2 -2
- package/script/methods/getData.d.ts +1 -1
- package/script/methods/getData.d.ts.map +1 -1
- package/script/methods/getData.js +2 -2
- package/script/methods/join.d.ts.map +1 -1
- package/script/methods/join.js +8 -16
- package/script/methods/joinGeo.d.ts.map +1 -1
- package/script/methods/joinGeo.js +10 -19
- package/script/methods/loadArray.d.ts +1 -1
- package/script/methods/loadArray.d.ts.map +1 -1
- package/script/methods/loadArray.js +74 -19
- package/script/methods/loadData.js +3 -0
- package/script/methods/log.d.ts +7 -0
- package/script/methods/log.d.ts.map +1 -0
- package/script/methods/log.js +69 -0
- package/script/methods/logBottom.d.ts +5 -0
- package/script/methods/logBottom.d.ts.map +1 -0
- package/script/methods/logBottom.js +15 -0
- package/script/methods/removeTable.d.ts.map +1 -1
- package/script/methods/removeTable.js +2 -0
- package/script/methods/removeTables.d.ts.map +1 -1
- package/script/methods/removeTables.js +7 -0
- package/script/methods/renameTable.d.ts.map +1 -1
- package/script/methods/renameTable.js +4 -0
- package/script/methods/rowToText.js +2 -2
- package/script/methods/selectTables.d.ts.map +1 -1
- package/script/methods/selectTables.js +6 -0
- package/script/methods/setTypes.d.ts +1 -1
- package/script/methods/setTypes.d.ts.map +1 -1
- package/script/methods/stream.d.ts.map +1 -1
- package/script/methods/stream.js +2 -1
- package/script/methods/updateWithJS.d.ts +1 -3
- package/script/methods/updateWithJS.d.ts.map +1 -1
- package/script/methods/updateWithJS.js +122 -36
|
@@ -13,7 +13,7 @@ export declare function prepareArray(rows: {
|
|
|
13
13
|
[key: string]: unknown;
|
|
14
14
|
}[], columnTypes?: {
|
|
15
15
|
[key: string]: string;
|
|
16
|
-
}): PreparedArray;
|
|
16
|
+
}, requireExplicitNestedTypes?: boolean): PreparedArray;
|
|
17
17
|
export declare function executePreparedArray(simpleTable: SimpleTable, prepared: PreparedArray): Promise<void>;
|
|
18
18
|
export {};
|
|
19
19
|
//# sourceMappingURL=loadArray.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadArray.d.ts","sourceRoot":"","sources":["../../src/methods/loadArray.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"loadArray.d.ts","sourceRoot":"","sources":["../../src/methods/loadArray.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,WAAW,EACjB,MAAM,kBAAkB,CAAC;AAK1B,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAKvD,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,EAClC,OAAO,GAAE,WAAW,CAAC,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAM,QAiBnE;AAED,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,EAAE,WAAW,EAAE,EAAE,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAgB,YAAY,CAC1B,IAAI,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,EAClC,WAAW,GAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAO,EAC3C,0BAA0B,UAAQ,GACjC,aAAa,CAsHf;AAED,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,aAAa,iBA4ExB"}
|
|
@@ -7,6 +7,9 @@ exports.default = loadArray;
|
|
|
7
7
|
exports.prepareArray = prepareArray;
|
|
8
8
|
exports.executePreparedArray = executePreparedArray;
|
|
9
9
|
const node_api_1 = require("@duckdb/node-api");
|
|
10
|
+
const prepareGeometry_js_1 = __importDefault(require("../helpers/prepareGeometry.js"));
|
|
11
|
+
const prepareJSON_js_1 = __importDefault(require("../helpers/prepareJSON.js"));
|
|
12
|
+
const geometryFromJSON_js_1 = __importDefault(require("../helpers/geometryFromJSON.js"));
|
|
10
13
|
const queueOp_js_1 = __importDefault(require("../helpers/queueOp.js"));
|
|
11
14
|
const parseTypes_js_1 = __importDefault(require("../helpers/parseTypes.js"));
|
|
12
15
|
const parseDuckDBType_js_1 = __importDefault(require("../helpers/parseDuckDBType.js"));
|
|
@@ -16,7 +19,7 @@ function loadArray(simpleTable, rows, options = {}) {
|
|
|
16
19
|
if (rows.length === 0) {
|
|
17
20
|
throw new Error("The array is empty. loadArray needs at least one object to infer the column types.");
|
|
18
21
|
}
|
|
19
|
-
const prepared = prepareArray(rows, options.columnTypes);
|
|
22
|
+
const prepared = prepareArray(rows, options.columnTypes, true);
|
|
20
23
|
(0, queueOp_js_1.default)(simpleTable, {
|
|
21
24
|
kind: "barrier",
|
|
22
25
|
method: "loadArray()",
|
|
@@ -24,17 +27,26 @@ function loadArray(simpleTable, rows, options = {}) {
|
|
|
24
27
|
execute: () => executePreparedArray(simpleTable, prepared),
|
|
25
28
|
});
|
|
26
29
|
}
|
|
27
|
-
function prepareArray(rows, columnTypes = {}) {
|
|
30
|
+
function prepareArray(rows, columnTypes = {}, requireExplicitNestedTypes = false) {
|
|
28
31
|
const keys = Object.keys(rows[0]);
|
|
29
32
|
const overrides = new Map();
|
|
30
33
|
for (const [key, type] of Object.entries(columnTypes)) {
|
|
31
34
|
if (!keys.includes(key)) {
|
|
32
35
|
throw new Error(`Unknown column ${JSON.stringify(key)} in loadArray columnTypes.`);
|
|
33
36
|
}
|
|
37
|
+
if (type.toUpperCase() === "JSON") {
|
|
38
|
+
overrides.set(key, "JSON");
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (/^geometry/i.test(type)) {
|
|
42
|
+
if (!/^geometry\('EPSG:4326'\)$/i.test(type)) {
|
|
43
|
+
throw new Error(`Unsupported type ${JSON.stringify(type)} for column ${JSON.stringify(key)}. GeoJSON ingestion requires GEOMETRY('EPSG:4326'); reproject input to WGS84 first.`);
|
|
44
|
+
}
|
|
45
|
+
overrides.set(key, "GEOMETRY('EPSG:4326')");
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
34
48
|
try {
|
|
35
|
-
const normalized =
|
|
36
|
-
? type.toUpperCase()
|
|
37
|
-
: (0, parseTypes_js_1.default)(type);
|
|
49
|
+
const normalized = (0, parseTypes_js_1.default)(type);
|
|
38
50
|
(0, parseDuckDBType_js_1.default)(normalized);
|
|
39
51
|
overrides.set(key, normalized);
|
|
40
52
|
}
|
|
@@ -56,6 +68,14 @@ function prepareArray(rows, columnTypes = {}) {
|
|
|
56
68
|
}
|
|
57
69
|
continue;
|
|
58
70
|
}
|
|
71
|
+
if (requireExplicitNestedTypes) {
|
|
72
|
+
for (let j = 0; j < rows.length; j++) {
|
|
73
|
+
const cell = rows[j][key];
|
|
74
|
+
if (cell !== null && typeof cell === "object" && !(cell instanceof Date)) {
|
|
75
|
+
throw new Error(`Column ${JSON.stringify(key)}, row ${j + 1}: array and object cells require an explicit columnTypes entry. Use JSON for nested data, FLOAT[n] for fixed-size vectors, or GEOMETRY('EPSG:4326') for GeoJSON geometries.`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
59
79
|
const value = firstNonNullValue[i];
|
|
60
80
|
const type = typeof value;
|
|
61
81
|
if (type === "symbol" || type === "function") {
|
|
@@ -112,24 +132,59 @@ async function executePreparedArray(simpleTable, prepared) {
|
|
|
112
132
|
simpleTable.connection = simpleTable.sdb.connection;
|
|
113
133
|
}
|
|
114
134
|
const { keys, types, columnsData, rowCount } = prepared;
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
appender.
|
|
135
|
+
const hasGeometry = types.includes("GEOMETRY('EPSG:4326')");
|
|
136
|
+
const needsConversion = hasGeometry || types.includes("JSON");
|
|
137
|
+
const staged = needsConversion
|
|
138
|
+
? `__sda_array_${crypto.randomUUID().replaceAll("-", "")}`
|
|
139
|
+
: simpleTable.name;
|
|
140
|
+
const storageTypes = types.map((type) => type.startsWith("GEOMETRY") || type === "JSON" ? "VARCHAR" : type);
|
|
141
|
+
if (hasGeometry && !simpleTable.sdb.spatialLoaded) {
|
|
142
|
+
await simpleTable.sdb.customQuery("INSTALL spatial; LOAD spatial; SET geometry_always_xy = true;");
|
|
143
|
+
simpleTable.sdb.spatialLoaded = true;
|
|
144
|
+
}
|
|
145
|
+
try {
|
|
146
|
+
await simpleTable.sdb.customQuery(`CREATE ${needsConversion ? "TEMP" : "OR REPLACE"} TABLE ${(0, quoteIdentifier_js_1.default)(staged)}(${keys.map((key, i) => `${(0, quoteIdentifier_js_1.default)(key)} ${storageTypes[i]}`).join(", ")})`);
|
|
147
|
+
const appender = await simpleTable.connection
|
|
148
|
+
.createAppender(staged);
|
|
149
|
+
try {
|
|
150
|
+
const duckDBTypes = storageTypes.map((d) => (0, parseDuckDBType_js_1.default)(d));
|
|
151
|
+
// The maximum capacity of a DuckDB data chunk is 2048 rows.
|
|
152
|
+
const chunkSize = 2000;
|
|
153
|
+
for (let start = 0; start < rowCount; start += chunkSize) {
|
|
154
|
+
const end = Math.min(start + chunkSize, rowCount);
|
|
155
|
+
const dataChunk = node_api_1.DuckDBDataChunk.create(duckDBTypes, end - start);
|
|
156
|
+
for (let i = 0; i < keys.length; i++) {
|
|
157
|
+
dataChunk.setColumnValues(i, columnsData[i].slice(start, end));
|
|
158
|
+
}
|
|
159
|
+
appender.appendDataChunk(dataChunk);
|
|
160
|
+
}
|
|
161
|
+
appender.flushSync();
|
|
162
|
+
}
|
|
163
|
+
finally {
|
|
164
|
+
appender.closeSync();
|
|
165
|
+
}
|
|
166
|
+
if (!needsConversion)
|
|
167
|
+
return;
|
|
168
|
+
// CTAS is atomic: conversion must finish before the destination is replaced.
|
|
169
|
+
await simpleTable.sdb.customQuery(`CREATE OR REPLACE TABLE ${(0, quoteIdentifier_js_1.default)(simpleTable.name)} AS SELECT ${keys.map((key, i) => types[i].startsWith("GEOMETRY")
|
|
170
|
+
? `${(0, geometryFromJSON_js_1.default)((0, quoteIdentifier_js_1.default)(key))} AS ${(0, quoteIdentifier_js_1.default)(key)}`
|
|
171
|
+
: types[i] === "JSON"
|
|
172
|
+
? `${(0, quoteIdentifier_js_1.default)(key)}::JSON AS ${(0, quoteIdentifier_js_1.default)(key)}`
|
|
173
|
+
: (0, quoteIdentifier_js_1.default)(key)).join(", ")} FROM ${(0, quoteIdentifier_js_1.default)(staged)}`);
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
if (needsConversion) {
|
|
177
|
+
await simpleTable.sdb.customQuery(`DROP TABLE IF EXISTS ${(0, quoteIdentifier_js_1.default)(staged)}`);
|
|
178
|
+
}
|
|
128
179
|
}
|
|
129
|
-
appender.flushSync();
|
|
130
180
|
}
|
|
131
181
|
/** Validates and snapshots a value for an explicitly declared destination type. */
|
|
132
182
|
function prepareTypedValue(value, type, column, row) {
|
|
183
|
+
if (type === "JSON")
|
|
184
|
+
return (0, prepareJSON_js_1.default)(value, column, row);
|
|
185
|
+
if (type === "GEOMETRY('EPSG:4326')") {
|
|
186
|
+
return (0, prepareGeometry_js_1.default)(value, column, row);
|
|
187
|
+
}
|
|
133
188
|
if (value === null || value === undefined || Number.isNaN(value))
|
|
134
189
|
return null;
|
|
135
190
|
let compatible = false;
|
|
@@ -54,6 +54,9 @@ function loadDataQuery(table, files, options = {}) {
|
|
|
54
54
|
return `CREATE OR REPLACE TABLE ${(0, quoteIdentifier_js_1.default)(table)} AS ${loadDataSelect(files, options)};`;
|
|
55
55
|
}
|
|
56
56
|
function loadDataSelect(files, options = {}) {
|
|
57
|
+
if (Object.values(options.columnTypes ?? {}).some((type) => /^\s*geometry\b/i.test(type))) {
|
|
58
|
+
throw new Error("Geometry column types are not supported by loadData(). Use loadGeoData() instead.");
|
|
59
|
+
}
|
|
57
60
|
const fileExtension = (0, getExtension_js_1.default)(files[0]);
|
|
58
61
|
if (options.fileType !== undefined &&
|
|
59
62
|
!["csv", "dsv", "json", "parquet", "excel"].includes(options.fileType)) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/methods/log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAMvD,wBAA8B,GAAG,CAC/B,WAAW,EAAE,WAAW,EACxB,OAAO,GAAE,KAAK,GAAG,MAAM,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CAChB,iBA4EP"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = log;
|
|
7
|
+
const logData_js_1 = __importDefault(require("../helpers/logData.js"));
|
|
8
|
+
const getData_js_1 = __importDefault(require("./getData.js"));
|
|
9
|
+
const quoteIdentifier_js_1 = __importDefault(require("../helpers/quoteIdentifier.js"));
|
|
10
|
+
const formatNumber_js_1 = __importDefault(require("../helpers/formatNumber.js"));
|
|
11
|
+
async function log(simpleTable, options = {}) {
|
|
12
|
+
if (simpleTable.connection === undefined) {
|
|
13
|
+
await simpleTable.sdb.start();
|
|
14
|
+
simpleTable.db = simpleTable.sdb.db;
|
|
15
|
+
simpleTable.connection = simpleTable.sdb.connection;
|
|
16
|
+
}
|
|
17
|
+
if (simpleTable.connection === undefined) {
|
|
18
|
+
throw new Error("simpleTable.connection is undefined");
|
|
19
|
+
}
|
|
20
|
+
let count;
|
|
21
|
+
if (typeof options === "number") {
|
|
22
|
+
count = options;
|
|
23
|
+
}
|
|
24
|
+
else if (options === "all") {
|
|
25
|
+
count = await simpleTable.getRowCount();
|
|
26
|
+
}
|
|
27
|
+
else if (typeof options === "object") {
|
|
28
|
+
if (options.count === "all") {
|
|
29
|
+
count = await simpleTable.getRowCount();
|
|
30
|
+
}
|
|
31
|
+
else if (typeof options.count === "number") {
|
|
32
|
+
count = options.count;
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
count = simpleTable.rowsToLog;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
count = simpleTable.rowsToLog;
|
|
40
|
+
}
|
|
41
|
+
const types = typeof options === "object"
|
|
42
|
+
? options.types ?? simpleTable.typesToLog
|
|
43
|
+
: simpleTable.typesToLog;
|
|
44
|
+
const conditions = typeof options === "object"
|
|
45
|
+
? options.conditions ?? undefined
|
|
46
|
+
: undefined;
|
|
47
|
+
if (simpleTable.connection === undefined ||
|
|
48
|
+
!(await simpleTable.sdb.hasTable(simpleTable.name))) {
|
|
49
|
+
console.log(`\nTable ${simpleTable.name}: no data`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
console.log(`\nTable ${simpleTable.name}:`);
|
|
53
|
+
conditions && console.log(`Conditions: ${conditions}`);
|
|
54
|
+
const data = await (0, getData_js_1.default)(simpleTable, { limit: count, conditions }, "log()");
|
|
55
|
+
(0, logData_js_1.default)(types ? await simpleTable.getTypes() : null, data, simpleTable.charsToLog);
|
|
56
|
+
const rowCount = conditions
|
|
57
|
+
? parseInt((await simpleTable.sdb.customQuery(`select count(*) as count from ${(0, quoteIdentifier_js_1.default)(simpleTable.name)} where ${conditions}`, { returnData: true }))[0].count)
|
|
58
|
+
: await simpleTable.getRowCount();
|
|
59
|
+
const displayedRows = data.length;
|
|
60
|
+
const showing = displayedRows < rowCount
|
|
61
|
+
? ` / showing ${(0, formatNumber_js_1.default)(displayedRows)} rows`
|
|
62
|
+
: "";
|
|
63
|
+
const charsToLog = typeof simpleTable.charsToLog === "number"
|
|
64
|
+
? ` (charsToLog: ${simpleTable.charsToLog})`
|
|
65
|
+
: "";
|
|
66
|
+
console.log(`${(0, formatNumber_js_1.default)(rowCount)} rows in total${showing}${charsToLog}`);
|
|
67
|
+
}
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logBottom.d.ts","sourceRoot":"","sources":["../../src/methods/logBottom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAIvD,wBAA8B,SAAS,CACrC,WAAW,EAAE,WAAW,EACxB,KAAK,CAAC,EAAE,MAAM,EACd,OAAO,GAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAO,iBAW1C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = logBottom;
|
|
7
|
+
const logData_js_1 = __importDefault(require("../helpers/logData.js"));
|
|
8
|
+
const getBottom_js_1 = __importDefault(require("./getBottom.js"));
|
|
9
|
+
async function logBottom(simpleTable, count, options = {}) {
|
|
10
|
+
const rows = count ?? simpleTable.rowsToLog;
|
|
11
|
+
console.log(`\nTable ${simpleTable.name} (${rows} bottom rows):`);
|
|
12
|
+
const data = await (0, getBottom_js_1.default)(simpleTable, rows, options, "logBottom()");
|
|
13
|
+
(0, logData_js_1.default)(null, data, simpleTable.charsToLog);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeTable.d.ts","sourceRoot":"","sources":["../../src/methods/removeTable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"removeTable.d.ts","sourceRoot":"","sources":["../../src/methods/removeTable.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAGvD,wBAA8B,WAAW,CACvC,WAAW,EAAE,WAAW,iBAiBzB"}
|
|
@@ -4,11 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = removeTable;
|
|
7
|
+
const cacheTableDependencies_js_1 = require("../helpers/cacheTableDependencies.js");
|
|
7
8
|
const quoteIdentifier_js_1 = __importDefault(require("../helpers/quoteIdentifier.js"));
|
|
8
9
|
const mergeOptions_js_1 = __importDefault(require("../helpers/mergeOptions.js"));
|
|
9
10
|
const queryDB_js_1 = __importDefault(require("../helpers/queryDB.js"));
|
|
10
11
|
const tableRegistry_js_1 = require("../helpers/tableRegistry.js");
|
|
11
12
|
async function removeTable(simpleTable) {
|
|
13
|
+
(0, cacheTableDependencies_js_1.assertCacheTableMutation)(simpleTable);
|
|
12
14
|
await (0, queryDB_js_1.default)(simpleTable, `DROP TABLE ${(0, quoteIdentifier_js_1.default)(simpleTable.name)};`, (0, mergeOptions_js_1.default)(simpleTable, {
|
|
13
15
|
table: null,
|
|
14
16
|
method: "removeTable()",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeTables.d.ts","sourceRoot":"","sources":["../../src/methods/removeTables.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"removeTables.d.ts","sourceRoot":"","sources":["../../src/methods/removeTables.ts"],"names":[],"mappings":"AAIA,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAIjD,wBAA8B,YAAY,CACxC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,CAAC,WAAW,GAAG,MAAM,CAAC,EAAE,iBA2CxD"}
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = removeTables;
|
|
7
|
+
const cacheTableDependencies_js_1 = require("../helpers/cacheTableDependencies.js");
|
|
7
8
|
const quoteIdentifier_js_1 = __importDefault(require("../helpers/quoteIdentifier.js"));
|
|
8
9
|
const mergeOptions_js_1 = __importDefault(require("../helpers/mergeOptions.js"));
|
|
9
10
|
const queryDB_js_1 = __importDefault(require("../helpers/queryDB.js"));
|
|
@@ -17,6 +18,12 @@ async function removeTables(simpleDB, tables) {
|
|
|
17
18
|
? tables
|
|
18
19
|
: [tables];
|
|
19
20
|
(0, assertSameDatabase_js_1.default)(simpleDB, tablesToBeRemoved.filter((table) => table instanceof SimpleTable_js_1.default), "removeTables()");
|
|
21
|
+
const names = tablesToBeRemoved.map((table) => (table instanceof SimpleTable_js_1.default ? table.name : table).toLowerCase());
|
|
22
|
+
for (const table of simpleDB.getTables()) {
|
|
23
|
+
if (names.includes(table.name.toLowerCase())) {
|
|
24
|
+
(0, cacheTableDependencies_js_1.assertCacheTableMutation)(table);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
20
27
|
await (0, queryDB_js_1.default)(simpleDB, tablesToBeRemoved.map((d) => `DROP TABLE ${(0, quoteIdentifier_js_1.default)(d instanceof SimpleTable_js_1.default ? d.name : d)};`).join("\n"), (0, mergeOptions_js_1.default)(simpleDB, {
|
|
21
28
|
table: null,
|
|
22
29
|
method: "removeTable()",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renameTable.d.ts","sourceRoot":"","sources":["../../src/methods/renameTable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"renameTable.d.ts","sourceRoot":"","sources":["../../src/methods/renameTable.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAIvD,wBAA8B,WAAW,CACvC,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,MAAM,iBAgBb"}
|
|
@@ -4,11 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = renameTable;
|
|
7
|
+
const cacheTableDependencies_js_1 = require("../helpers/cacheTableDependencies.js");
|
|
7
8
|
const quoteIdentifier_js_1 = __importDefault(require("../helpers/quoteIdentifier.js"));
|
|
8
9
|
const mergeOptions_js_1 = __importDefault(require("../helpers/mergeOptions.js"));
|
|
9
10
|
const queryDB_js_1 = __importDefault(require("../helpers/queryDB.js"));
|
|
10
11
|
const tableGeneration_js_1 = require("../helpers/tableGeneration.js");
|
|
12
|
+
const tableRegistry_js_1 = require("../helpers/tableRegistry.js");
|
|
11
13
|
async function renameTable(simpleTable, name) {
|
|
14
|
+
(0, cacheTableDependencies_js_1.assertCacheTableMutation)(simpleTable);
|
|
15
|
+
(0, tableRegistry_js_1.assertTableNameAvailable)(simpleTable.sdb, name, simpleTable);
|
|
12
16
|
await (0, queryDB_js_1.default)(simpleTable, `ALTER TABLE ${(0, quoteIdentifier_js_1.default)(simpleTable.name)} RENAME TO ${(0, quoteIdentifier_js_1.default)(name)};`, (0, mergeOptions_js_1.default)(simpleTable, {
|
|
13
17
|
table: simpleTable.name,
|
|
14
18
|
method: "renameTable()",
|
|
@@ -25,8 +25,8 @@ function rowToText(simpleTable, columns, newColumn) {
|
|
|
25
25
|
throw new Error(`The column ${col} is of type ${allTypes[col]}. The rowToText() method only works with string columns. Please convert the column to string first with the .convert() method.`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
const parts = columns.map((col) =>
|
|
29
|
-
const concatenatedExpression = parts.join("
|
|
28
|
+
const parts = columns.map((col) => `concat(?, COALESCE(${(0, quoteIdentifier_js_1.default)(col)}, ?))`);
|
|
29
|
+
const concatenatedExpression = `concat(${parts.join(", ")})`;
|
|
30
30
|
return `SELECT *, CAST(${concatenatedExpression} AS VARCHAR) AS ${(0, quoteIdentifier_js_1.default)(newColumn)} FROM ${input}`;
|
|
31
31
|
},
|
|
32
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectTables.d.ts","sourceRoot":"","sources":["../../src/methods/selectTables.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"selectTables.d.ts","sourceRoot":"","sources":["../../src/methods/selectTables.ts"],"names":[],"mappings":"AAIA,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAClD,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAKjD,wBAA8B,YAAY,CACxC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,WAAW,GAAG,MAAM,GAAG,CAAC,WAAW,GAAG,MAAM,CAAC,EAAE,iBAqDxD"}
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = selectTables;
|
|
7
|
+
const cacheTableDependencies_js_1 = require("../helpers/cacheTableDependencies.js");
|
|
7
8
|
const quoteIdentifier_js_1 = __importDefault(require("../helpers/quoteIdentifier.js"));
|
|
8
9
|
const mergeOptions_js_1 = __importDefault(require("../helpers/mergeOptions.js"));
|
|
9
10
|
const queryDB_js_1 = __importDefault(require("../helpers/queryDB.js"));
|
|
@@ -15,6 +16,11 @@ async function selectTables(simpleDB, tables) {
|
|
|
15
16
|
const selected = Array.isArray(tables) ? tables : [tables];
|
|
16
17
|
(0, assertSameDatabase_js_1.default)(simpleDB, selected.filter((table) => table instanceof SimpleTable_js_1.default), "selectTables()");
|
|
17
18
|
const tablesToBeSelected = selected.map((t) => t instanceof SimpleTable_js_1.default ? t.name : t);
|
|
19
|
+
for (const table of simpleDB.getTables()) {
|
|
20
|
+
if (!tablesToBeSelected.includes(table.name)) {
|
|
21
|
+
(0, cacheTableDependencies_js_1.assertCacheTableMutation)(table);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
18
24
|
const existingTables = await simpleDB.getTableNames();
|
|
19
25
|
const missingTables = tablesToBeSelected.filter((table) => !existingTables.includes(table));
|
|
20
26
|
if (missingTables.length > 0) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type SimpleTable from "../class/SimpleTable.js";
|
|
2
2
|
export default function setTypes(simpleTable: SimpleTable, types: {
|
|
3
|
-
[key: string]: "integer" | "float" | "number" | "string" | "date" | "time" | "datetime" | "datetimeTz" | "bigint" | "double" | "varchar" | "timestamp" | "timestamp with time zone" | "boolean" | `geometry('${string}')` | `GEOMETRY('${string}')`;
|
|
3
|
+
[key: string]: "integer" | "float" | "number" | "string" | "date" | "time" | "datetime" | "datetimeTz" | "bigint" | "double" | "varchar" | "timestamp" | "timestamp with time zone" | "boolean" | "json" | "JSON" | `float[${number}]` | `FLOAT[${number}]` | `geometry('${string}')` | `GEOMETRY('${string}')`;
|
|
4
4
|
}): void;
|
|
5
5
|
//# sourceMappingURL=setTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setTypes.d.ts","sourceRoot":"","sources":["../../src/methods/setTypes.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAEvD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE;IACL,CAAC,GAAG,EAAE,MAAM,GACR,SAAS,GACT,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,MAAM,GACN,UAAU,GACV,YAAY,GACZ,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,WAAW,GACX,0BAA0B,GAC1B,SAAS,GACT,aAAa,MAAM,IAAI,GACvB,aAAa,MAAM,IAAI,CAAC;CAC7B,QAkCF"}
|
|
1
|
+
{"version":3,"file":"setTypes.d.ts","sourceRoot":"","sources":["../../src/methods/setTypes.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAEvD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE;IACL,CAAC,GAAG,EAAE,MAAM,GACR,SAAS,GACT,OAAO,GACP,QAAQ,GACR,QAAQ,GACR,MAAM,GACN,MAAM,GACN,UAAU,GACV,YAAY,GACZ,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,WAAW,GACX,0BAA0B,GAC1B,SAAS,GACT,MAAM,GACN,MAAM,GACN,SAAS,MAAM,GAAG,GAClB,SAAS,MAAM,GAAG,GAClB,aAAa,MAAM,IAAI,GACvB,aAAa,MAAM,IAAI,CAAC;CAC7B,QAkCF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/methods/stream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/methods/stream.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAGvD,wBAA+B,MAAM,CACnC,WAAW,EAAE,WAAW,EACxB,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;CAChB,GACL,cAAc,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAAE,IAAI,EAAE,SAAS,CAAC,CAsE7D"}
|
package/script/methods/stream.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = stream;
|
|
7
|
+
const cleanSQL_js_1 = __importDefault(require("../helpers/cleanSQL.js"));
|
|
7
8
|
const quoteIdentifier_js_1 = __importDefault(require("../helpers/quoteIdentifier.js"));
|
|
8
9
|
const runQuery_js_1 = require("../helpers/runQuery.js");
|
|
9
10
|
const SDAError_js_1 = __importDefault(require("../class/SDAError.js"));
|
|
@@ -23,7 +24,7 @@ async function* stream(simpleTable, options = {}) {
|
|
|
23
24
|
? [options.columns]
|
|
24
25
|
: options.columns)
|
|
25
26
|
: undefined;
|
|
26
|
-
const query = `SELECT ${columns ? columns.map((d) => `${(0, quoteIdentifier_js_1.default)(d)}`).join(", ") : "*"} FROM ${(0, quoteIdentifier_js_1.default)(simpleTable.name)}${options.conditions ? ` WHERE ${options.conditions}` : ""}
|
|
27
|
+
const query = (0, cleanSQL_js_1.default)(`SELECT ${columns ? columns.map((d) => `${(0, quoteIdentifier_js_1.default)(d)}`).join(", ") : "*"} FROM ${(0, quoteIdentifier_js_1.default)(simpleTable.name)}${options.conditions ? ` WHERE ${options.conditions}` : ""};`, simpleTable.sdb.expressionSyntax);
|
|
27
28
|
try {
|
|
28
29
|
await (0, observeQuery_js_1.default)(simpleTable.connection, query, [], {
|
|
29
30
|
logSQL: simpleTable.sdb.logSQL,
|
|
@@ -3,9 +3,7 @@ type Row = {
|
|
|
3
3
|
[key: string]: unknown;
|
|
4
4
|
};
|
|
5
5
|
type DataModifier = (rows: Row[]) => Row[] | Promise<Row[]>;
|
|
6
|
-
type UpdateWithJSOptions =
|
|
7
|
-
batchSize?: number;
|
|
8
|
-
};
|
|
6
|
+
type UpdateWithJSOptions = NonNullable<Parameters<SimpleTable["updateWithJS"]>[1]>;
|
|
9
7
|
export default function updateWithJS(simpleTable: SimpleTable, dataModifier: DataModifier, options?: UpdateWithJSOptions): void;
|
|
10
8
|
export {};
|
|
11
9
|
//# sourceMappingURL=updateWithJS.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateWithJS.d.ts","sourceRoot":"","sources":["../../src/methods/updateWithJS.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"updateWithJS.d.ts","sourceRoot":"","sources":["../../src/methods/updateWithJS.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAQvD,KAAK,GAAG,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAEtC,KAAK,YAAY,GAAG,CAClB,IAAI,EAAE,GAAG,EAAE,KACR,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAE5B,KAAK,mBAAmB,GAAG,WAAW,CACpC,UAAU,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAC3C,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,YAAY,EAC1B,OAAO,GAAE,mBAAwB,GAChC,IAAI,CAeN"}
|