@itwin/core-backend 5.8.0-dev.5 → 5.8.0-dev.8
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 +11 -1
- package/lib/cjs/ECDb.d.ts +26 -0
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +53 -2
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSqlRowExecutor.d.ts +66 -0
- package/lib/cjs/ECSqlRowExecutor.d.ts.map +1 -0
- package/lib/cjs/ECSqlRowExecutor.js +135 -0
- package/lib/cjs/ECSqlRowExecutor.js.map +1 -0
- package/lib/cjs/ECSqlStatement.d.ts +13 -1
- package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
- package/lib/cjs/ECSqlStatement.js +30 -0
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/ECSqlSyncReader.d.ts +104 -0
- package/lib/cjs/ECSqlSyncReader.d.ts.map +1 -0
- package/lib/cjs/ECSqlSyncReader.js +191 -0
- package/lib/cjs/ECSqlSyncReader.js.map +1 -0
- package/lib/cjs/IModelDb.d.ts +21 -1
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +43 -0
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IpcHost.d.ts.map +1 -1
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/core-backend.d.ts +1 -0
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +1 -0
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.js +10 -2
- package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/esm/ECDb.d.ts +26 -0
- package/lib/esm/ECDb.d.ts.map +1 -1
- package/lib/esm/ECDb.js +54 -3
- package/lib/esm/ECDb.js.map +1 -1
- package/lib/esm/ECSqlRowExecutor.d.ts +66 -0
- package/lib/esm/ECSqlRowExecutor.d.ts.map +1 -0
- package/lib/esm/ECSqlRowExecutor.js +131 -0
- package/lib/esm/ECSqlRowExecutor.js.map +1 -0
- package/lib/esm/ECSqlStatement.d.ts +13 -1
- package/lib/esm/ECSqlStatement.d.ts.map +1 -1
- package/lib/esm/ECSqlStatement.js +30 -0
- package/lib/esm/ECSqlStatement.js.map +1 -1
- package/lib/esm/ECSqlSyncReader.d.ts +104 -0
- package/lib/esm/ECSqlSyncReader.d.ts.map +1 -0
- package/lib/esm/ECSqlSyncReader.js +187 -0
- package/lib/esm/ECSqlSyncReader.js.map +1 -0
- package/lib/esm/IModelDb.d.ts +21 -1
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +43 -0
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/IpcHost.d.ts.map +1 -1
- package/lib/esm/IpcHost.js.map +1 -1
- package/lib/esm/core-backend.d.ts +1 -0
- package/lib/esm/core-backend.d.ts.map +1 -1
- package/lib/esm/core-backend.js +1 -0
- package/lib/esm/core-backend.js.map +1 -1
- package/lib/esm/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
- package/lib/esm/internal/workspace/WorkspaceImpl.js +10 -2
- package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlQuery.test.js +21 -12
- package/lib/esm/test/ecdb/ECSqlQuery.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlSyncReader.test.d.ts +2 -0
- package/lib/esm/test/ecdb/ECSqlSyncReader.test.d.ts.map +1 -0
- package/lib/esm/test/ecdb/ECSqlSyncReader.test.js +122 -0
- package/lib/esm/test/ecdb/ECSqlSyncReader.test.js.map +1 -0
- package/lib/esm/test/ecdb/QueryReaders.test.d.ts +2 -0
- package/lib/esm/test/ecdb/QueryReaders.test.d.ts.map +1 -0
- package/lib/esm/test/ecdb/QueryReaders.test.js +1427 -0
- package/lib/esm/test/ecdb/QueryReaders.test.js.map +1 -0
- package/lib/esm/test/ecsql/src/ECSqlTestParser.d.ts +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestParser.d.ts.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestParser.js +7 -5
- package/lib/esm/test/ecsql/src/ECSqlTestParser.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js +172 -98
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
- package/lib/esm/test/standalone/Workspace.test.js +53 -0
- package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
- package/lib/esm/test/standalone/iModelDb.test.d.ts +2 -0
- package/lib/esm/test/standalone/iModelDb.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/iModelDb.test.js +35 -0
- package/lib/esm/test/standalone/iModelDb.test.js.map +1 -0
- package/package.json +13 -13
- package/lib/esm/test/ecdb/ECSqlReader.test.d.ts +0 -2
- package/lib/esm/test/ecdb/ECSqlReader.test.d.ts.map +0 -1
- package/lib/esm/test/ecdb/ECSqlReader.test.js +0 -669
- package/lib/esm/test/ecdb/ECSqlReader.test.js.map +0 -1
package/lib/esm/ECDb.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module ECDb
|
|
3
|
+
*/
|
|
4
|
+
import { BeEvent } from "@itwin/core-bentley";
|
|
1
5
|
import { IModelJsNative } from "@bentley/imodeljs-native";
|
|
2
6
|
import { ECSchemaProps, ECSqlReader, QueryBinder, QueryOptions } from "@itwin/core-common";
|
|
3
7
|
import { ECSqlStatement, ECSqlWriteStatement } from "./ECSqlStatement";
|
|
4
8
|
import { SqliteStatement } from "./SqliteStatement";
|
|
5
9
|
import { _nativeDb } from "./internal/Symbols";
|
|
10
|
+
import { ECSqlSyncReader, SynchronousQueryOptions } from "./ECSqlSyncReader";
|
|
6
11
|
/** Modes for how to open [ECDb]($backend) files.
|
|
7
12
|
* @public
|
|
8
13
|
*/
|
|
@@ -19,6 +24,8 @@ export declare class ECDb implements Disposable {
|
|
|
19
24
|
private _nativeDb?;
|
|
20
25
|
private readonly _statementCache;
|
|
21
26
|
private _sqliteStatementCache;
|
|
27
|
+
/** Event called when the ECDb is about to be closed. */
|
|
28
|
+
readonly onBeforeClose: BeEvent<() => void>;
|
|
22
29
|
/** only for tests
|
|
23
30
|
* @internal
|
|
24
31
|
*/
|
|
@@ -60,6 +67,10 @@ export declare class ECDb implements Disposable {
|
|
|
60
67
|
* @throws [IModelError]($common) if the database is not open.
|
|
61
68
|
*/
|
|
62
69
|
closeDb(): void;
|
|
70
|
+
/** Clear all in-memory caches held in this ECDb.
|
|
71
|
+
* @beta
|
|
72
|
+
*/
|
|
73
|
+
clearCaches(): void;
|
|
63
74
|
/** @internal use to test statement caching */
|
|
64
75
|
clearStatementCache(): void;
|
|
65
76
|
/** @internal use to test statement caching */
|
|
@@ -210,5 +221,20 @@ export declare class ECDb implements Disposable {
|
|
|
210
221
|
* @public
|
|
211
222
|
* */
|
|
212
223
|
createQueryReader(ecsql: string, params?: QueryBinder, config?: QueryOptions): ECSqlReader;
|
|
224
|
+
/** Allow to execute query and read results along with meta data. The result are stepped one by one.
|
|
225
|
+
*
|
|
226
|
+
* See also:
|
|
227
|
+
* - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)
|
|
228
|
+
* - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)
|
|
229
|
+
* - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)
|
|
230
|
+
* @param ecsql The ECSQL query to execute.
|
|
231
|
+
* @param callback the callback to invoke on the prepared ECSqlSyncReader
|
|
232
|
+
* @param params The values to bind to the parameters (if the ECSQL has any).
|
|
233
|
+
* @param config Optional flags which control how query is executed.
|
|
234
|
+
* @returns the value returned by `callback`.
|
|
235
|
+
* @throws IModelError if db is not open or if error occurs during statement execution
|
|
236
|
+
* @beta
|
|
237
|
+
* */
|
|
238
|
+
withQueryReader<T>(ecsql: string, callback: (reader: ECSqlSyncReader) => T, params?: QueryBinder, config?: SynchronousQueryOptions): T;
|
|
213
239
|
}
|
|
214
240
|
//# sourceMappingURL=ECDb.d.ts.map
|
package/lib/esm/ECDb.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECDb.d.ts","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":"
|
|
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,EAAkB,aAAa,EAAE,WAAW,EAAe,WAAW,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGxH,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;AAE/C,OAAO,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAI7E;;GAEG;AACH,oBAAY,YAAY;IACtB,QAAQ,IAAA;IACR,SAAS,IAAA;IACT,sGAAsG;IACtG,WAAW,IAAA;CACZ;AAED;;GAEG;AACH,qBAAa,IAAK,YAAW,UAAU;IACrC,OAAO,CAAC,SAAS,CAAC,CAAsB;IAExC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAwC;IACxE,OAAO,CAAC,qBAAqB,CAAyC;IAEtE,wDAAwD;IACxD,SAAgB,aAAa,gBAAqB,IAAI,EAAI;IAE1D;;OAEG;IACI,gBAAgB,CAAC,IAAI,EAAE,MAAM;;IAQpC;;OAEG;IACI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IA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AAM,CAAC,EAAE,uBAAuB,GAAG,CAAC;CAoB9I"}
|
package/lib/esm/ECDb.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module ECDb
|
|
7
7
|
*/
|
|
8
|
-
import { assert, DbResult, Logger, OpenMode } from "@itwin/core-bentley";
|
|
8
|
+
import { assert, BeEvent, DbResult, Logger, OpenMode } from "@itwin/core-bentley";
|
|
9
9
|
import { ECSqlReader, IModelError } from "@itwin/core-common";
|
|
10
10
|
import { BackendLoggerCategory } from "./BackendLoggerCategory";
|
|
11
11
|
import { ConcurrentQuery } from "./ConcurrentQuery";
|
|
@@ -13,6 +13,8 @@ import { ECSqlStatement, ECSqlWriteStatement } from "./ECSqlStatement";
|
|
|
13
13
|
import { IModelNative } from "./internal/NativePlatform";
|
|
14
14
|
import { SqliteStatement, StatementCache } from "./SqliteStatement";
|
|
15
15
|
import { _nativeDb } from "./internal/Symbols";
|
|
16
|
+
import { ECSqlRowExecutor } from "./ECSqlRowExecutor";
|
|
17
|
+
import { ECSqlSyncReader } from "./ECSqlSyncReader";
|
|
16
18
|
const loggerCategory = BackendLoggerCategory.ECDb;
|
|
17
19
|
/** Modes for how to open [ECDb]($backend) files.
|
|
18
20
|
* @public
|
|
@@ -32,6 +34,8 @@ export class ECDb {
|
|
|
32
34
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
33
35
|
_statementCache = new StatementCache();
|
|
34
36
|
_sqliteStatementCache = new StatementCache();
|
|
37
|
+
/** Event called when the ECDb is about to be closed. */
|
|
38
|
+
onBeforeClose = new BeEvent();
|
|
35
39
|
/** only for tests
|
|
36
40
|
* @internal
|
|
37
41
|
*/
|
|
@@ -73,7 +77,7 @@ export class ECDb {
|
|
|
73
77
|
if (alias.toLowerCase() === "main" || alias.toLowerCase() === "schema_sync_db" || alias.toLowerCase() === "ecchange" || alias.toLowerCase() === "temp") {
|
|
74
78
|
throw new IModelError(DbResult.BE_SQLITE_ERROR, "Reserved tablespace name cannot be used");
|
|
75
79
|
}
|
|
76
|
-
this.
|
|
80
|
+
this.clearCaches();
|
|
77
81
|
this[_nativeDb].detachDb(alias);
|
|
78
82
|
}
|
|
79
83
|
/** @deprecated in 5.0 - will not be removed until after 2026-06-13. Use [Symbol.dispose] instead. */
|
|
@@ -107,9 +111,17 @@ export class ECDb {
|
|
|
107
111
|
* @throws [IModelError]($common) if the database is not open.
|
|
108
112
|
*/
|
|
109
113
|
closeDb() {
|
|
114
|
+
this.onBeforeClose.raiseEvent();
|
|
115
|
+
this.clearCaches();
|
|
116
|
+
this[_nativeDb].closeDb();
|
|
117
|
+
}
|
|
118
|
+
/** Clear all in-memory caches held in this ECDb.
|
|
119
|
+
* @beta
|
|
120
|
+
*/
|
|
121
|
+
clearCaches() {
|
|
110
122
|
this._statementCache.clear();
|
|
111
123
|
this._sqliteStatementCache.clear();
|
|
112
|
-
this[_nativeDb].
|
|
124
|
+
this[_nativeDb].clearECDbCache();
|
|
113
125
|
}
|
|
114
126
|
/** @internal use to test statement caching */
|
|
115
127
|
clearStatementCache() {
|
|
@@ -148,6 +160,7 @@ export class ECDb {
|
|
|
148
160
|
Logger.logError(loggerCategory, `Failed to import schema from '${pathName}'.`);
|
|
149
161
|
throw new IModelError(status, `Failed to import schema from '${pathName}'.`);
|
|
150
162
|
}
|
|
163
|
+
this.clearCaches();
|
|
151
164
|
}
|
|
152
165
|
/** Removes unused schemas from the database.
|
|
153
166
|
*
|
|
@@ -170,6 +183,9 @@ export class ECDb {
|
|
|
170
183
|
this.abandonChanges();
|
|
171
184
|
throw new IModelError(DbResult.BE_SQLITE_ERROR, `Failed to drop schemas: ${error}`);
|
|
172
185
|
}
|
|
186
|
+
finally {
|
|
187
|
+
this.clearCaches();
|
|
188
|
+
}
|
|
173
189
|
}
|
|
174
190
|
/**
|
|
175
191
|
* Returns the full schema for the input name.
|
|
@@ -428,5 +444,40 @@ export class ECDb {
|
|
|
428
444
|
};
|
|
429
445
|
return new ECSqlReader(executor, ecsql, params, config);
|
|
430
446
|
}
|
|
447
|
+
/** Allow to execute query and read results along with meta data. The result are stepped one by one.
|
|
448
|
+
*
|
|
449
|
+
* See also:
|
|
450
|
+
* - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)
|
|
451
|
+
* - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)
|
|
452
|
+
* - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)
|
|
453
|
+
* @param ecsql The ECSQL query to execute.
|
|
454
|
+
* @param callback the callback to invoke on the prepared ECSqlSyncReader
|
|
455
|
+
* @param params The values to bind to the parameters (if the ECSQL has any).
|
|
456
|
+
* @param config Optional flags which control how query is executed.
|
|
457
|
+
* @returns the value returned by `callback`.
|
|
458
|
+
* @throws IModelError if db is not open or if error occurs during statement execution
|
|
459
|
+
* @beta
|
|
460
|
+
* */
|
|
461
|
+
withQueryReader(ecsql, callback, params, config) {
|
|
462
|
+
if (!this[_nativeDb].isOpen())
|
|
463
|
+
throw new IModelError(DbResult.BE_SQLITE_ERROR, "db not open");
|
|
464
|
+
const executor = new ECSqlRowExecutor(this);
|
|
465
|
+
const reader = new ECSqlSyncReader(executor, ecsql, params, config);
|
|
466
|
+
const release = () => executor[Symbol.dispose]();
|
|
467
|
+
try {
|
|
468
|
+
const val = callback(reader);
|
|
469
|
+
if (val instanceof Promise) {
|
|
470
|
+
val.then(release, release);
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
release();
|
|
474
|
+
}
|
|
475
|
+
return val;
|
|
476
|
+
}
|
|
477
|
+
catch (err) {
|
|
478
|
+
release();
|
|
479
|
+
throw err;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
431
482
|
}
|
|
432
483
|
//# sourceMappingURL=ECDb.js.map
|
package/lib/esm/ECDb.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECDb.js","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":"AAAA;;;+FAG+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C;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gBAAgB;IAChB,IAAW,CAAC,SAAS,CAAC;QACpB,MAAM,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;;;;;;;;;SAWK;IACE,iBAAiB,CAAC,KAAa,EAAE,MAAoB,EAAE,MAAqB;QACjF,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;YAChD,MAAM,IAAI,WAAW,CAAC,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QACjE,CAAC;QACD,MAAM,QAAQ,GAAG;YACf,OAAO,EAAE,KAAK,EAAE,OAAuB,EAAE,EAAE;gBACzC,OAAO,eAAe,CAAC,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC;YACvE,CAAC;SACF,CAAC;QACF,OAAO,IAAI,WAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;CACF","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, 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 { 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\n\r\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\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\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.clearStatementCache();\r\n this[_nativeDb].detachDb(alias);\r\n }\r\n\r\n /** @deprecated in 5.0 - will not be removed until after 2026-06-13. 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._statementCache.clear();\r\n this._sqliteStatementCache.clear();\r\n this[_nativeDb].closeDb();\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 }\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 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 }\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 /**\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 - will not be removed until after 2026-06-13. 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 - will not be removed until after 2026-06-13. 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 - will not be removed until after 2026-06-13. 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 /** Allow to execute query and read results along with meta data. The result are streamed.\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/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, \"db not open\");\r\n }\r\n const executor = {\r\n execute: async (request: DbQueryRequest) => {\r\n return ConcurrentQuery.executeQueryRequest(this[_nativeDb], request);\r\n },\r\n };\r\n return new ECSqlReader(executor, ecsql, params, config);\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,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAElF,OAAO,EAAiC,WAAW,EAAE,WAAW,EAA6B,MAAM,oBAAoB,CAAC;AACxH,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,eAAe,EAA2B,MAAM,mBAAmB,CAAC;AAE7E,MAAM,cAAc,GAAW,qBAAqB,CAAC,IAAI,CAAC;AAE1D;;GAEG;AACH,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,uDAAQ,CAAA;IACR,yDAAS,CAAA;IACT,sGAAsG;IACtG,6DAAW,CAAA;AACb,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAED;;GAEG;AACH,MAAM,OAAO,IAAI;IACP,SAAS,CAAuB;IACxC,4DAA4D;IAC3C,eAAe,GAAG,IAAI,cAAc,EAAkB,CAAC;IAChE,qBAAqB,GAAG,IAAI,cAAc,EAAmB,CAAC;IAEtE,wDAAwD;IACxC,aAAa,GAAG,IAAI,OAAO,EAAc,CAAC;IAE1D;;OAEG;IACI,gBAAgB,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AW,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1D,CAAC;IAED;;;;;;;;;;;;;SAaK;IACE,eAAe,CAAI,KAAa,EAAE,QAAwC,EAAE,MAAoB,EAAE,MAAgC;QACvI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,EAAE;YAC3B,MAAM,IAAI,WAAW,CAAC,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC;QAEjE,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;QAC5C,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;QACpE,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QACjD,IAAI,CAAC;YACH,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","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 { 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 { ECSqlRowExecutor } from \"./ECSqlRowExecutor\";\r\nimport { ECSqlSyncReader, SynchronousQueryOptions } from \"./ECSqlSyncReader\";\r\n\r\nconst loggerCategory: string = BackendLoggerCategory.ECDb;\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\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 - will not be removed until after 2026-06-13. 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._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 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 /**\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 - will not be removed until after 2026-06-13. 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 - will not be removed until after 2026-06-13. 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 - will not be removed until after 2026-06-13. 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 /** Allow to execute query and read results along with meta data. The result are streamed.\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/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, \"db not open\");\r\n }\r\n const executor = {\r\n execute: async (request: DbQueryRequest) => {\r\n return ConcurrentQuery.executeQueryRequest(this[_nativeDb], request);\r\n },\r\n };\r\n return new ECSqlReader(executor, ecsql, params, config);\r\n }\r\n\r\n /** Allow to execute query and read results along with meta data. The result are stepped one by one.\r\n *\r\n * See also:\r\n * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)\r\n * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)\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, \"db not open\");\r\n\r\n const executor = new ECSqlRowExecutor(this);\r\n const reader = new ECSqlSyncReader(executor, ecsql, params, config);\r\n const release = () => executor[Symbol.dispose]();\r\n try {\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"]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { QueryPropertyMetaData } from "@itwin/core-common";
|
|
2
|
+
import { IModelDb } from "./IModelDb";
|
|
3
|
+
import { IModelJsNative } from "@bentley/imodeljs-native";
|
|
4
|
+
import { ECDb } from "./ECDb";
|
|
5
|
+
/**
|
|
6
|
+
* Executes ECSql queries one row at a time against an IModelDb, maintaining statement state between
|
|
7
|
+
* successive calls so the caller can page through results via offset-based requests.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare class ECSqlRowExecutor implements Disposable {
|
|
11
|
+
private readonly _db;
|
|
12
|
+
private _stmt;
|
|
13
|
+
private _removeListener;
|
|
14
|
+
constructor(_db: IModelDb | ECDb);
|
|
15
|
+
/** Disposes the current statement and resets all internal state.
|
|
16
|
+
* Invoked when the db signals that the executor must be recycled.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
private cleanup;
|
|
20
|
+
/** Call this function to dispose the row executor off.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
[Symbol.dispose](): void;
|
|
24
|
+
/** Prepare the statement and bind parameters in one step.
|
|
25
|
+
* Call once during reader initialization — avoids the per-row `ensureStatementReady` check.
|
|
26
|
+
* @param query - The ECSql text to prepare.
|
|
27
|
+
* @param args - Optional bind parameters.
|
|
28
|
+
* @throws IModelError on preparation or binding failure.
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
prepareAndBind(query: string, args?: object): void;
|
|
32
|
+
/** Fast-path: step the cursor once and return row data directly.
|
|
33
|
+
*
|
|
34
|
+
* Returns the row data array if a row is available.
|
|
35
|
+
* Returns `undefined` if the result set is exhausted (DONE).
|
|
36
|
+
*
|
|
37
|
+
* This avoids all intermediate object allocations (StepResult, RowDataResult,
|
|
38
|
+
* DbRuntimeStats, DbQueryResponse) that the general `execute()` path creates per row.
|
|
39
|
+
*
|
|
40
|
+
* @param options - Native row-adaptor options (should be cached and reused across rows).
|
|
41
|
+
* @throws IModelError on step failure or row extraction failure.
|
|
42
|
+
* @internal
|
|
43
|
+
*/
|
|
44
|
+
stepNextRow(options: IModelJsNative.ECSqlRowAdaptorOptions): any;
|
|
45
|
+
/** Get column metadata directly from the prepared statement.
|
|
46
|
+
* Call once after `prepareAndBind` — the metadata does not change between rows.
|
|
47
|
+
* @param options - Native row-adaptor options that influence property naming.
|
|
48
|
+
* @returns Array of column metadata.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
fetchMetadata(options: IModelJsNative.ECSqlRowAdaptorOptions): QueryPropertyMetaData[];
|
|
52
|
+
/** Prepares the ECSql statement against the native database and records the elapsed preparation time.
|
|
53
|
+
* @param ecsql - The ECSql text to prepare.
|
|
54
|
+
* @returns An `OperationResult` indicating success or failure.
|
|
55
|
+
* @internal
|
|
56
|
+
*/
|
|
57
|
+
private prepareStmt;
|
|
58
|
+
/** Resets the statement and binds the given parameter values. Caches the arguments for later
|
|
59
|
+
* comparison so that redundant rebinds can be skipped.
|
|
60
|
+
* @param args - The parameter object to bind, or `undefined` when no parameters are needed.
|
|
61
|
+
* @returns An `OperationResult` indicating success or failure.
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
private bindValues;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=ECSqlRowExecutor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ECSqlRowExecutor.d.ts","sourceRoot":"","sources":["../../src/ECSqlRowExecutor.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAkB9B;;;;GAIG;AACH,qBAAa,gBAAiB,YAAW,UAAU;IAK9B,OAAO,CAAC,QAAQ,CAAC,GAAG;IAHvC,OAAO,CAAC,KAAK,CAAiB;IAC9B,OAAO,CAAC,eAAe,CAAa;gBAEA,GAAG,EAAE,QAAQ,GAAG,IAAI;IAUxD;;;OAGG;IACH,OAAO,CAAC,OAAO;IAIf;;OAEG;IACI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;IAS/B;;;;;;OAMG;IACI,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAazD;;;;;;;;;;;OAWG;IACI,WAAW,CAAC,OAAO,EAAE,cAAc,CAAC,sBAAsB,GAAG,GAAG;IAWvE;;;;;OAKG;IACI,aAAa,CAAC,OAAO,EAAE,cAAc,CAAC,sBAAsB,GAAG,qBAAqB,EAAE;IAQ7F;;;;OAIG;IACH,OAAO,CAAC,WAAW;IASnB;;;;;OAKG;IACH,OAAO,CAAC,UAAU;CAWnB"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { IModelError } from "@itwin/core-common";
|
|
6
|
+
import { ECSqlStatement } from "./ECSqlStatement";
|
|
7
|
+
import { DbResult } from "@itwin/core-bentley";
|
|
8
|
+
import { _nativeDb } from "./internal/Symbols";
|
|
9
|
+
// --------------------------------------------------------------------------------------------
|
|
10
|
+
// ECSqlRowExecutor
|
|
11
|
+
// --------------------------------------------------------------------------------------------
|
|
12
|
+
/**
|
|
13
|
+
* Executes ECSql queries one row at a time against an IModelDb, maintaining statement state between
|
|
14
|
+
* successive calls so the caller can page through results via offset-based requests.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export class ECSqlRowExecutor {
|
|
18
|
+
_db;
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
20
|
+
_stmt;
|
|
21
|
+
_removeListener;
|
|
22
|
+
constructor(_db) {
|
|
23
|
+
this._db = _db;
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
25
|
+
this._stmt = new ECSqlStatement();
|
|
26
|
+
this._removeListener = this._db.onBeforeClose.addListener(() => this.cleanup());
|
|
27
|
+
}
|
|
28
|
+
// --------------------------------------------------------------------------------------------
|
|
29
|
+
// Lifecycle
|
|
30
|
+
// --------------------------------------------------------------------------------------------
|
|
31
|
+
/** Disposes the current statement and resets all internal state.
|
|
32
|
+
* Invoked when the db signals that the executor must be recycled.
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
cleanup() {
|
|
36
|
+
this._stmt[Symbol.dispose]();
|
|
37
|
+
}
|
|
38
|
+
/** Call this function to dispose the row executor off.
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
[Symbol.dispose]() {
|
|
42
|
+
this._removeListener();
|
|
43
|
+
this.cleanup();
|
|
44
|
+
}
|
|
45
|
+
// --------------------------------------------------------------------------------------------
|
|
46
|
+
// Core execution
|
|
47
|
+
// --------------------------------------------------------------------------------------------
|
|
48
|
+
/** Prepare the statement and bind parameters in one step.
|
|
49
|
+
* Call once during reader initialization — avoids the per-row `ensureStatementReady` check.
|
|
50
|
+
* @param query - The ECSql text to prepare.
|
|
51
|
+
* @param args - Optional bind parameters.
|
|
52
|
+
* @throws IModelError on preparation or binding failure.
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
prepareAndBind(query, args) {
|
|
56
|
+
const prepResult = this.prepareStmt(query);
|
|
57
|
+
if (!prepResult.isSuccessful)
|
|
58
|
+
throw new IModelError(DbResult.BE_SQLITE_ERROR, prepResult.message ?? `Failed to prepare statement: ${query}`);
|
|
59
|
+
if (args) {
|
|
60
|
+
const bindResult = this.bindValues(args);
|
|
61
|
+
if (!bindResult.isSuccessful)
|
|
62
|
+
throw new IModelError(DbResult.BE_SQLITE_ERROR, bindResult.message ?? `Failed to bind values: ${query}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/** Fast-path: step the cursor once and return row data directly.
|
|
66
|
+
*
|
|
67
|
+
* Returns the row data array if a row is available.
|
|
68
|
+
* Returns `undefined` if the result set is exhausted (DONE).
|
|
69
|
+
*
|
|
70
|
+
* This avoids all intermediate object allocations (StepResult, RowDataResult,
|
|
71
|
+
* DbRuntimeStats, DbQueryResponse) that the general `execute()` path creates per row.
|
|
72
|
+
*
|
|
73
|
+
* @param options - Native row-adaptor options (should be cached and reused across rows).
|
|
74
|
+
* @throws IModelError on step failure or row extraction failure.
|
|
75
|
+
* @internal
|
|
76
|
+
*/
|
|
77
|
+
stepNextRow(options) {
|
|
78
|
+
if (!this._stmt.isPrepared)
|
|
79
|
+
throw new IModelError(DbResult.BE_SQLITE_ERROR, "Statement is not prepared. Likely cause: the db was closed before step is called or the ECSqlSyncReader is used outside the context of the callback passed to withQueryReader.");
|
|
80
|
+
const stepResult = this._stmt.step();
|
|
81
|
+
if (stepResult === DbResult.BE_SQLITE_ROW)
|
|
82
|
+
return this._stmt.toRow(options).data;
|
|
83
|
+
if (stepResult === DbResult.BE_SQLITE_DONE)
|
|
84
|
+
return undefined;
|
|
85
|
+
throw new IModelError(stepResult, `Step failed with code ${stepResult}`);
|
|
86
|
+
}
|
|
87
|
+
/** Get column metadata directly from the prepared statement.
|
|
88
|
+
* Call once after `prepareAndBind` — the metadata does not change between rows.
|
|
89
|
+
* @param options - Native row-adaptor options that influence property naming.
|
|
90
|
+
* @returns Array of column metadata.
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
fetchMetadata(options) {
|
|
94
|
+
return this._stmt.getMetadata(options).properties;
|
|
95
|
+
}
|
|
96
|
+
// --------------------------------------------------------------------------------------------
|
|
97
|
+
// Execution phases
|
|
98
|
+
// --------------------------------------------------------------------------------------------
|
|
99
|
+
/** Prepares the ECSql statement against the native database and records the elapsed preparation time.
|
|
100
|
+
* @param ecsql - The ECSql text to prepare.
|
|
101
|
+
* @returns An `OperationResult` indicating success or failure.
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
prepareStmt(ecsql) {
|
|
105
|
+
try {
|
|
106
|
+
this._stmt.prepare(this._db[_nativeDb], ecsql);
|
|
107
|
+
return { isSuccessful: true };
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
return { isSuccessful: false, message: error.message };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** Resets the statement and binds the given parameter values. Caches the arguments for later
|
|
114
|
+
* comparison so that redundant rebinds can be skipped.
|
|
115
|
+
* @param args - The parameter object to bind, or `undefined` when no parameters are needed.
|
|
116
|
+
* @returns An `OperationResult` indicating success or failure.
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
119
|
+
bindValues(args) {
|
|
120
|
+
try {
|
|
121
|
+
if (args === undefined)
|
|
122
|
+
return { isSuccessful: true };
|
|
123
|
+
this._stmt.bindParams(args);
|
|
124
|
+
return { isSuccessful: true };
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
return { isSuccessful: false, message: error.message };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=ECSqlRowExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ECSqlRowExecutor.js","sourceRoot":"","sources":["../../src/ECSqlRowExecutor.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,WAAW,EAAyB,MAAM,oBAAoB,CAAC;AAExE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE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,IAAI,KAAK,SAAS;gBACpB,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;YAEhC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAC5B,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;QAChC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;QACzD,CAAC;IACH,CAAC;CACF","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\r\nimport { IModelError, QueryPropertyMetaData } from \"@itwin/core-common\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { DbResult } from \"@itwin/core-bentley\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { _nativeDb } from \"./internal/Symbols\";\r\nimport { ECDb } from \"./ECDb\";\r\n\r\n// --------------------------------------------------------------------------------------------\r\n// Internal result types\r\n// --------------------------------------------------------------------------------------------\r\n\r\n/** Result of an internal operation that may fail with a message.\r\n * @internal\r\n */\r\ninterface OperationResult {\r\n isSuccessful: boolean;\r\n message?: string;\r\n}\r\n\r\n// --------------------------------------------------------------------------------------------\r\n// ECSqlRowExecutor\r\n// --------------------------------------------------------------------------------------------\r\n\r\n/**\r\n * Executes ECSql queries one row at a time against an IModelDb, maintaining statement state between\r\n * successive calls so the caller can page through results via offset-based requests.\r\n * @internal\r\n */\r\nexport class ECSqlRowExecutor implements Disposable {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n private _stmt: ECSqlStatement;\r\n private _removeListener: () => void;\r\n\r\n public constructor(private readonly _db: IModelDb | ECDb) {\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n this._stmt = new ECSqlStatement();\r\n this._removeListener = this._db.onBeforeClose.addListener(() => this.cleanup());\r\n }\r\n\r\n // --------------------------------------------------------------------------------------------\r\n // Lifecycle\r\n // --------------------------------------------------------------------------------------------\r\n\r\n /** Disposes the current statement and resets all internal state.\r\n * Invoked when the db signals that the executor must be recycled.\r\n * @internal\r\n */\r\n private cleanup(): void {\r\n this._stmt[Symbol.dispose]();\r\n }\r\n\r\n /** Call this function to dispose the row executor off.\r\n * @internal\r\n */\r\n public [Symbol.dispose](): void {\r\n this._removeListener();\r\n this.cleanup();\r\n }\r\n\r\n // --------------------------------------------------------------------------------------------\r\n // Core execution\r\n // --------------------------------------------------------------------------------------------\r\n\r\n /** Prepare the statement and bind parameters in one step.\r\n * Call once during reader initialization — avoids the per-row `ensureStatementReady` check.\r\n * @param query - The ECSql text to prepare.\r\n * @param args - Optional bind parameters.\r\n * @throws IModelError on preparation or binding failure.\r\n * @internal\r\n */\r\n public prepareAndBind(query: string, args?: object): void {\r\n\r\n const prepResult = this.prepareStmt(query);\r\n if (!prepResult.isSuccessful)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, prepResult.message ?? `Failed to prepare statement: ${query}`);\r\n\r\n if (args) {\r\n const bindResult = this.bindValues(args);\r\n if (!bindResult.isSuccessful)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, bindResult.message ?? `Failed to bind values: ${query}`);\r\n }\r\n }\r\n\r\n /** Fast-path: step the cursor once and return row data directly.\r\n *\r\n * Returns the row data array if a row is available.\r\n * Returns `undefined` if the result set is exhausted (DONE).\r\n *\r\n * This avoids all intermediate object allocations (StepResult, RowDataResult,\r\n * DbRuntimeStats, DbQueryResponse) that the general `execute()` path creates per row.\r\n *\r\n * @param options - Native row-adaptor options (should be cached and reused across rows).\r\n * @throws IModelError on step failure or row extraction failure.\r\n * @internal\r\n */\r\n public stepNextRow(options: IModelJsNative.ECSqlRowAdaptorOptions): any {\r\n if (!this._stmt.isPrepared)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, \"Statement is not prepared. Likely cause: the db was closed before step is called or the ECSqlSyncReader is used outside the context of the callback passed to withQueryReader.\");\r\n const stepResult = this._stmt.step();\r\n if (stepResult === DbResult.BE_SQLITE_ROW)\r\n return this._stmt.toRow(options).data;\r\n if (stepResult === DbResult.BE_SQLITE_DONE)\r\n return undefined;\r\n throw new IModelError(stepResult, `Step failed with code ${stepResult}`);\r\n }\r\n\r\n /** Get column metadata directly from the prepared statement.\r\n * Call once after `prepareAndBind` — the metadata does not change between rows.\r\n * @param options - Native row-adaptor options that influence property naming.\r\n * @returns Array of column metadata.\r\n * @internal\r\n */\r\n public fetchMetadata(options: IModelJsNative.ECSqlRowAdaptorOptions): QueryPropertyMetaData[] {\r\n return this._stmt.getMetadata(options).properties;\r\n }\r\n\r\n // --------------------------------------------------------------------------------------------\r\n // Execution phases\r\n // --------------------------------------------------------------------------------------------\r\n\r\n /** Prepares the ECSql statement against the native database and records the elapsed preparation time.\r\n * @param ecsql - The ECSql text to prepare.\r\n * @returns An `OperationResult` indicating success or failure.\r\n * @internal\r\n */\r\n private prepareStmt(ecsql: string): OperationResult {\r\n try {\r\n this._stmt.prepare(this._db[_nativeDb], ecsql);\r\n return { isSuccessful: true };\r\n } catch (error: any) {\r\n return { isSuccessful: false, message: error.message };\r\n }\r\n }\r\n\r\n /** Resets the statement and binds the given parameter values. Caches the arguments for later\r\n * comparison so that redundant rebinds can be skipped.\r\n * @param args - The parameter object to bind, or `undefined` when no parameters are needed.\r\n * @returns An `OperationResult` indicating success or failure.\r\n * @internal\r\n */\r\n private bindValues(args: object | undefined): OperationResult {\r\n try {\r\n if (args === undefined)\r\n return { isSuccessful: true };\r\n\r\n this._stmt.bindParams(args);\r\n return { isSuccessful: true };\r\n } catch (error: any) {\r\n return { isSuccessful: false, message: error.message };\r\n }\r\n }\r\n}"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { DbResult, GuidString, Id64String } from "@itwin/core-bentley";
|
|
5
5
|
import { LowAndHighXYZ, XAndY, XYAndZ } from "@itwin/core-geometry";
|
|
6
|
-
import { ECSqlValueType, NavigationBindingValue, NavigationValue, QueryRowFormat } from "@itwin/core-common";
|
|
6
|
+
import { ECSqlValueType, NavigationBindingValue, NavigationValue, PropertyMetaDataMap, QueryRowFormat } from "@itwin/core-common";
|
|
7
7
|
import { IModelJsNative } from "@bentley/imodeljs-native";
|
|
8
8
|
/** The result of an **ECSQL INSERT** statement as returned from [ECSqlStatement.stepForInsert]($backend).
|
|
9
9
|
*
|
|
@@ -240,6 +240,18 @@ export declare class ECSqlStatement implements IterableIterator<any>, Disposable
|
|
|
240
240
|
* - [Code Samples]($docs/learning/backend/ECSQLCodeExamples#working-with-the-query-result)
|
|
241
241
|
*/
|
|
242
242
|
getRow(args?: ECSqlRowArg): any;
|
|
243
|
+
/**
|
|
244
|
+
* Used by ECSqlRowExecutor to get row data as json with options determined by request parameters.
|
|
245
|
+
* @internal */
|
|
246
|
+
toRow(args: IModelJsNative.ECSqlRowAdaptorOptions): any;
|
|
247
|
+
/**
|
|
248
|
+
* Used by ECSqlRowExecutor to get metadata as json.
|
|
249
|
+
* @internal */
|
|
250
|
+
getMetadata(args: IModelJsNative.ECSqlRowAdaptorOptions): PropertyMetaDataMap;
|
|
251
|
+
/**
|
|
252
|
+
* Used by ECSqlRowExecutor to bind params to the statement.
|
|
253
|
+
* @internal */
|
|
254
|
+
bindParams(args: object): void;
|
|
243
255
|
private formatCurrentRow;
|
|
244
256
|
/** Calls step when called as an iterator.
|
|
245
257
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECSqlStatement.d.ts","sourceRoot":"","sources":["../../src/ECSqlStatement.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAW,KAAK,EAAE,MAAM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