@itwin/core-backend 5.15.0 → 5.16.0-dev.10
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/CHANGELOG.md +8 -1
- package/lib/cjs/ConcurrentQuery.d.ts +4 -0
- package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
- package/lib/cjs/ConcurrentQuery.js +28 -1
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +5 -10
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSqlRowExecutor.d.ts +39 -55
- package/lib/cjs/ECSqlRowExecutor.d.ts.map +1 -1
- package/lib/cjs/ECSqlRowExecutor.js +118 -140
- package/lib/cjs/ECSqlRowExecutor.js.map +1 -1
- package/lib/cjs/ECSqlSyncReader.d.ts +21 -8
- package/lib/cjs/ECSqlSyncReader.d.ts.map +1 -1
- package/lib/cjs/ECSqlSyncReader.js +67 -25
- package/lib/cjs/ECSqlSyncReader.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +5 -10
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +7 -0
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +1 -0
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/SQLiteDb.d.ts +52 -5
- package/lib/cjs/SQLiteDb.d.ts.map +1 -1
- package/lib/cjs/SQLiteDb.js +40 -5
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +11 -6
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/internal/ChangesetConflictArgs.d.ts +4 -0
- package/lib/cjs/internal/ChangesetConflictArgs.d.ts.map +1 -1
- package/lib/cjs/internal/ChangesetConflictArgs.js +1 -0
- package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -1
- package/lib/cjs/internal/QueryMetadataCache.d.ts +8 -0
- package/lib/cjs/internal/QueryMetadataCache.d.ts.map +1 -1
- package/lib/cjs/internal/QueryMetadataCache.js +23 -0
- package/lib/cjs/internal/QueryMetadataCache.js.map +1 -1
- package/lib/esm/ConcurrentQuery.d.ts +4 -0
- package/lib/esm/ConcurrentQuery.d.ts.map +1 -1
- package/lib/esm/ConcurrentQuery.js +29 -2
- package/lib/esm/ConcurrentQuery.js.map +1 -1
- package/lib/esm/ECDb.d.ts.map +1 -1
- package/lib/esm/ECDb.js +6 -11
- package/lib/esm/ECDb.js.map +1 -1
- package/lib/esm/ECSqlRowExecutor.d.ts +39 -55
- package/lib/esm/ECSqlRowExecutor.d.ts.map +1 -1
- package/lib/esm/ECSqlRowExecutor.js +119 -140
- package/lib/esm/ECSqlRowExecutor.js.map +1 -1
- package/lib/esm/ECSqlSyncReader.d.ts +21 -8
- package/lib/esm/ECSqlSyncReader.d.ts.map +1 -1
- package/lib/esm/ECSqlSyncReader.js +68 -26
- package/lib/esm/ECSqlSyncReader.js.map +1 -1
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +6 -11
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/IModelHost.d.ts +7 -0
- package/lib/esm/IModelHost.d.ts.map +1 -1
- package/lib/esm/IModelHost.js +1 -0
- package/lib/esm/IModelHost.js.map +1 -1
- package/lib/esm/SQLiteDb.d.ts +52 -5
- package/lib/esm/SQLiteDb.d.ts.map +1 -1
- package/lib/esm/SQLiteDb.js +40 -5
- package/lib/esm/SQLiteDb.js.map +1 -1
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +12 -7
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/internal/ChangesetConflictArgs.d.ts +4 -0
- package/lib/esm/internal/ChangesetConflictArgs.d.ts.map +1 -1
- package/lib/esm/internal/ChangesetConflictArgs.js +1 -0
- package/lib/esm/internal/ChangesetConflictArgs.js.map +1 -1
- package/lib/esm/internal/QueryMetadataCache.d.ts +8 -0
- package/lib/esm/internal/QueryMetadataCache.d.ts.map +1 -1
- package/lib/esm/internal/QueryMetadataCache.js +23 -0
- package/lib/esm/internal/QueryMetadataCache.js.map +1 -1
- package/lib/esm/test/IModelHost.test.js +103 -2
- package/lib/esm/test/IModelHost.test.js.map +1 -1
- package/lib/esm/test/ecdb/CTE.test.js +21 -0
- package/lib/esm/test/ecdb/CTE.test.js.map +1 -1
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js +72 -0
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
- package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js +51 -9
- package/lib/esm/test/ecdb/ConcurrentQueryLoad.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlQuery.test.js +2 -1
- package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlSyncReader.test.js +338 -84
- package/lib/esm/test/ecdb/ECSqlSyncReader.test.js.map +1 -1
- package/lib/esm/test/ecdb/QueryMetadataCache.test.js +40 -4
- package/lib/esm/test/ecdb/QueryMetadataCache.test.js.map +1 -1
- package/lib/esm/test/ecdb/QueryReaders.test.js +14 -7
- package/lib/esm/test/ecdb/QueryReaders.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangeMerge.test.js +71 -1
- package/lib/esm/test/standalone/ChangeMerge.test.js.map +1 -1
- package/lib/esm/test/standalone/IModelWrite.test.js +6 -2
- package/lib/esm/test/standalone/IModelWrite.test.js.map +1 -1
- package/lib/esm/test/standalone/MergeConflict.test.js +15 -0
- package/lib/esm/test/standalone/MergeConflict.test.js.map +1 -1
- package/lib/esm/test/standalone/SQLiteDb.test.d.ts.map +1 -1
- package/lib/esm/test/standalone/SQLiteDb.test.js +422 -1
- package/lib/esm/test/standalone/SQLiteDb.test.js.map +1 -1
- package/package.json +16 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Change Log - @itwin/core-backend
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Mon, 09 Nov 2026 16:53:07 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 5.15.1
|
|
6
|
+
Mon, 09 Nov 2026 16:52:11 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- Expose raw SQLite changeset apply flags, a no-local-changes conflict policy, and custom conflict handlers through SQLiteDb.applyChangeset.
|
|
4
11
|
|
|
5
12
|
## 5.15.0
|
|
6
13
|
Thu, 05 Nov 2026 17:47:36 GMT
|
|
@@ -4,6 +4,10 @@ import { DbBlobRequest, DbBlobResponse, DbQueryConfig, DbQueryRequest, DbQueryRe
|
|
|
4
4
|
export type OnResponse = (response: Response) => void;
|
|
5
5
|
/** @internal */
|
|
6
6
|
export declare class ConcurrentQuery {
|
|
7
|
+
/** Executes a primary-connection request whose native callback completes on the caller's thread.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
static executePrimaryQueryRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbQueryRequest): DbQueryResponse;
|
|
7
11
|
/** @internal */
|
|
8
12
|
static executeQueryRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbQueryRequest): Promise<DbQueryResponse>;
|
|
9
13
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConcurrentQuery.d.ts","sourceRoot":"","sources":["../../src/ConcurrentQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK1D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"ConcurrentQuery.d.ts","sourceRoot":"","sources":["../../src/ConcurrentQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK1D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAA6C,MAAM,oBAAoB,CAAC;AAS9J,gBAAgB;AAChB,MAAM,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;AAEtD,gBAAgB;AAChB,qBAAa,eAAe;IAC1B;;OAEG;WACW,0BAA0B,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,GAAG,eAAe;IAkBpI,gBAAgB;WACI,mBAAmB,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAS5I,gBAAgB;WACI,kBAAkB,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;WAQ3H,WAAW,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,aAAa;WAGpG,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK;CAGxE"}
|
|
@@ -6,13 +6,40 @@ exports.ConcurrentQuery = void 0;
|
|
|
6
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
7
|
*--------------------------------------------------------------------------------------------*/
|
|
8
8
|
const core_common_1 = require("@itwin/core-common");
|
|
9
|
+
const IModelHost_1 = require("./IModelHost");
|
|
10
|
+
function isQueryResponse(response) {
|
|
11
|
+
return "meta" in response && Array.isArray(response.meta) &&
|
|
12
|
+
"data" in response && Array.isArray(response.data) &&
|
|
13
|
+
"rowCount" in response && typeof response.rowCount === "number";
|
|
14
|
+
}
|
|
9
15
|
/** @internal */
|
|
10
16
|
class ConcurrentQuery {
|
|
17
|
+
/** Executes a primary-connection request whose native callback completes on the caller's thread.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
static executePrimaryQueryRequest(conn, request) {
|
|
21
|
+
if (request.usePrimaryConn !== true)
|
|
22
|
+
throw new Error("A synchronous concurrent query request must use the primary connection");
|
|
23
|
+
request.kind = core_common_1.DbRequestKind.ECSql;
|
|
24
|
+
let response;
|
|
25
|
+
const nativeRequest = { ...request, collectCloudSqliteStats: IModelHost_1.IModelHost.configuration?.collectCloudSqliteStats === true };
|
|
26
|
+
conn.concurrentQueryExecute(nativeRequest, (value) => {
|
|
27
|
+
response = value;
|
|
28
|
+
});
|
|
29
|
+
if (response === undefined)
|
|
30
|
+
throw new Error("Primary-connection query did not complete synchronously");
|
|
31
|
+
if (response.kind === core_common_1.DbResponseKind.NoResult)
|
|
32
|
+
return { ...response, meta: [], data: [], rowCount: 0 };
|
|
33
|
+
if (!isQueryResponse(response))
|
|
34
|
+
throw new Error("Primary-connection query returned an invalid response");
|
|
35
|
+
return response;
|
|
36
|
+
}
|
|
11
37
|
/** @internal */
|
|
12
38
|
static async executeQueryRequest(conn, request) {
|
|
13
39
|
return new Promise((resolve) => {
|
|
14
40
|
request.kind = core_common_1.DbRequestKind.ECSql;
|
|
15
|
-
|
|
41
|
+
const nativeRequest = { ...request, collectCloudSqliteStats: IModelHost_1.IModelHost.configuration?.collectCloudSqliteStats === true };
|
|
42
|
+
conn.concurrentQueryExecute(nativeRequest, (response) => {
|
|
16
43
|
resolve(response);
|
|
17
44
|
});
|
|
18
45
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConcurrentQuery.js","sourceRoot":"","sources":["../../src/ConcurrentQuery.ts"],"names":[],"mappings":";;;AACA;;;+FAG+F;AAC/F,
|
|
1
|
+
{"version":3,"file":"ConcurrentQuery.js","sourceRoot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C,uDAAuD,CAAC,CAAC;QAC3E,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAgD,EAAE,OAAuB;QAC/G,OAAO,IAAI,OAAO,CAAkB,CAAC,OAAO,EAAE,EAAE;YAC9C,OAAO,CAAC,IAAI,GAAG,2BAAa,CAAC,KAAK,CAAC;YACnC,MAAM,aAAa,GAAG,EAAE,GAAG,OAAO,EAAE,uBAAuB,EAAE,uBAAU,CAAC,aAAa,EAAE,uBAAuB,KAAK,IAAI,EAAE,CAAC;YAC1H,IAAI,CAAC,sBAAsB,CAAC,aAAa,EAAE,CAAC,QAAa,EAAE,EAAE;gBAC3D,OAAO,CAAC,QAA2B,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IACD,gBAAgB;IACT,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAgD,EAAE,OAAsB;QAC7G,OAAO,IAAI,OAAO,CAAiB,CAAC,OAAO,EAAE,EAAE;YAC7C,OAAO,CAAC,IAAI,GAAG,2BAAa,CAAC,MAAM,CAAC;YACpC,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,CAAC,QAAa,EAAE,EAAE;gBACrD,OAAO,CAAC,QAA0B,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IACM,MAAM,CAAC,WAAW,CAAC,IAAgD,EAAE,MAAsB;QAChG,OAAO,IAAI,CAAC,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IACM,MAAM,CAAC,QAAQ,CAAC,IAAgD;QACrE,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;CACF;AA/CD,0CA+CC","sourcesContent":["import { IModelJsNative } from \"@bentley/imodeljs-native\";\r\n/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { DbBlobRequest, DbBlobResponse, DbQueryConfig, DbQueryRequest, DbQueryResponse, DbRequestKind, DbResponse, DbResponseKind } from \"@itwin/core-common\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\nfunction isQueryResponse(response: DbResponse): response is DbQueryResponse {\r\n return \"meta\" in response && Array.isArray(response.meta) &&\r\n \"data\" in response && Array.isArray(response.data) &&\r\n \"rowCount\" in response && typeof response.rowCount === \"number\";\r\n}\r\n\r\n/** @internal */\r\nexport type OnResponse = (response: Response) => void;\r\n\r\n/** @internal */\r\nexport class ConcurrentQuery {\r\n /** Executes a primary-connection request whose native callback completes on the caller's thread.\r\n * @internal\r\n */\r\n public static executePrimaryQueryRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbQueryRequest): DbQueryResponse {\r\n if (request.usePrimaryConn !== true)\r\n throw new Error(\"A synchronous concurrent query request must use the primary connection\");\r\n request.kind = DbRequestKind.ECSql;\r\n let response: DbResponse | undefined;\r\n const nativeRequest = { ...request, collectCloudSqliteStats: IModelHost.configuration?.collectCloudSqliteStats === true };\r\n conn.concurrentQueryExecute(nativeRequest, (value) => {\r\n response = value;\r\n });\r\n if (response === undefined)\r\n throw new Error(\"Primary-connection query did not complete synchronously\");\r\n if (response.kind === DbResponseKind.NoResult)\r\n return { ...response, meta: [], data: [], rowCount: 0 };\r\n if (!isQueryResponse(response))\r\n throw new Error(\"Primary-connection query returned an invalid response\");\r\n return response;\r\n }\r\n\r\n /** @internal */\r\n public static async executeQueryRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbQueryRequest): Promise<DbQueryResponse> {\r\n return new Promise<DbQueryResponse>((resolve) => {\r\n request.kind = DbRequestKind.ECSql;\r\n const nativeRequest = { ...request, collectCloudSqliteStats: IModelHost.configuration?.collectCloudSqliteStats === true };\r\n conn.concurrentQueryExecute(nativeRequest, (response: any) => {\r\n resolve(response as DbQueryResponse);\r\n });\r\n });\r\n }\r\n /** @internal */\r\n public static async executeBlobRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbBlobRequest): Promise<DbBlobResponse> {\r\n return new Promise<DbBlobResponse>((resolve) => {\r\n request.kind = DbRequestKind.BlobIO;\r\n conn.concurrentQueryExecute(request, (response: any) => {\r\n resolve(response as DbBlobResponse);\r\n });\r\n });\r\n }\r\n public static resetConfig(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, config?: DbQueryConfig): DbQueryConfig {\r\n return conn.concurrentQueryResetConfig(config);\r\n }\r\n public static shutdown(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb) {\r\n conn.concurrentQueryShutdown();\r\n }\r\n}\r\n"]}
|
package/lib/cjs/ECDb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECDb.d.ts","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAU,OAAO,EAA8B,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"ECDb.d.ts","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAU,OAAO,EAA8B,MAAM,qBAAqB,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAmC,aAAa,EAAE,WAAW,EAAe,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIzI,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAkB,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,OAAO,EAAE,eAAe,EAAE,uBAAuB,E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"}
|
package/lib/cjs/ECDb.js
CHANGED
|
@@ -498,9 +498,9 @@ class ECDb {
|
|
|
498
498
|
throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR_NOTOPEN, "db not open");
|
|
499
499
|
}
|
|
500
500
|
const executor = {
|
|
501
|
-
execute:
|
|
502
|
-
|
|
503
|
-
|
|
501
|
+
execute: (request) => request.usePrimaryConn === true
|
|
502
|
+
? this._queryMetadataCache.executeCachedPrimaryQueryRequest(request, (req) => ConcurrentQuery_1.ConcurrentQuery.executePrimaryQueryRequest(this[Symbols_1._nativeDb], req))
|
|
503
|
+
: this._queryMetadataCache.executeCachedQueryRequest(request, async (req) => ConcurrentQuery_1.ConcurrentQuery.executeQueryRequest(this[Symbols_1._nativeDb], req)),
|
|
504
504
|
};
|
|
505
505
|
return new core_common_1.ECSqlReader(executor, ecsql, params, config);
|
|
506
506
|
}
|
|
@@ -524,13 +524,8 @@ class ECDb {
|
|
|
524
524
|
withQueryReader(ecsql, callback, params, config) {
|
|
525
525
|
if (!this[Symbols_1._nativeDb].isOpen())
|
|
526
526
|
throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR_NOTOPEN, "db not open");
|
|
527
|
-
|
|
528
|
-
const
|
|
529
|
-
const executor = new ECSqlRowExecutor_1.ECSqlRowExecutor(this, stmt, loggerCategory);
|
|
530
|
-
const release = () => {
|
|
531
|
-
executor[Symbol.dispose]();
|
|
532
|
-
(0, ECSqlRowExecutor_1.releaseECSqlStatement)(stmt, this._statementCache, loggerCategory, executor.canCacheStatement);
|
|
533
|
-
};
|
|
527
|
+
const executor = new ECSqlRowExecutor_1.ECSqlRowExecutor(this);
|
|
528
|
+
const release = () => executor[Symbol.dispose]();
|
|
534
529
|
try {
|
|
535
530
|
const reader = new ECSqlSyncReader_1.ECSqlSyncReader(executor, ecsql, params, config);
|
|
536
531
|
const val = callback(reader);
|
package/lib/cjs/ECDb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|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AC;YAClB,OAAO,EAAE,CAAC;YACV,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AAlgBD,oBAkgBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ECDb\r\n */\r\nimport { assert, BeEvent, DbResult, Logger, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { DbQueryRequest, ECSchemaProps, ECSqlReader, IModelError, QueryBinder, QueryOptions } from \"@itwin/core-common\";\r\nimport { serialize } from \"node:v8\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { ConcurrentQuery } from \"./ConcurrentQuery\";\r\nimport { ECSqlStatement, ECSqlWriteStatement } from \"./ECSqlStatement\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\nimport { _nativeDb } from \"./internal/Symbols\";\r\nimport { QueryMetadataCache } from \"./internal/QueryMetadataCache\";\r\nimport { ECSqlRowExecutor, releaseECSqlStatement } from \"./ECSqlRowExecutor\";\r\nimport { ECSqlSyncReader, SynchronousQueryOptions } from \"./ECSqlSyncReader\";\r\n\r\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\r\n\r\n/** Maps a zero-based CSV column to an EC property.\r\n * @beta\r\n */\r\nexport interface CSVColumnMapping {\r\n /** Zero-based index of the source CSV column. */\r\n columnIndex: number;\r\n /** EC property access string to receive the column value. */\r\n propertyName: string;\r\n}\r\n\r\n/** Common options for importing CSV data into an ECClass.\r\n * @beta\r\n */\r\nexport interface CSVImportOptions {\r\n /** Full name or ECSQL name of the ECClass to insert. */\r\n className: string;\r\n /** Source-column to EC-property mappings. Unmapped source columns are ignored. */\r\n mapping: readonly CSVColumnMapping[];\r\n /** Exact CSV value to bind as null. By default, every field is treated as a value. */\r\n nullValue?: string;\r\n}\r\n\r\n/** Options for [[ECDb.importCSVFile]].\r\n * @beta\r\n */\r\nexport interface CSVFileImportOptions extends CSVImportOptions {\r\n /** Whether the first CSV row is a header to skip. Defaults to false. */\r\n hasHeader?: boolean;\r\n}\r\n\r\nfunction validateCSVMapping(mapping: readonly CSVColumnMapping[]): void {\r\n if (0 === mapping.length)\r\n throw new TypeError(\"mapping must not be empty\");\r\n\r\n const columnIndexes = new Set<number>();\r\n for (const entry of mapping) {\r\n if (undefined === entry || null === entry || \"object\" !== typeof entry)\r\n throw new TypeError(\"mapping must contain only objects\");\r\n if (!Number.isSafeInteger(entry.columnIndex) || entry.columnIndex < 0 || entry.columnIndex >= 0xffff_ffff)\r\n throw new TypeError(\"mapping columnIndex values must be non-negative safe integers\");\r\n if (\"string\" !== typeof entry.propertyName || 0 === entry.propertyName.length)\r\n throw new TypeError(\"mapping propertyName values must not be empty\");\r\n if (columnIndexes.has(entry.columnIndex))\r\n throw new TypeError(\"mapping must not contain duplicate columnIndex values\");\r\n columnIndexes.add(entry.columnIndex);\r\n }\r\n}\r\n\r\n/** Modes for how to open [ECDb]($backend) files.\r\n * @public\r\n */\r\nexport enum ECDbOpenMode {\r\n Readonly,\r\n ReadWrite,\r\n /** Opens the file read-write and upgrades the file if necessary to the latest file format version. */\r\n FileUpgrade,\r\n}\r\n\r\n/** An ECDb file\r\n * @public\r\n */\r\nexport class ECDb implements Disposable {\r\n private _nativeDb?: IModelJsNative.ECDb;\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n private readonly _statementCache = new StatementCache<ECSqlStatement>();\r\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\r\n private readonly _queryMetadataCache = new QueryMetadataCache();\r\n\r\n /** Event called when the ECDb is about to be closed. */\r\n public readonly onBeforeClose = new BeEvent<() => void>();\r\n\r\n /** only for tests\r\n * @internal\r\n */\r\n public resetSqliteCache(size: number) {\r\n this._sqliteStatementCache.clear();\r\n this._sqliteStatementCache = new StatementCache<SqliteStatement>(size);\r\n }\r\n\r\n constructor() {\r\n this._nativeDb = new IModelNative.platform.ECDb();\r\n }\r\n /** Call this function when finished with this ECDb object. This releases the native resources held by the\r\n * ECDb object.\r\n */\r\n public [Symbol.dispose](): void {\r\n if (!this._nativeDb)\r\n return;\r\n\r\n this.closeDb();\r\n this._nativeDb.dispose();\r\n this._nativeDb = undefined;\r\n }\r\n /**\r\n * Attach an iModel file to this connection and load and register its schemas.\r\n * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'\r\n * @param fileName IModel file name\r\n * @param alias identifier for the attached file. This identifer is used to access schema from the attached file. e.g. if alias is 'abc' then schema can be accessed using 'abc.MySchema.MyClass'\r\n */\r\n public attachDb(fileName: string, alias: string): void {\r\n if (alias.toLowerCase() === \"main\" || alias.toLowerCase() === \"schema_sync_db\" || alias.toLowerCase() === \"ecchange\" || alias.toLowerCase() === \"temp\") {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Reserved tablespace name cannot be used\");\r\n }\r\n this[_nativeDb].attachDb(fileName, alias);\r\n }\r\n /**\r\n * Detach the attached file from this connection. The attached file is closed and its schemas are unregistered.\r\n * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'\r\n * @param alias identifer that was used in the call to [[attachDb]]\r\n */\r\n public detachDb(alias: string): void {\r\n if (alias.toLowerCase() === \"main\" || alias.toLowerCase() === \"schema_sync_db\" || alias.toLowerCase() === \"ecchange\" || alias.toLowerCase() === \"temp\") {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Reserved tablespace name cannot be used\");\r\n }\r\n this.clearCaches();\r\n this[_nativeDb].detachDb(alias);\r\n }\r\n\r\n /** @deprecated in 5.0 - might be removed in next major version. Use [Symbol.dispose] instead. */\r\n public dispose(): void {\r\n this[Symbol.dispose]();\r\n }\r\n\r\n /** Create an ECDb\r\n * @param pathName The path to the ECDb file to create.\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public createDb(pathName: string): void {\r\n const status: DbResult = this[_nativeDb].createDb(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to created ECDb\");\r\n }\r\n\r\n /** Open the ECDb.\r\n * @param pathName The path to the ECDb file to open\r\n * @param openMode Open mode\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\r\n const nativeOpenMode: OpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\r\n const tryUpgrade: boolean = openMode === ECDbOpenMode.FileUpgrade;\r\n const status: DbResult = this[_nativeDb].openDb(pathName, nativeOpenMode, tryUpgrade);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to open ECDb\");\r\n }\r\n\r\n /** Returns true if the ECDb is open */\r\n public get isOpen(): boolean { return this[_nativeDb].isOpen(); }\r\n\r\n /** Close the Db after saving any uncommitted changes.\r\n * @throws [IModelError]($common) if the database is not open.\r\n */\r\n public closeDb(): void {\r\n this.onBeforeClose.raiseEvent();\r\n this.clearCaches();\r\n this[_nativeDb].closeDb();\r\n }\r\n\r\n /** Clear all in-memory caches held in this ECDb.\r\n * @beta\r\n */\r\n public clearCaches(): void {\r\n this._queryMetadataCache.clear();\r\n this._statementCache.clear();\r\n this._sqliteStatementCache.clear();\r\n this[_nativeDb].clearECDbCache();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public clearStatementCache() {\r\n this._statementCache.clear();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public getCachedStatementCount() {\r\n return this._statementCache.size;\r\n }\r\n\r\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction.\r\n * @param changesetName The name of the operation that generated these changes.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public saveChanges(changesetName?: string): void {\r\n const status: DbResult = this[_nativeDb].saveChanges(changesetName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to save changes\");\r\n }\r\n\r\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public abandonChanges(): void {\r\n const status: DbResult = this[_nativeDb].abandonChanges();\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to abandon changes\");\r\n }\r\n\r\n /** Import a schema.\r\n *\r\n * If the import was successful, the database is automatically saved to disk.\r\n * @param pathName Path to ECSchema XML file to import.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public importSchema(pathName: string): void {\r\n const status: DbResult = this[_nativeDb].importSchema(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK) {\r\n Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);\r\n throw new IModelError(status, `Failed to import schema from '${pathName}'.`);\r\n }\r\n this.clearCaches();\r\n }\r\n\r\n /** Removes unused schemas from the database.\r\n *\r\n * If the removal was successful, the database is automatically saved to disk.\r\n * @param schemaNames Array of schema names to drop\r\n * @throws [IModelError]($common) if the database if the operation failed.\r\n * @alpha\r\n */\r\n public dropSchemas(schemaNames: string[]): void {\r\n if (schemaNames.length === 0)\r\n return;\r\n // SchemaSync.isEnabled() should be used, but ECDb is not an iModelDb so it has no container props\r\n if (this[_nativeDb].schemaSyncEnabled())\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Cannot drop schemas when schema sync is enabled\");\r\n\r\n try {\r\n this[_nativeDb].dropSchemas(schemaNames);\r\n this.saveChanges('dropped unused schemas');\r\n } catch (error: any) {\r\n Logger.logError(loggerCategory, `Failed to drop schemas: ${error}`);\r\n this.abandonChanges();\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Failed to drop schemas: ${error}`);\r\n } finally {\r\n this.clearCaches();\r\n }\r\n }\r\n\r\n /**\r\n * Returns the full schema for the input name.\r\n * @param name The name of the schema e.g. 'ECDbMeta'\r\n * @returns The SchemaProps for the requested schema\r\n * @throws if the schema can not be found or loaded.\r\n */\r\n public getSchemaProps(name: string): ECSchemaProps {\r\n return this[_nativeDb].getSchemaProps(name);\r\n }\r\n\r\n /** Import in-memory CSV rows into an ECClass.\r\n *\r\n * The rows are V8-serialized and processed in one native call. Values are converted from\r\n * their CSV string representation according to the mapped EC property type. One ECSQL\r\n * statement is reused for all rows. Every row must have the same number of columns.\r\n * Boolean fields accept `true`, `false`, `1`, or `0`. Integer fields must contain a\r\n * base-10 value in the signed 32-bit range. Boolean, double, integer, and string EC\r\n * properties are supported. The import is all-or-nothing and callers must call\r\n * [[saveChanges]] to commit it to disk.\r\n * @returns The number of imported rows.\r\n * @beta\r\n */\r\n public importCSVData(rows: readonly (readonly string[])[], options: CSVImportOptions): number {\r\n validateCSVMapping(options.mapping);\r\n return this[_nativeDb].importCSVData(options.className, serialize(rows), options.mapping, { nullValue: options.nullValue });\r\n }\r\n\r\n /** Stream a CSV file into an ECClass.\r\n *\r\n * The file must be UTF-8 encoded; an optional UTF-8 byte-order mark is accepted. It is read\r\n * and parsed in native code, and one ECSQL statement is reused for all rows. Every record must\r\n * have the same number of columns; blank records are not skipped. Boolean fields accept\r\n * `true`, `false`, `1`, or `0`. Integer fields must contain a base-10 value in the signed\r\n * 32-bit range. Boolean, double, integer, and string EC properties are supported. The import\r\n * is all-or-nothing and callers must call [[saveChanges]] to commit it to disk.\r\n * @returns The number of imported rows, excluding an optional header.\r\n * @beta\r\n */\r\n public importCSVFile(csvFilePath: string, options: CSVFileImportOptions): number {\r\n validateCSVMapping(options.mapping);\r\n return this[_nativeDb].importCSVFile(options.className, csvFilePath, options.mapping, {\r\n hasHeader: options.hasHeader,\r\n nullValue: options.nullValue,\r\n });\r\n }\r\n\r\n /**\r\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withWriteStatement]]\r\n * @beta\r\n */\r\n public withCachedWriteStatement<T>(ecsql: string, callback: (stmt: ECSqlWriteStatement) => T, logErrors = true): T {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\r\n const release = () => this._statementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(new ECSqlWriteStatement(stmt));\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\r\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withCachedWriteStatement]]\r\n * @beta\r\n */\r\n public withWriteStatement<T>(ecsql: string, callback: (stmt: ECSqlWriteStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareWriteStatement(ecsql, logErrors);\r\n const release = () => stmt[Symbol.dispose]();\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an ECSQL statement.\r\n * @param ecsql The ECSQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @beta\r\n */\r\n public prepareWriteStatement(ecsql: string, logErrors = true): ECSqlWriteStatement {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return new ECSqlWriteStatement(this.prepareStatement(ecsql, logErrors));\r\n }\r\n\r\n /**\r\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withStatement]]\r\n * @public\r\n * @deprecated in 4.11 - might be removed in next major version. Use [[createQueryReader]] for SELECT statements and [[withCachedWriteStatement]] for INSERT/UPDATE/DELETE instead.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\r\n const release = () => this._statementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\r\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n * @deprecated in 4.11 - might be removed in next major version. Use [[createQueryReader]] for SELECT statements and [[withWriteStatement]] for INSERT/UPDATE/DELETE instead.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this.prepareStatement(ecsql, logErrors);\r\n const release = () => stmt[Symbol.dispose]();\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an ECSQL statement.\r\n * @param ecsql The ECSQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @deprecated in 4.11 - might be removed in next major version. Use [[prepareWriteStatement]] when preparing an INSERT/UPDATE/DELETE statement or [[createQueryReader]] to execute a SELECT statement.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public prepareStatement(ecsql: string, logErrors = true): ECSqlStatement {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = new ECSqlStatement();\r\n stmt.prepare(this[_nativeDb], ecsql, logErrors);\r\n return stmt;\r\n }\r\n\r\n /**\r\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n */\r\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\r\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @public\r\n */\r\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => stmt[Symbol.dispose]();\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an SQL statement.\r\n * @param sql The SQLite SQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @internal\r\n */\r\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\r\n const stmt = new SqliteStatement(sql);\r\n stmt.prepare(this[_nativeDb], logErrors);\r\n return stmt;\r\n }\r\n\r\n /** @internal */\r\n public get [_nativeDb](): IModelJsNative.ECDb {\r\n assert(undefined !== this._nativeDb);\r\n return this._nativeDb;\r\n }\r\n\r\n /** Creates a reader for asynchronous ECSQL query execution.\r\n * Execution starts when the reader is consumed using asynchronous iteration or awaited calls to `step()` or `toArray()`.\r\n * Results are fetched and buffered in batches. For synchronous, callback-scoped execution, use [[withQueryReader]].\r\n *\r\n * See also:\r\n * - [Choosing a query reader]($docs/learning/backend/ExecutingECSQL)\r\n * - [Asynchronous query examples]($docs/learning/ECSQLCodeExamples)\r\n * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)\r\n *\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param config Allow to specify certain flags which control how query is executed.\r\n * @returns Returns an [ECSqlReader]($common) which helps iterate over the result set and also give access to metadata.\r\n * @public\r\n * */\r\n public createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader {\r\n if (!this._nativeDb || !this._nativeDb.isOpen()) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR_NOTOPEN, \"db not open\");\r\n }\r\n const executor = {\r\n execute: async (request: DbQueryRequest) => {\r\n return this._queryMetadataCache.executeCachedQueryRequest(request, async (req) => ConcurrentQuery.executeQueryRequest(this[_nativeDb], req));\r\n },\r\n };\r\n return new ECSqlReader(executor, ecsql, params, config);\r\n }\r\n\r\n /** Executes a callback with a synchronous ECSQL reader on the owning database connection.\r\n * The reader steps one row at a time without buffering result batches. Finish using it before the callback completes.\r\n * Return materialized rows or computed values rather than the reader. For asynchronous execution, use [[createQueryReader]].\r\n * The prepared statement may be reused from the statement cache between completed calls.\r\n *\r\n * See also:\r\n * - [Choosing a query reader]($docs/learning/backend/ExecutingECSQL)\r\n * - [Synchronous query examples]($docs/learning/backend/WithQueryReaderCodeExamples)\r\n * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)\r\n * @param ecsql The ECSQL query to execute.\r\n * @param callback the callback to invoke on the prepared ECSqlSyncReader\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param config Optional flags which control how query is executed.\r\n * @returns the value returned by `callback`.\r\n * @throws IModelError if db is not open or if error occurs during statement execution\r\n * @beta\r\n * */\r\n public withQueryReader<T>(ecsql: string, callback: (reader: ECSqlSyncReader) => T, params?: QueryBinder, config?: SynchronousQueryOptions): T {\r\n if (!this[_nativeDb].isOpen())\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR_NOTOPEN, \"db not open\");\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? new ECSqlStatement();\r\n const executor = new ECSqlRowExecutor(this, stmt, loggerCategory);\r\n const release = () => {\r\n executor[Symbol.dispose]();\r\n releaseECSqlStatement(stmt, this._statementCache, loggerCategory, executor.canCacheStatement);\r\n };\r\n try {\r\n const reader = new ECSqlSyncReader(executor, ecsql, params, config);\r\n const val = callback(reader);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err: any) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ECDb.js","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAkF;AAElF,oDAAyI;AACzI,qCAAoC;AACpC,mEAAgE;AAChE,uDAAoD;AACpD,qDAAuE;AACvE,8DAAyD;AACzD,uDAAoE;AACpE,gDAA+C;AAC/C,sEAAmE;AACnE,yDAAsD;AACtD,uDAA6E;AAE7E,MAAM,cAAc,GAAW,6CAAqB,CAAC,IAAI,CAAC;AAgC1D,SAAS,kBAAkB,CAAC,OAAoC;IAC9D,IAAI,CAAC,KAAK,OAAO,CAAC,MAAM;QACtB,MAAM,IAAI,SAAS,CAAC,2BAA2B,CAAC,CAAC;IAEnD,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IACxC,KAAK,MAAM,KAA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MAAM,IAAI,yBAAW,CAAC,uBAAQ,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC;QAEzE,MAAM,QAAQ,GAAG,IAAI,mCAAgB,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QACjD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,iCAAe,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;YACpE,MAAM,GAAG,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;YAC7B,IAAI,GAAG,YAAY,OAAO,EAAE,CAAC;gBAC3B,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7B,CAAC;iBAAM,CAAC;gBACN,OAAO,EAAE,CAAC;YACZ,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,EAAE,CAAC;YACV,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;CACF;AA7fD,oBA6fC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ECDb\r\n */\r\nimport { assert, BeEvent, DbResult, Logger, OpenMode } from \"@itwin/core-bentley\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { DbQueryRequest, DbQueryResponse, ECSchemaProps, ECSqlReader, IModelError, QueryBinder, QueryOptions } from \"@itwin/core-common\";\r\nimport { serialize } from \"node:v8\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { ConcurrentQuery } from \"./ConcurrentQuery\";\r\nimport { ECSqlStatement, ECSqlWriteStatement } from \"./ECSqlStatement\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\nimport { SqliteStatement, StatementCache } from \"./SqliteStatement\";\r\nimport { _nativeDb } from \"./internal/Symbols\";\r\nimport { QueryMetadataCache } from \"./internal/QueryMetadataCache\";\r\nimport { ECSqlRowExecutor } from \"./ECSqlRowExecutor\";\r\nimport { ECSqlSyncReader, SynchronousQueryOptions } from \"./ECSqlSyncReader\";\r\n\r\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\r\n\r\n/** Maps a zero-based CSV column to an EC property.\r\n * @beta\r\n */\r\nexport interface CSVColumnMapping {\r\n /** Zero-based index of the source CSV column. */\r\n columnIndex: number;\r\n /** EC property access string to receive the column value. */\r\n propertyName: string;\r\n}\r\n\r\n/** Common options for importing CSV data into an ECClass.\r\n * @beta\r\n */\r\nexport interface CSVImportOptions {\r\n /** Full name or ECSQL name of the ECClass to insert. */\r\n className: string;\r\n /** Source-column to EC-property mappings. Unmapped source columns are ignored. */\r\n mapping: readonly CSVColumnMapping[];\r\n /** Exact CSV value to bind as null. By default, every field is treated as a value. */\r\n nullValue?: string;\r\n}\r\n\r\n/** Options for [[ECDb.importCSVFile]].\r\n * @beta\r\n */\r\nexport interface CSVFileImportOptions extends CSVImportOptions {\r\n /** Whether the first CSV row is a header to skip. Defaults to false. */\r\n hasHeader?: boolean;\r\n}\r\n\r\nfunction validateCSVMapping(mapping: readonly CSVColumnMapping[]): void {\r\n if (0 === mapping.length)\r\n throw new TypeError(\"mapping must not be empty\");\r\n\r\n const columnIndexes = new Set<number>();\r\n for (const entry of mapping) {\r\n if (undefined === entry || null === entry || \"object\" !== typeof entry)\r\n throw new TypeError(\"mapping must contain only objects\");\r\n if (!Number.isSafeInteger(entry.columnIndex) || entry.columnIndex < 0 || entry.columnIndex >= 0xffff_ffff)\r\n throw new TypeError(\"mapping columnIndex values must be non-negative safe integers\");\r\n if (\"string\" !== typeof entry.propertyName || 0 === entry.propertyName.length)\r\n throw new TypeError(\"mapping propertyName values must not be empty\");\r\n if (columnIndexes.has(entry.columnIndex))\r\n throw new TypeError(\"mapping must not contain duplicate columnIndex values\");\r\n columnIndexes.add(entry.columnIndex);\r\n }\r\n}\r\n\r\n/** Modes for how to open [ECDb]($backend) files.\r\n * @public\r\n */\r\nexport enum ECDbOpenMode {\r\n Readonly,\r\n ReadWrite,\r\n /** Opens the file read-write and upgrades the file if necessary to the latest file format version. */\r\n FileUpgrade,\r\n}\r\n\r\n/** An ECDb file\r\n * @public\r\n */\r\nexport class ECDb implements Disposable {\r\n private _nativeDb?: IModelJsNative.ECDb;\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n private readonly _statementCache = new StatementCache<ECSqlStatement>();\r\n private _sqliteStatementCache = new StatementCache<SqliteStatement>();\r\n private readonly _queryMetadataCache = new QueryMetadataCache();\r\n\r\n /** Event called when the ECDb is about to be closed. */\r\n public readonly onBeforeClose = new BeEvent<() => void>();\r\n\r\n /** only for tests\r\n * @internal\r\n */\r\n public resetSqliteCache(size: number) {\r\n this._sqliteStatementCache.clear();\r\n this._sqliteStatementCache = new StatementCache<SqliteStatement>(size);\r\n }\r\n\r\n constructor() {\r\n this._nativeDb = new IModelNative.platform.ECDb();\r\n }\r\n /** Call this function when finished with this ECDb object. This releases the native resources held by the\r\n * ECDb object.\r\n */\r\n public [Symbol.dispose](): void {\r\n if (!this._nativeDb)\r\n return;\r\n\r\n this.closeDb();\r\n this._nativeDb.dispose();\r\n this._nativeDb = undefined;\r\n }\r\n /**\r\n * Attach an iModel file to this connection and load and register its schemas.\r\n * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'\r\n * @param fileName IModel file name\r\n * @param alias identifier for the attached file. This identifer is used to access schema from the attached file. e.g. if alias is 'abc' then schema can be accessed using 'abc.MySchema.MyClass'\r\n */\r\n public attachDb(fileName: string, alias: string): void {\r\n if (alias.toLowerCase() === \"main\" || alias.toLowerCase() === \"schema_sync_db\" || alias.toLowerCase() === \"ecchange\" || alias.toLowerCase() === \"temp\") {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Reserved tablespace name cannot be used\");\r\n }\r\n this[_nativeDb].attachDb(fileName, alias);\r\n }\r\n /**\r\n * Detach the attached file from this connection. The attached file is closed and its schemas are unregistered.\r\n * @note There are some reserve tablespace names that cannot be used. They are 'main', 'schema_sync_db', 'ecchange' & 'temp'\r\n * @param alias identifer that was used in the call to [[attachDb]]\r\n */\r\n public detachDb(alias: string): void {\r\n if (alias.toLowerCase() === \"main\" || alias.toLowerCase() === \"schema_sync_db\" || alias.toLowerCase() === \"ecchange\" || alias.toLowerCase() === \"temp\") {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Reserved tablespace name cannot be used\");\r\n }\r\n this.clearCaches();\r\n this[_nativeDb].detachDb(alias);\r\n }\r\n\r\n /** @deprecated in 5.0 - might be removed in next major version. Use [Symbol.dispose] instead. */\r\n public dispose(): void {\r\n this[Symbol.dispose]();\r\n }\r\n\r\n /** Create an ECDb\r\n * @param pathName The path to the ECDb file to create.\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public createDb(pathName: string): void {\r\n const status: DbResult = this[_nativeDb].createDb(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to created ECDb\");\r\n }\r\n\r\n /** Open the ECDb.\r\n * @param pathName The path to the ECDb file to open\r\n * @param openMode Open mode\r\n * @throws [IModelError]($common) if the operation failed.\r\n */\r\n public openDb(pathName: string, openMode: ECDbOpenMode = ECDbOpenMode.Readonly): void {\r\n const nativeOpenMode: OpenMode = openMode === ECDbOpenMode.Readonly ? OpenMode.Readonly : OpenMode.ReadWrite;\r\n const tryUpgrade: boolean = openMode === ECDbOpenMode.FileUpgrade;\r\n const status: DbResult = this[_nativeDb].openDb(pathName, nativeOpenMode, tryUpgrade);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to open ECDb\");\r\n }\r\n\r\n /** Returns true if the ECDb is open */\r\n public get isOpen(): boolean { return this[_nativeDb].isOpen(); }\r\n\r\n /** Close the Db after saving any uncommitted changes.\r\n * @throws [IModelError]($common) if the database is not open.\r\n */\r\n public closeDb(): void {\r\n this.onBeforeClose.raiseEvent();\r\n this.clearCaches();\r\n this[_nativeDb].closeDb();\r\n }\r\n\r\n /** Clear all in-memory caches held in this ECDb.\r\n * @beta\r\n */\r\n public clearCaches(): void {\r\n this._queryMetadataCache.clear();\r\n this._statementCache.clear();\r\n this._sqliteStatementCache.clear();\r\n this[_nativeDb].clearECDbCache();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public clearStatementCache() {\r\n this._statementCache.clear();\r\n }\r\n\r\n /** @internal use to test statement caching */\r\n public getCachedStatementCount() {\r\n return this._statementCache.size;\r\n }\r\n\r\n /** Commit the outermost transaction, writing changes to the file. Then, restart the transaction.\r\n * @param changesetName The name of the operation that generated these changes.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public saveChanges(changesetName?: string): void {\r\n const status: DbResult = this[_nativeDb].saveChanges(changesetName);\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to save changes\");\r\n }\r\n\r\n /** Abandon (cancel) the outermost transaction, discarding all changes since last save. Then, restart the transaction.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public abandonChanges(): void {\r\n const status: DbResult = this[_nativeDb].abandonChanges();\r\n if (status !== DbResult.BE_SQLITE_OK)\r\n throw new IModelError(status, \"Failed to abandon changes\");\r\n }\r\n\r\n /** Import a schema.\r\n *\r\n * If the import was successful, the database is automatically saved to disk.\r\n * @param pathName Path to ECSchema XML file to import.\r\n * @throws [IModelError]($common) if the database is not open or if the operation failed.\r\n */\r\n public importSchema(pathName: string): void {\r\n const status: DbResult = this[_nativeDb].importSchema(pathName);\r\n if (status !== DbResult.BE_SQLITE_OK) {\r\n Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);\r\n throw new IModelError(status, `Failed to import schema from '${pathName}'.`);\r\n }\r\n this.clearCaches();\r\n }\r\n\r\n /** Removes unused schemas from the database.\r\n *\r\n * If the removal was successful, the database is automatically saved to disk.\r\n * @param schemaNames Array of schema names to drop\r\n * @throws [IModelError]($common) if the database if the operation failed.\r\n * @alpha\r\n */\r\n public dropSchemas(schemaNames: string[]): void {\r\n if (schemaNames.length === 0)\r\n return;\r\n // SchemaSync.isEnabled() should be used, but ECDb is not an iModelDb so it has no container props\r\n if (this[_nativeDb].schemaSyncEnabled())\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Cannot drop schemas when schema sync is enabled\");\r\n\r\n try {\r\n this[_nativeDb].dropSchemas(schemaNames);\r\n this.saveChanges('dropped unused schemas');\r\n } catch (error: any) {\r\n Logger.logError(loggerCategory, `Failed to drop schemas: ${error}`);\r\n this.abandonChanges();\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, `Failed to drop schemas: ${error}`);\r\n } finally {\r\n this.clearCaches();\r\n }\r\n }\r\n\r\n /**\r\n * Returns the full schema for the input name.\r\n * @param name The name of the schema e.g. 'ECDbMeta'\r\n * @returns The SchemaProps for the requested schema\r\n * @throws if the schema can not be found or loaded.\r\n */\r\n public getSchemaProps(name: string): ECSchemaProps {\r\n return this[_nativeDb].getSchemaProps(name);\r\n }\r\n\r\n /** Import in-memory CSV rows into an ECClass.\r\n *\r\n * The rows are V8-serialized and processed in one native call. Values are converted from\r\n * their CSV string representation according to the mapped EC property type. One ECSQL\r\n * statement is reused for all rows. Every row must have the same number of columns.\r\n * Boolean fields accept `true`, `false`, `1`, or `0`. Integer fields must contain a\r\n * base-10 value in the signed 32-bit range. Boolean, double, integer, and string EC\r\n * properties are supported. The import is all-or-nothing and callers must call\r\n * [[saveChanges]] to commit it to disk.\r\n * @returns The number of imported rows.\r\n * @beta\r\n */\r\n public importCSVData(rows: readonly (readonly string[])[], options: CSVImportOptions): number {\r\n validateCSVMapping(options.mapping);\r\n return this[_nativeDb].importCSVData(options.className, serialize(rows), options.mapping, { nullValue: options.nullValue });\r\n }\r\n\r\n /** Stream a CSV file into an ECClass.\r\n *\r\n * The file must be UTF-8 encoded; an optional UTF-8 byte-order mark is accepted. It is read\r\n * and parsed in native code, and one ECSQL statement is reused for all rows. Every record must\r\n * have the same number of columns; blank records are not skipped. Boolean fields accept\r\n * `true`, `false`, `1`, or `0`. Integer fields must contain a base-10 value in the signed\r\n * 32-bit range. Boolean, double, integer, and string EC properties are supported. The import\r\n * is all-or-nothing and callers must call [[saveChanges]] to commit it to disk.\r\n * @returns The number of imported rows, excluding an optional header.\r\n * @beta\r\n */\r\n public importCSVFile(csvFilePath: string, options: CSVFileImportOptions): number {\r\n validateCSVMapping(options.mapping);\r\n return this[_nativeDb].importCSVFile(options.className, csvFilePath, options.mapping, {\r\n hasHeader: options.hasHeader,\r\n nullValue: options.nullValue,\r\n });\r\n }\r\n\r\n /**\r\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withWriteStatement]]\r\n * @beta\r\n */\r\n public withCachedWriteStatement<T>(ecsql: string, callback: (stmt: ECSqlWriteStatement) => T, logErrors = true): T {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\r\n const release = () => this._statementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(new ECSqlWriteStatement(stmt));\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\r\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withCachedWriteStatement]]\r\n * @beta\r\n */\r\n public withWriteStatement<T>(ecsql: string, callback: (stmt: ECSqlWriteStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareWriteStatement(ecsql, logErrors);\r\n const release = () => stmt[Symbol.dispose]();\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an ECSQL statement.\r\n * @param ecsql The ECSQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @beta\r\n */\r\n public prepareWriteStatement(ecsql: string, logErrors = true): ECSqlWriteStatement {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n return new ECSqlWriteStatement(this.prepareStatement(ecsql, logErrors));\r\n }\r\n\r\n /**\r\n * Use a prepared ECSQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for ECSQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withStatement]]\r\n * @public\r\n * @deprecated in 4.11 - might be removed in next major version. Use [[createQueryReader]] for SELECT statements and [[withCachedWriteStatement]] for INSERT/UPDATE/DELETE instead.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public withPreparedStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this._statementCache.findAndRemove(ecsql) ?? this.prepareStatement(ecsql, logErrors);\r\n const release = () => this._statementCache.addOrDispose(stmt);\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on an ECSQL statement. After the callback completes the statement is disposed.\r\n * Use this method for ECSQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n * @deprecated in 4.11 - might be removed in next major version. Use [[createQueryReader]] for SELECT statements and [[withWriteStatement]] for INSERT/UPDATE/DELETE instead.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public withStatement<T>(ecsql: string, callback: (stmt: ECSqlStatement) => T, logErrors = true): T {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = this.prepareStatement(ecsql, logErrors);\r\n const release = () => stmt[Symbol.dispose]();\r\n try {\r\n const val = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an ECSQL statement.\r\n * @param ecsql The ECSQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @deprecated in 4.11 - might be removed in next major version. Use [[prepareWriteStatement]] when preparing an INSERT/UPDATE/DELETE statement or [[createQueryReader]] to execute a SELECT statement.\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public prepareStatement(ecsql: string, logErrors = true): ECSqlStatement {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n const stmt = new ECSqlStatement();\r\n stmt.prepare(this[_nativeDb], ecsql, logErrors);\r\n return stmt;\r\n }\r\n\r\n /**\r\n * Use a prepared SQL statement, potentially from the statement cache. If the requested statement doesn't exist\r\n * in the statement cache, a new statement is prepared. After the callback completes, the statement is reset and saved\r\n * in the statement cache so it can be reused in the future. Use this method for SQL statements that will be\r\n * reused often and are expensive to prepare. The statement cache holds the most recently used statements, discarding\r\n * the oldest statements as it fills. For statements you don't intend to reuse, instead use [[withSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @see [[withPreparedStatement]]\r\n * @public\r\n */\r\n public withPreparedSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this._sqliteStatementCache.findAndRemove(sql) ?? this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => this._sqliteStatementCache.addOrDispose(stmt);\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Prepared and execute a callback on a SQL statement. After the callback completes the statement is disposed.\r\n * Use this method for SQL statements are either not expected to be reused, or are not expensive to prepare.\r\n * For statements that will be reused often, instead use [[withPreparedSqliteStatement]].\r\n * @param sql The SQLite SQL statement to execute\r\n * @param callback the callback to invoke on the prepared statement\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @returns the value returned by `callback`.\r\n * @public\r\n */\r\n public withSqliteStatement<T>(sql: string, callback: (stmt: SqliteStatement) => T, logErrors = true): T {\r\n const stmt = this.prepareSqliteStatement(sql, logErrors);\r\n const release = () => stmt[Symbol.dispose]();\r\n try {\r\n const val: T = callback(stmt);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Prepare an SQL statement.\r\n * @param sql The SQLite SQL statement to prepare\r\n * @param logErrors Determines if error will be logged if statement fail to prepare\r\n * @throws [IModelError]($common) if there is a problem preparing the statement.\r\n * @internal\r\n */\r\n public prepareSqliteStatement(sql: string, logErrors = true): SqliteStatement {\r\n const stmt = new SqliteStatement(sql);\r\n stmt.prepare(this[_nativeDb], logErrors);\r\n return stmt;\r\n }\r\n\r\n /** @internal */\r\n public get [_nativeDb](): IModelJsNative.ECDb {\r\n assert(undefined !== this._nativeDb);\r\n return this._nativeDb;\r\n }\r\n\r\n /** Creates a reader for asynchronous ECSQL query execution.\r\n * Execution starts when the reader is consumed using asynchronous iteration or awaited calls to `step()` or `toArray()`.\r\n * Results are fetched and buffered in batches. For synchronous, callback-scoped execution, use [[withQueryReader]].\r\n *\r\n * See also:\r\n * - [Choosing a query reader]($docs/learning/backend/ExecutingECSQL)\r\n * - [Asynchronous query examples]($docs/learning/ECSQLCodeExamples)\r\n * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)\r\n *\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param config Allow to specify certain flags which control how query is executed.\r\n * @returns Returns an [ECSqlReader]($common) which helps iterate over the result set and also give access to metadata.\r\n * @public\r\n * */\r\n public createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader {\r\n if (!this._nativeDb || !this._nativeDb.isOpen()) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR_NOTOPEN, \"db not open\");\r\n }\r\n const executor = {\r\n execute: (request: DbQueryRequest): DbQueryResponse | Promise<DbQueryResponse> => request.usePrimaryConn === true\r\n ? this._queryMetadataCache.executeCachedPrimaryQueryRequest(request, (req) => ConcurrentQuery.executePrimaryQueryRequest(this[_nativeDb], req))\r\n : this._queryMetadataCache.executeCachedQueryRequest(request, async (req) => ConcurrentQuery.executeQueryRequest(this[_nativeDb], req)),\r\n };\r\n return new ECSqlReader(executor, ecsql, params, config);\r\n }\r\n\r\n /** Executes a callback with a synchronous ECSQL reader on the owning database connection.\r\n * The reader steps one row at a time without buffering result batches. Finish using it before the callback completes.\r\n * Return materialized rows or computed values rather than the reader. For asynchronous execution, use [[createQueryReader]].\r\n * The prepared statement may be reused from the statement cache between completed calls.\r\n *\r\n * See also:\r\n * - [Choosing a query reader]($docs/learning/backend/ExecutingECSQL)\r\n * - [Synchronous query examples]($docs/learning/backend/WithQueryReaderCodeExamples)\r\n * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)\r\n * @param ecsql The ECSQL query to execute.\r\n * @param callback the callback to invoke on the prepared ECSqlSyncReader\r\n * @param params The values to bind to the parameters (if the ECSQL has any).\r\n * @param config Optional flags which control how query is executed.\r\n * @returns the value returned by `callback`.\r\n * @throws IModelError if db is not open or if error occurs during statement execution\r\n * @beta\r\n * */\r\n public withQueryReader<T>(ecsql: string, callback: (reader: ECSqlSyncReader) => T, params?: QueryBinder, config?: SynchronousQueryOptions): T {\r\n if (!this[_nativeDb].isOpen())\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR_NOTOPEN, \"db not open\");\r\n\r\n const executor = new ECSqlRowExecutor(this);\r\n const release = () => executor[Symbol.dispose]();\r\n try {\r\n const reader = new ECSqlSyncReader(executor, ecsql, params, config);\r\n const val = callback(reader);\r\n if (val instanceof Promise) {\r\n val.then(release, release);\r\n } else {\r\n release();\r\n }\r\n return val;\r\n } catch (err: any) {\r\n release();\r\n throw err;\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -1,79 +1,63 @@
|
|
|
1
1
|
import { PropertyMetaDataMap } from "@itwin/core-common";
|
|
2
2
|
import type { IModelDb } from "./IModelDb";
|
|
3
|
-
import { ECSqlStatement } from "./ECSqlStatement";
|
|
4
|
-
import { IModelJsNative } from "@bentley/imodeljs-native";
|
|
5
3
|
import type { ECDb } from "./ECDb";
|
|
6
|
-
|
|
7
|
-
/** Returns a statement to its cache, falling back to direct disposal without throwing.
|
|
4
|
+
/** Row rendering flags passed to `prepareECSqlBatchReader`.
|
|
8
5
|
* @internal
|
|
9
6
|
*/
|
|
10
|
-
export declare
|
|
7
|
+
export declare enum SyncReaderRowFlags {
|
|
8
|
+
None = 0,
|
|
9
|
+
AbbreviateBlobs = 1,
|
|
10
|
+
ClassIdsToClassNames = 2,
|
|
11
|
+
UseJsName = 4,
|
|
12
|
+
DoNotConvertClassIdsToClassNamesWhenAliased = 8
|
|
13
|
+
}
|
|
11
14
|
/**
|
|
12
|
-
* Executes ECSql
|
|
13
|
-
*
|
|
15
|
+
* Executes an ECSql query on the db's primary connection and hands out rows one at a time. On a read-only db, rows are
|
|
16
|
+
* read from native code in growing batches to reduce JS/native transitions; on a writable db native code returns one row
|
|
17
|
+
* per call so rows are never read ahead of writes made while iterating. The prepared statement is leased from the native
|
|
18
|
+
* concurrent query statement cache and returned to it when the executor is disposed.
|
|
14
19
|
* @internal
|
|
15
20
|
*/
|
|
16
21
|
export declare class ECSqlRowExecutor implements Disposable {
|
|
17
22
|
private readonly _db;
|
|
18
|
-
private readonly _stmt;
|
|
19
|
-
private readonly _loggerCategory;
|
|
20
23
|
private _removeListener;
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/** Removes the database-close listener owned by this row executor.
|
|
24
|
+
private _reader?;
|
|
25
|
+
/** Key of this statement's metadata in `metadataCache`, or undefined when its metadata must not be cached. */
|
|
26
|
+
private _metadataKey;
|
|
27
|
+
private _rows;
|
|
28
|
+
private _rowIndex;
|
|
29
|
+
private _batchSize;
|
|
30
|
+
/** Status of the last native batch. Anything other than BE_SQLITE_ROW means no further batch is fetched. */
|
|
31
|
+
private _batchStatus;
|
|
32
|
+
constructor(_db: IModelDb | ECDb);
|
|
33
|
+
/** Returns the leased statement to the native cache. Safe to call more than once. */
|
|
34
|
+
private releaseReader;
|
|
35
|
+
private resetBatch;
|
|
36
|
+
/** Returns the leased statement and removes the database-close listener owned by this row executor.
|
|
35
37
|
* @internal
|
|
36
38
|
*/
|
|
37
39
|
[Symbol.dispose](): void;
|
|
38
|
-
/** Prepare the statement and bind parameters in one step.
|
|
39
|
-
*
|
|
40
|
+
/** Prepare the statement and bind parameters in one step. On a read-only db the first batch of rows is read by the
|
|
41
|
+
* same native call.
|
|
40
42
|
* @param query - The ECSql text to prepare.
|
|
41
|
-
* @param args - Optional bind parameters.
|
|
43
|
+
* @param args - Optional bind parameters as flat `[key, type, value, ...]` triples.
|
|
44
|
+
* @param rowFlags - [[SyncReaderRowFlags]] used for every row and for metadata.
|
|
42
45
|
* @throws IModelError on preparation or binding failure.
|
|
43
46
|
* @internal
|
|
44
47
|
*/
|
|
45
|
-
prepareAndBind(query: string, args
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* DbRuntimeStats, DbQueryResponse) that the general `execute()` path creates per row.
|
|
53
|
-
*
|
|
54
|
-
* @param options - Native row-adaptor options (should be cached and reused across rows).
|
|
55
|
-
* @throws IModelError on step failure or row extraction failure.
|
|
56
|
-
* @internal
|
|
57
|
-
*/
|
|
58
|
-
stepNextRow(options: IModelJsNative.ECSqlRowAdaptorOptions): any;
|
|
59
|
-
/** Get column metadata directly from the prepared statement.
|
|
60
|
-
* Call once after `prepareAndBind` — the metadata does not change between rows.
|
|
61
|
-
* @param options - Native row-adaptor options that influence property naming.
|
|
62
|
-
* @returns Column metadata owned by the caller.
|
|
63
|
-
* @internal
|
|
64
|
-
*/
|
|
65
|
-
fetchMetadata(options: IModelJsNative.ECSqlRowAdaptorOptions): PropertyMetaDataMap;
|
|
66
|
-
/** Prepares the ECSql statement when the caller did not supply one from its cache.
|
|
67
|
-
* @param ecsql - The ECSql text to prepare.
|
|
68
|
-
* @returns An `OperationResult` indicating success or failure.
|
|
48
|
+
prepareAndBind(query: string, args: any[] | undefined, rowFlags: SyncReaderRowFlags): void;
|
|
49
|
+
/** Store a batch returned by native code: a JSON array string, an array of rows, or the final DbResult. */
|
|
50
|
+
private acceptBatch;
|
|
51
|
+
/** Return the next row data array, or `undefined` when the result set is exhausted. Rows are served from the
|
|
52
|
+
* read-ahead buffer; a new native batch is fetched only when the buffer is empty.
|
|
53
|
+
* @throws IModelError on step failure or when the statement is no longer available. A failure reported by a batch is
|
|
54
|
+
* thrown after the rows stepped before it have been returned.
|
|
69
55
|
* @internal
|
|
70
56
|
*/
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* @param args - The parameter object to bind, or `undefined` when no parameters are needed.
|
|
74
|
-
* @returns An `OperationResult` indicating success or failure.
|
|
57
|
+
stepNextRow(): any;
|
|
58
|
+
/** Get shared internal column metadata. Readers must copy it before exposing mutable metadata to callers.
|
|
75
59
|
* @internal
|
|
76
60
|
*/
|
|
77
|
-
|
|
61
|
+
fetchMetadata(): PropertyMetaDataMap;
|
|
78
62
|
}
|
|
79
63
|
//# sourceMappingURL=ECSqlRowExecutor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECSqlRowExecutor.d.ts","sourceRoot":"","sources":["../../src/ECSqlRowExecutor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAA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