@itwin/core-backend 5.14.0-dev.9 → 5.14.2

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.
Files changed (160) hide show
  1. package/CHANGELOG.md +67 -1
  2. package/lib/cjs/BriefcaseManager.d.ts +2 -2
  3. package/lib/cjs/BriefcaseManager.js.map +1 -1
  4. package/lib/cjs/ChangesetReader.d.ts +1 -1
  5. package/lib/cjs/ChangesetReader.js +2 -2
  6. package/lib/cjs/ChangesetReader.js.map +1 -1
  7. package/lib/cjs/ChangesetReaderTypes.d.ts +5 -2
  8. package/lib/cjs/ChangesetReaderTypes.d.ts.map +1 -1
  9. package/lib/cjs/ChangesetReaderTypes.js +3 -0
  10. package/lib/cjs/ChangesetReaderTypes.js.map +1 -1
  11. package/lib/cjs/ECDb.d.ts +63 -6
  12. package/lib/cjs/ECDb.d.ts.map +1 -1
  13. package/lib/cjs/ECDb.js +62 -6
  14. package/lib/cjs/ECDb.js.map +1 -1
  15. package/lib/cjs/ECSqlRowExecutor.d.ts +3 -3
  16. package/lib/cjs/ECSqlRowExecutor.d.ts.map +1 -1
  17. package/lib/cjs/ECSqlRowExecutor.js +2 -2
  18. package/lib/cjs/ECSqlRowExecutor.js.map +1 -1
  19. package/lib/cjs/ECSqlStatement.d.ts +7 -2
  20. package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
  21. package/lib/cjs/ECSqlStatement.js +17 -4
  22. package/lib/cjs/ECSqlStatement.js.map +1 -1
  23. package/lib/cjs/ECSqlSyncReader.d.ts.map +1 -1
  24. package/lib/cjs/ECSqlSyncReader.js +2 -2
  25. package/lib/cjs/ECSqlSyncReader.js.map +1 -1
  26. package/lib/cjs/Element.d.ts.map +1 -1
  27. package/lib/cjs/Element.js +6 -3
  28. package/lib/cjs/Element.js.map +1 -1
  29. package/lib/cjs/IModelDb.d.ts +12 -10
  30. package/lib/cjs/IModelDb.d.ts.map +1 -1
  31. package/lib/cjs/IModelDb.js +26 -12
  32. package/lib/cjs/IModelDb.js.map +1 -1
  33. package/lib/cjs/SchemaSync.d.ts +2 -2
  34. package/lib/cjs/SchemaSync.d.ts.map +1 -1
  35. package/lib/cjs/SchemaSync.js +2 -2
  36. package/lib/cjs/SchemaSync.js.map +1 -1
  37. package/lib/cjs/SqliteChangesetReader.d.ts +16 -8
  38. package/lib/cjs/SqliteChangesetReader.d.ts.map +1 -1
  39. package/lib/cjs/SqliteChangesetReader.js +11 -1
  40. package/lib/cjs/SqliteChangesetReader.js.map +1 -1
  41. package/lib/cjs/TxnManager.d.ts.map +1 -1
  42. package/lib/cjs/TxnManager.js +4 -0
  43. package/lib/cjs/TxnManager.js.map +1 -1
  44. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +90 -5
  45. package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  46. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js +59 -1
  47. package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  48. package/lib/cjs/internal/annotations/fieldSpecs.d.ts +82 -0
  49. package/lib/cjs/internal/annotations/fieldSpecs.d.ts.map +1 -0
  50. package/lib/cjs/internal/annotations/fieldSpecs.js +187 -0
  51. package/lib/cjs/internal/annotations/fieldSpecs.js.map +1 -0
  52. package/lib/cjs/internal/annotations/fields.d.ts +39 -2
  53. package/lib/cjs/internal/annotations/fields.d.ts.map +1 -1
  54. package/lib/cjs/internal/annotations/fields.js +140 -13
  55. package/lib/cjs/internal/annotations/fields.js.map +1 -1
  56. package/lib/esm/BriefcaseManager.d.ts +2 -2
  57. package/lib/esm/BriefcaseManager.js.map +1 -1
  58. package/lib/esm/ChangesetReader.d.ts +1 -1
  59. package/lib/esm/ChangesetReader.js +2 -2
  60. package/lib/esm/ChangesetReader.js.map +1 -1
  61. package/lib/esm/ChangesetReaderTypes.d.ts +5 -2
  62. package/lib/esm/ChangesetReaderTypes.d.ts.map +1 -1
  63. package/lib/esm/ChangesetReaderTypes.js +3 -0
  64. package/lib/esm/ChangesetReaderTypes.js.map +1 -1
  65. package/lib/esm/ECDb.d.ts +63 -6
  66. package/lib/esm/ECDb.d.ts.map +1 -1
  67. package/lib/esm/ECDb.js +62 -6
  68. package/lib/esm/ECDb.js.map +1 -1
  69. package/lib/esm/ECSqlRowExecutor.d.ts +3 -3
  70. package/lib/esm/ECSqlRowExecutor.d.ts.map +1 -1
  71. package/lib/esm/ECSqlRowExecutor.js +2 -2
  72. package/lib/esm/ECSqlRowExecutor.js.map +1 -1
  73. package/lib/esm/ECSqlStatement.d.ts +7 -2
  74. package/lib/esm/ECSqlStatement.d.ts.map +1 -1
  75. package/lib/esm/ECSqlStatement.js +17 -4
  76. package/lib/esm/ECSqlStatement.js.map +1 -1
  77. package/lib/esm/ECSqlSyncReader.d.ts.map +1 -1
  78. package/lib/esm/ECSqlSyncReader.js +3 -3
  79. package/lib/esm/ECSqlSyncReader.js.map +1 -1
  80. package/lib/esm/Element.d.ts.map +1 -1
  81. package/lib/esm/Element.js +6 -3
  82. package/lib/esm/Element.js.map +1 -1
  83. package/lib/esm/IModelDb.d.ts +12 -10
  84. package/lib/esm/IModelDb.d.ts.map +1 -1
  85. package/lib/esm/IModelDb.js +26 -12
  86. package/lib/esm/IModelDb.js.map +1 -1
  87. package/lib/esm/SchemaSync.d.ts +2 -2
  88. package/lib/esm/SchemaSync.d.ts.map +1 -1
  89. package/lib/esm/SchemaSync.js +2 -2
  90. package/lib/esm/SchemaSync.js.map +1 -1
  91. package/lib/esm/SqliteChangesetReader.d.ts +16 -8
  92. package/lib/esm/SqliteChangesetReader.d.ts.map +1 -1
  93. package/lib/esm/SqliteChangesetReader.js +11 -1
  94. package/lib/esm/SqliteChangesetReader.js.map +1 -1
  95. package/lib/esm/TxnManager.d.ts.map +1 -1
  96. package/lib/esm/TxnManager.js +4 -0
  97. package/lib/esm/TxnManager.js.map +1 -1
  98. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +90 -5
  99. package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
  100. package/lib/esm/annotations/ElementDrivesTextAnnotation.js +60 -2
  101. package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
  102. package/lib/esm/internal/annotations/fieldSpecs.d.ts +82 -0
  103. package/lib/esm/internal/annotations/fieldSpecs.d.ts.map +1 -0
  104. package/lib/esm/internal/annotations/fieldSpecs.js +179 -0
  105. package/lib/esm/internal/annotations/fieldSpecs.js.map +1 -0
  106. package/lib/esm/internal/annotations/fields.d.ts +39 -2
  107. package/lib/esm/internal/annotations/fields.d.ts.map +1 -1
  108. package/lib/esm/internal/annotations/fields.js +140 -13
  109. package/lib/esm/internal/annotations/fields.js.map +1 -1
  110. package/lib/esm/test/AnnotationTestUtils.d.ts +9 -0
  111. package/lib/esm/test/AnnotationTestUtils.d.ts.map +1 -1
  112. package/lib/esm/test/AnnotationTestUtils.js +17 -0
  113. package/lib/esm/test/AnnotationTestUtils.js.map +1 -1
  114. package/lib/esm/test/annotations/FieldFormat.test.d.ts +2 -0
  115. package/lib/esm/test/annotations/FieldFormat.test.d.ts.map +1 -0
  116. package/lib/esm/test/annotations/FieldFormat.test.js +738 -0
  117. package/lib/esm/test/annotations/FieldFormat.test.js.map +1 -0
  118. package/lib/esm/test/annotations/FieldFormattingLifecycle.test.d.ts +2 -0
  119. package/lib/esm/test/annotations/FieldFormattingLifecycle.test.d.ts.map +1 -0
  120. package/lib/esm/test/annotations/FieldFormattingLifecycle.test.js +323 -0
  121. package/lib/esm/test/annotations/FieldFormattingLifecycle.test.js.map +1 -0
  122. package/lib/esm/test/annotations/FieldSpecs.test.d.ts +2 -0
  123. package/lib/esm/test/annotations/FieldSpecs.test.d.ts.map +1 -0
  124. package/lib/esm/test/annotations/FieldSpecs.test.js +54 -0
  125. package/lib/esm/test/annotations/FieldSpecs.test.js.map +1 -0
  126. package/lib/esm/test/annotations/Fields.test.js +221 -27
  127. package/lib/esm/test/annotations/Fields.test.js.map +1 -1
  128. package/lib/esm/test/ecdb/CSVImport.test.d.ts +2 -0
  129. package/lib/esm/test/ecdb/CSVImport.test.d.ts.map +1 -0
  130. package/lib/esm/test/ecdb/CSVImport.test.js +186 -0
  131. package/lib/esm/test/ecdb/CSVImport.test.js.map +1 -0
  132. package/lib/esm/test/ecdb/ConcurrentQuery.test.js +19 -2
  133. package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
  134. package/lib/esm/test/ecdb/ECSqlSyncReader.test.js +140 -0
  135. package/lib/esm/test/ecdb/ECSqlSyncReader.test.js.map +1 -1
  136. package/lib/esm/test/ecdb/QueryReaders.test.js +105 -30
  137. package/lib/esm/test/ecdb/QueryReaders.test.js.map +1 -1
  138. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.d.ts.map +1 -1
  139. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js +7 -0
  140. package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js.map +1 -1
  141. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js +86 -7
  142. package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
  143. package/lib/esm/test/hubaccess/CodeSwap.test.js +78 -0
  144. package/lib/esm/test/hubaccess/CodeSwap.test.js.map +1 -1
  145. package/lib/esm/test/imodel/IModelElements.test.js +5 -0
  146. package/lib/esm/test/imodel/IModelElements.test.js.map +1 -1
  147. package/lib/esm/test/imodel/IModelGeolocation.test.js +3 -3
  148. package/lib/esm/test/imodel/IModelGeolocation.test.js.map +1 -1
  149. package/lib/esm/test/standalone/ChangesetReader.test.js +111 -2
  150. package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
  151. package/lib/esm/test/standalone/DgnDomainMergeConflict.test.js +61 -0
  152. package/lib/esm/test/standalone/DgnDomainMergeConflict.test.js.map +1 -1
  153. package/lib/esm/test/standalone/SQLiteDb.test.d.ts.map +1 -1
  154. package/lib/esm/test/standalone/SQLiteDb.test.js +116 -0
  155. package/lib/esm/test/standalone/SQLiteDb.test.js.map +1 -1
  156. package/lib/esm/test/standalone/SessionApplyIndirect.test.d.ts +2 -0
  157. package/lib/esm/test/standalone/SessionApplyIndirect.test.d.ts.map +1 -0
  158. package/lib/esm/test/standalone/SessionApplyIndirect.test.js +211 -0
  159. package/lib/esm/test/standalone/SessionApplyIndirect.test.js.map +1 -0
  160. package/package.json +15 -13
@@ -1 +1 @@
1
- {"version":3,"file":"ECDb.js","sourceRoot":"","sources":["../../src/ECDb.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAkF;AAElF,oDAAwH;AACxH,mEAAgE;AAChE,uDAAoD;AACpD,qDAAuE;AACvE,8DAAyD;AACzD,uDAAoE;AACpE,gDAA+C;AAC/C,yDAA6E;AAC7E,uDAA6E;AAE7E,MAAM,cAAc,GAAW,6CAAqB,CAAC,IAAI,CAAC;AAE1D;;GAEG;AACH,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,uDAAQ,CAAA;IACR,yDAAS,CAAA;IACT,sGAAsG;IACtG,6DAAW,CAAA;AACb,CAAC,EALW,YAAY,4BAAZ,YAAY,QAKvB;AAED;;GAEG;AACH,MAAa,IAAI;IACP,SAAS,CAAuB;IACxC,4DAA4D;IAC3C,eAAe,GAAG,IAAI,gCAAc,EAAkB,CAAC;IAChE,qBAAqB,GAAG,IAAI,gCAAc,EAAmB,CAAC;IAEtE,wDAAwD;IACxC,aAAa,GAAG,IAAI,sBAAO,EAAc,CAAC;IAE1D;;OAEG;IACI,gBAAgB,CAAC,IAAY;QAClC,IAAI,CAAC,qBAAqB,CAAC,KAAK,EAAE,CAAC;QACnC,IAAI,CAAC,qBAAqB,GAAG,IAAI,gCAAc,CAAkB,IAAI,CAAC,CAAC;IACzE,CAAC;IAED;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,6BAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IACpD,CAAC;IACD;;OAEG;IACI,CAAC,MAAM,CAAC,OAAO,CAAC;QACrB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C,MAAM,EAAE;YAC3B,MAAM,IAAI,yBAAW,CAAC,uBAAQ,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC;QAEzE,4DAA4D;QAC5D,MAAM,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,IAAI,+BAAc,EAAE,CAAC;QAC/E,MAAM,QAAQ,GAAG,IAAI,mCAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QAClE,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,IAAA,wCAAqB,EAAC,IAAI,EAAE,IAAI,CAAC,eAAe,EAAE,cAAc,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAAC;QAChG,CAAC,CAAC;QACF,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;AAvdD,oBAudC","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, releaseECSqlStatement } 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 - 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._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 /**\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 /** 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_NOTOPEN, \"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_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,oDAAwH;AACxH,qCAAoC;AACpC,mEAAgE;AAChE,uDAAoD;AACpD,qDAAuE;AACvE,8DAAyD;AACzD,uDAAoE;AACpE,gDAA+C;AAC/C,yDAA6E;AAC7E,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,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,IAAI,SAAS,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,IAAI,QAAQ,KAAK,OAAO,KAAK;YACpE,MAAM,IAAI,SAAS,CAAC,mCAAmC,CAAC,CAAC;QAC3D,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,WAAW,GAAG,CAAC,IAAI,KAAK,CAA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AAI,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;AAhgBD,oBAggBC","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 { 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\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._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 ConcurrentQuery.executeQueryRequest(this[_nativeDb], request);\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,4 +1,4 @@
1
- import { QueryPropertyMetaData } from "@itwin/core-common";
1
+ import { PropertyMetaDataMap } from "@itwin/core-common";
2
2
  import type { IModelDb } from "./IModelDb";
3
3
  import { ECSqlStatement } from "./ECSqlStatement";
4
4
  import { IModelJsNative } from "@bentley/imodeljs-native";
@@ -59,10 +59,10 @@ export declare class ECSqlRowExecutor implements Disposable {
59
59
  /** Get column metadata directly from the prepared statement.
60
60
  * Call once after `prepareAndBind` — the metadata does not change between rows.
61
61
  * @param options - Native row-adaptor options that influence property naming.
62
- * @returns Array of column metadata.
62
+ * @returns Column metadata owned by the caller.
63
63
  * @internal
64
64
  */
65
- fetchMetadata(options: IModelJsNative.ECSqlRowAdaptorOptions): QueryPropertyMetaData[];
65
+ fetchMetadata(options: IModelJsNative.ECSqlRowAdaptorOptions): PropertyMetaDataMap;
66
66
  /** Prepares the ECSql statement when the caller did not supply one from its cache.
67
67
  * @param ecsql - The ECSql text to prepare.
68
68
  * @returns An `OperationResult` indicating success or failure.
@@ -1 +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,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAYxD;;GAEG;AAEH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,cAAc,CAAC,cAAc,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAoBlJ;AAkBD;;;;GAIG;AACH,qBAAa,gBAAiB,YAAW,UAAU;IAW9B,OAAO,CAAC,QAAQ,CAAC,GAAG;IAAmB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAAkB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAVlI,OAAO,CAAC,eAAe,CAAa;IACpC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,kBAAkB,CAAQ;IAElC;;OAEG;IACH,IAAW,iBAAiB,IAAI,OAAO,CAAoC;gBAGvC,GAAG,EAAE,QAAQ,GAAG,IAAI,EAAmB,KAAK,EAAE,cAAc,EAAmB,eAAe,EAAE,MAAM;IAQ1I;;;;OAIG;IACH,OAAO,CAAC,OAAO;IASf;;OAEG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AO,CAAC,kBAAkB,CAAQ;IAElC;;OAEG;IACH,IAAW,iBAAiB,IAAI,OAAO,CAAoC;gBAGvC,GAAG,EAAE,QAAQ,GAAG,IAAI,EAAmB,KAAK,EAAE,cAAc,EAAmB,eAAe,EAAE,MAAM;IAQ1I;;;;OAIG;IACH,OAAO,CAAC,OAAO;IASf;;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,mBAAmB;IAUzF;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAkBnB;;;;OAIG;IACH,OAAO,CAAC,UAAU;CAcnB"}
@@ -140,13 +140,13 @@ class ECSqlRowExecutor {
140
140
  /** Get column metadata directly from the prepared statement.
141
141
  * Call once after `prepareAndBind` — the metadata does not change between rows.
142
142
  * @param options - Native row-adaptor options that influence property naming.
143
- * @returns Array of column metadata.
143
+ * @returns Column metadata owned by the caller.
144
144
  * @internal
145
145
  */
146
146
  fetchMetadata(options) {
147
147
  if (this._isDisposed || !this._stmt.isPrepared)
148
148
  throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, statementNotPreparedMessage);
149
- return this._stmt.getMetadata(options).properties;
149
+ return this._stmt.getMetadata(options);
150
150
  }
151
151
  // --------------------------------------------------------------------------------------------
152
152
  // Execution phases
@@ -1 +1 @@
1
- {"version":3,"file":"ECSqlRowExecutor.js","sourceRoot":"","sources":["../../src/ECSqlRowExecutor.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAyB/F,sDAoBC;AA3CD,oDAAwE;AAGxE,sDAAqE;AAErE,gDAA+C;A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,UAAU;YACvB,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;QAEhC,IAAI,CAAC;YACH,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,mBAAS,CAAC,EAAE,KAAK,CAAC,CAAC;YAC/C,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;QAChC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;YAChC,IAAI,CAAC;gBACH,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,CAAC;YAAC,OAAO,YAAY,EAAE,CAAC;gBACtB,wBAAwB,CAAC,IAAI,CAAC,eAAe,EAAE,gEAAgE,EAAE,YAAY,CAAC,CAAC;YACjI,CAAC;YACD,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;QACzD,CAAC;IACH,CAAC;IAED;;;;OAIG;IACK,UAAU,CAAC,IAAwB;QACzC,IAAI,CAAC;YACH,IAAI,IAAI,KAAK,SAAS;gBACpB,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;YAEhC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU;gBACxB,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC;YAEvE,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;AAlJD,4CAkJC","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 type { IModelDb } from \"./IModelDb\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { BentleyError, DbResult, Logger } from \"@itwin/core-bentley\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { _nativeDb } from \"./internal/Symbols\";\r\nimport type { ECDb } from \"./ECDb\";\r\nimport type { StatementCache } from \"./SqliteStatement\";\r\n\r\nconst statementNotPreparedMessage = \"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\r\nfunction logStatementCleanupError(loggerCategory: string, message: string, error: unknown): void {\r\n try {\r\n Logger.logTrace(loggerCategory, message, () => ({ error: BentleyError.getErrorMessage(error) }));\r\n } catch {\r\n // Cleanup diagnostics must not replace the original query error.\r\n }\r\n}\r\n\r\n/** Returns a statement to its cache, falling back to direct disposal without throwing.\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/no-deprecated\r\nexport function releaseECSqlStatement(stmt: ECSqlStatement, cache: StatementCache<ECSqlStatement>, loggerCategory: string, canCache: boolean): void {\r\n if (!canCache || !stmt.isPrepared) {\r\n try {\r\n stmt[Symbol.dispose]();\r\n } catch (error) {\r\n logStatementCleanupError(loggerCategory, \"Failed to dispose an ECSQL statement that could not be cached.\", error);\r\n }\r\n return;\r\n }\r\n\r\n try {\r\n cache.addOrDispose(stmt);\r\n } catch (error) {\r\n try {\r\n stmt[Symbol.dispose]();\r\n } catch (disposeError) {\r\n logStatementCleanupError(loggerCategory, \"Failed to dispose an ECSQL statement after it could not be returned to the statement cache.\", disposeError);\r\n }\r\n logStatementCleanupError(loggerCategory, \"Failed to return an ECSQL statement to the statement cache; attempted direct disposal instead.\", error);\r\n }\r\n}\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 private _removeListener: () => void;\r\n private _isDisposed = false;\r\n private _canCacheStatement = true;\r\n\r\n /** Whether the statement completed preparation and can be returned to its cache.\r\n * @internal\r\n */\r\n public get canCacheStatement(): boolean { return this._canCacheStatement; }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public constructor(private readonly _db: IModelDb | ECDb, private readonly _stmt: ECSqlStatement, private readonly _loggerCategory: string) {\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 currently held statement without returning it to the cache.\r\n * Invoked when the db signals it is closing (the statement cache is cleared on close, so the\r\n * checked-out statement must be disposed directly to avoid a use-after-free or double dispose).\r\n * @internal\r\n */\r\n private cleanup(): void {\r\n this._isDisposed = true;\r\n try {\r\n this._stmt[Symbol.dispose]();\r\n } catch (error) {\r\n logStatementCleanupError(this._loggerCategory, \"Failed to dispose an ECSQL statement while closing its database.\", error);\r\n }\r\n }\r\n\r\n /** Removes the database-close listener owned by this row executor.\r\n * @internal\r\n */\r\n public [Symbol.dispose](): void {\r\n this._isDisposed = true;\r\n this._removeListener();\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._isDisposed || !this._stmt.isPrepared)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, statementNotPreparedMessage);\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 if (this._isDisposed || !this._stmt.isPrepared)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, statementNotPreparedMessage);\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 when the caller did not supply one from its cache.\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 if (this._stmt.isPrepared)\r\n return { isSuccessful: true };\r\n\r\n try {\r\n this._stmt.prepare(this._db[_nativeDb], ecsql);\r\n return { isSuccessful: true };\r\n } catch (error: any) {\r\n this._canCacheStatement = false;\r\n try {\r\n this._stmt[Symbol.dispose]();\r\n } catch (disposeError) {\r\n logStatementCleanupError(this._loggerCategory, \"Failed to dispose an ECSQL statement after preparation failed.\", disposeError);\r\n }\r\n return { isSuccessful: false, message: error.message };\r\n }\r\n }\r\n\r\n /** Binds the supplied parameter values to the prepared statement.\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 if (!this._stmt.isPrepared)\r\n return { isSuccessful: false, message: statementNotPreparedMessage };\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}"]}
1
+ {"version":3,"file":"ECSqlRowExecutor.js","sourceRoot":"","sources":["../../src/ECSqlRowExecutor.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAyB/F,sDAoBC;AA3CD,oDAAsE;AAGtE,sDAAqE;AAErE,gDAA+C;AAI/C,MAAM,2BAA2B,GAAG,gLAAgL,CAAC;AAErN,SAAS,wBAAwB,CAAC,cAAsB,EAAE,OAAe,EAAE,KAAc;IACvF,IAAI,CAAC;QACH,qBAAM,CAAC,QAAQ,CAAC,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AAK,CAAC,CAAC;YAC/C,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;QAChC,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;YAChC,IAAI,CAAC;gBACH,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/B,CAAC;YAAC,OAAO,YAAY,EAAE,CAAC;gBACtB,wBAAwB,CAAC,IAAI,CAAC,eAAe,EAAE,gEAAgE,EAAE,YAAY,CAAC,CAAC;YACjI,CAAC;YACD,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;QACzD,CAAC;IACH,CAAC;IAED;;;;OAIG;IACK,UAAU,CAAC,IAAwB;QACzC,IAAI,CAAC;YACH,IAAI,IAAI,KAAK,SAAS;gBACpB,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;YAEhC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU;gBACxB,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,EAAE,2BAA2B,EAAE,CAAC;YAEvE,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;AAlJD,4CAkJC","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, PropertyMetaDataMap } from \"@itwin/core-common\";\r\nimport type { IModelDb } from \"./IModelDb\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { BentleyError, DbResult, Logger } from \"@itwin/core-bentley\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { _nativeDb } from \"./internal/Symbols\";\r\nimport type { ECDb } from \"./ECDb\";\r\nimport type { StatementCache } from \"./SqliteStatement\";\r\n\r\nconst statementNotPreparedMessage = \"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\r\nfunction logStatementCleanupError(loggerCategory: string, message: string, error: unknown): void {\r\n try {\r\n Logger.logTrace(loggerCategory, message, () => ({ error: BentleyError.getErrorMessage(error) }));\r\n } catch {\r\n // Cleanup diagnostics must not replace the original query error.\r\n }\r\n}\r\n\r\n/** Returns a statement to its cache, falling back to direct disposal without throwing.\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/no-deprecated\r\nexport function releaseECSqlStatement(stmt: ECSqlStatement, cache: StatementCache<ECSqlStatement>, loggerCategory: string, canCache: boolean): void {\r\n if (!canCache || !stmt.isPrepared) {\r\n try {\r\n stmt[Symbol.dispose]();\r\n } catch (error) {\r\n logStatementCleanupError(loggerCategory, \"Failed to dispose an ECSQL statement that could not be cached.\", error);\r\n }\r\n return;\r\n }\r\n\r\n try {\r\n cache.addOrDispose(stmt);\r\n } catch (error) {\r\n try {\r\n stmt[Symbol.dispose]();\r\n } catch (disposeError) {\r\n logStatementCleanupError(loggerCategory, \"Failed to dispose an ECSQL statement after it could not be returned to the statement cache.\", disposeError);\r\n }\r\n logStatementCleanupError(loggerCategory, \"Failed to return an ECSQL statement to the statement cache; attempted direct disposal instead.\", error);\r\n }\r\n}\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 private _removeListener: () => void;\r\n private _isDisposed = false;\r\n private _canCacheStatement = true;\r\n\r\n /** Whether the statement completed preparation and can be returned to its cache.\r\n * @internal\r\n */\r\n public get canCacheStatement(): boolean { return this._canCacheStatement; }\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-deprecated\r\n public constructor(private readonly _db: IModelDb | ECDb, private readonly _stmt: ECSqlStatement, private readonly _loggerCategory: string) {\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 currently held statement without returning it to the cache.\r\n * Invoked when the db signals it is closing (the statement cache is cleared on close, so the\r\n * checked-out statement must be disposed directly to avoid a use-after-free or double dispose).\r\n * @internal\r\n */\r\n private cleanup(): void {\r\n this._isDisposed = true;\r\n try {\r\n this._stmt[Symbol.dispose]();\r\n } catch (error) {\r\n logStatementCleanupError(this._loggerCategory, \"Failed to dispose an ECSQL statement while closing its database.\", error);\r\n }\r\n }\r\n\r\n /** Removes the database-close listener owned by this row executor.\r\n * @internal\r\n */\r\n public [Symbol.dispose](): void {\r\n this._isDisposed = true;\r\n this._removeListener();\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._isDisposed || !this._stmt.isPrepared)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, statementNotPreparedMessage);\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 Column metadata owned by the caller.\r\n * @internal\r\n */\r\n public fetchMetadata(options: IModelJsNative.ECSqlRowAdaptorOptions): PropertyMetaDataMap {\r\n if (this._isDisposed || !this._stmt.isPrepared)\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR, statementNotPreparedMessage);\r\n return this._stmt.getMetadata(options);\r\n }\r\n\r\n // --------------------------------------------------------------------------------------------\r\n // Execution phases\r\n // --------------------------------------------------------------------------------------------\r\n\r\n /** Prepares the ECSql statement when the caller did not supply one from its cache.\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 if (this._stmt.isPrepared)\r\n return { isSuccessful: true };\r\n\r\n try {\r\n this._stmt.prepare(this._db[_nativeDb], ecsql);\r\n return { isSuccessful: true };\r\n } catch (error: any) {\r\n this._canCacheStatement = false;\r\n try {\r\n this._stmt[Symbol.dispose]();\r\n } catch (disposeError) {\r\n logStatementCleanupError(this._loggerCategory, \"Failed to dispose an ECSQL statement after preparation failed.\", disposeError);\r\n }\r\n return { isSuccessful: false, message: error.message };\r\n }\r\n }\r\n\r\n /** Binds the supplied parameter values to the prepared statement.\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 if (!this._stmt.isPrepared)\r\n return { isSuccessful: false, message: statementNotPreparedMessage };\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}"]}
@@ -62,6 +62,10 @@ export declare class ECSqlStatement implements IterableIterator<any>, Disposable
62
62
  private _stmt;
63
63
  private _sql;
64
64
  private _props;
65
+ /** Column metadata for the prepared statement, keyed by row-adaptor options. Native metadata depends only on the
66
+ * prepared statement and those options, so it is reused until the statement is re-prepared or disposed.
67
+ */
68
+ private _metadataCache?;
65
69
  get sql(): string;
66
70
  /** Check if this statement has been prepared successfully or not */
67
71
  get isPrepared(): boolean;
@@ -196,7 +200,7 @@ export declare class ECSqlStatement implements IterableIterator<any>, Disposable
196
200
  * The section "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" describes the
197
201
  * iTwin.js types to be used for the different ECSQL parameter types.
198
202
  *
199
- * See also these [Code Samples]($docs/learning/backend/ECSQLCodeExamples#binding-to-all-parameters-at-once)
203
+ * See [reader parameter-binding examples]($docs/learning/ECSQLCodeExamples.md#parameter-bindings) for SELECT queries using [QueryBinder]($common).
200
204
  */
201
205
  bindValues(values: any[] | object): void;
202
206
  /** Clear any bindings that were previously set on this statement.
@@ -246,6 +250,7 @@ export declare class ECSqlStatement implements IterableIterator<any>, Disposable
246
250
  toRow(args: IModelJsNative.ECSqlRowAdaptorOptions): any;
247
251
  /**
248
252
  * Used by ECSqlRowExecutor to get metadata as json.
253
+ * The native metadata is cached per row-adaptor options; each call returns copies so callers cannot alter the cache.
249
254
  * @internal */
250
255
  getMetadata(args: IModelJsNative.ECSqlRowAdaptorOptions): PropertyMetaDataMap;
251
256
  /**
@@ -430,7 +435,7 @@ export declare class ECSqlWriteStatement {
430
435
  * The section "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" describes the
431
436
  * iTwin.js types to be used for the different ECSQL parameter types.
432
437
  *
433
- * See also these [Code Samples]($docs/learning/backend/ECSQLCodeExamples#binding-to-all-parameters-at-once)
438
+ * See [reader parameter-binding examples]($docs/learning/ECSQLCodeExamples.md#parameter-bindings) for SELECT queries using [QueryBinder]($common).
434
439
  */
435
440
  bindValues(values: any[] | object): void;
436
441
  /** Clear any bindings that were previously set on this statement.
@@ -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,EAAO,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAa,cAAc,EAAe,sBAAsB,EAAE,eAAe,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC1J,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI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AO,IAAI,cAAc,CAAC;IAE1B;;;;OAIG;IACH,eAAe,IAAI,MAAM,CAAC;IAE1B;;;;OAIG;IACH,qBAAqB,IAAI,MAAM,GAAG,SAAS,CAAC;IAE5C;;;OAGG;IACH,eAAe,IAAI,MAAM,CAAC;IAE1B,wEAAwE;IACxE,MAAM,IAAI,OAAO,CAAC;IAElB,qFAAqF;IACrF,gBAAgB,IAAI,OAAO,CAAC;IAE5B;;OAEG;IACH,mBAAmB,IAAI,OAAO,CAAC;IAE/B;;;OAGG;IACH,sBAAsB,IAAI,MAAM,CAAC;IAEjC,oGAAoG;IACpG,gBAAgB,IAAI,MAAM,CAAC;IAE3B;;OAEG;IACH,iBAAiB,IAAI,MAAM,CAAC;CAC7B"}
@@ -61,6 +61,10 @@ class ECSqlStatement {
61
61
  _stmt;
62
62
  _sql;
63
63
  _props = new core_common_1.PropertyMetaDataMap([]);
64
+ /** Column metadata for the prepared statement, keyed by row-adaptor options. Native metadata depends only on the
65
+ * prepared statement and those options, so it is reused until the statement is re-prepared or disposed.
66
+ */
67
+ _metadataCache;
64
68
  get sql() { return this._sql; } // eslint-disable-line @typescript-eslint/no-non-null-assertion
65
69
  /** Check if this statement has been prepared successfully or not */
66
70
  get isPrepared() { return !!this._stmt; }
@@ -89,6 +93,7 @@ class ECSqlStatement {
89
93
  if (this.isPrepared)
90
94
  throw new Error("ECSqlStatement is already prepared");
91
95
  this._sql = ecsql;
96
+ this._metadataCache = undefined;
92
97
  this._stmt = new NativePlatform_1.IModelNative.platform.ECSqlStatement();
93
98
  return this._stmt.prepare(db, ecsql, logErrors);
94
99
  }
@@ -110,6 +115,7 @@ class ECSqlStatement {
110
115
  * > Do not call this method directly on a statement that is being managed by a statement cache.
111
116
  */
112
117
  [Symbol.dispose]() {
118
+ this._metadataCache = undefined;
113
119
  if (this._stmt) {
114
120
  this._stmt.dispose(); // free native statement
115
121
  this._stmt = undefined;
@@ -220,7 +226,7 @@ class ECSqlStatement {
220
226
  * The section "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" describes the
221
227
  * iTwin.js types to be used for the different ECSQL parameter types.
222
228
  *
223
- * See also these [Code Samples]($docs/learning/backend/ECSQLCodeExamples#binding-to-all-parameters-at-once)
229
+ * See [reader parameter-binding examples]($docs/learning/ECSQLCodeExamples.md#parameter-bindings) for SELECT queries using [QueryBinder]($common).
224
230
  */
225
231
  bindValues(values) {
226
232
  if (Array.isArray(values)) {
@@ -328,12 +334,19 @@ class ECSqlStatement {
328
334
  }
329
335
  /**
330
336
  * Used by ECSqlRowExecutor to get metadata as json.
337
+ * The native metadata is cached per row-adaptor options; each call returns copies so callers cannot alter the cache.
331
338
  * @internal */
332
339
  getMetadata(args) {
333
340
  if (!this._stmt)
334
341
  throw new Error("ECSqlStatement is not prepared");
335
- const resp = this._stmt.getMetadata(args);
336
- return new core_common_1.PropertyMetaDataMap(resp.meta);
342
+ const key = `${args.abbreviateBlobs}|${args.classIdsToClassNames}|${args.useJsName}|${args.doNotConvertClassIdsToClassNamesWhenAliased}`;
343
+ this._metadataCache ??= new Map();
344
+ let properties = this._metadataCache.get(key);
345
+ if (!properties) {
346
+ properties = new core_common_1.PropertyMetaDataMap(this._stmt.getMetadata(args).meta).properties;
347
+ this._metadataCache.set(key, properties);
348
+ }
349
+ return new core_common_1.PropertyMetaDataMap(properties.map((property) => ({ ...property })));
337
350
  }
338
351
  /**
339
352
  * Used by ECSqlRowExecutor to bind params to the statement.
@@ -588,7 +601,7 @@ class ECSqlWriteStatement {
588
601
  * The section "[iTwin.js Types used in ECSQL Parameter Bindings]($docs/learning/ECSQLParameterTypes)" describes the
589
602
  * iTwin.js types to be used for the different ECSQL parameter types.
590
603
  *
591
- * See also these [Code Samples]($docs/learning/backend/ECSQLCodeExamples#binding-to-all-parameters-at-once)
604
+ * See [reader parameter-binding examples]($docs/learning/ECSQLCodeExamples.md#parameter-bindings) for SELECT queries using [QueryBinder]($common).
592
605
  */
593
606
  bindValues(values) {
594
607
  this._stmt.bindValues(values);