@itwin/core-backend 5.14.0-dev.21 → 5.14.0-dev.22

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.
@@ -618,17 +618,18 @@ class IModelDb extends core_common_1.IModel {
618
618
  throw err;
619
619
  }
620
620
  }
621
- /** Allow to execute query and read results along with meta data. The result are streamed.
621
+ /** Creates a reader for asynchronous ECSQL query execution.
622
+ * Execution starts when the reader is consumed using asynchronous iteration or awaited calls to `step()` or `toArray()`.
623
+ * Results are fetched and buffered in batches. For synchronous, callback-scoped execution, use [[withQueryReader]].
622
624
  *
623
625
  * See also:
624
- * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)
625
- * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)
626
+ * - [Choosing a query reader]($docs/learning/backend/ExecutingECSQL)
627
+ * - [Asynchronous query examples]($docs/learning/ECSQLCodeExamples)
626
628
  * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)
627
629
  *
628
630
  * @param params The values to bind to the parameters (if the ECSQL has any).
629
631
  * @param config Allow to specify certain flags which control how query is executed.
630
632
  * @returns Returns an [ECSqlReader]($common) which helps iterate over the result set and also give access to metadata.
631
- * Should be used when we donot want true step by step behaviour and want to take advantage of caching capabilities of the reader.
632
633
  * @public
633
634
  * */
634
635
  createQueryReader(ecsql, params, config) {
@@ -641,20 +642,21 @@ class IModelDb extends core_common_1.IModel {
641
642
  };
642
643
  return new core_common_1.ECSqlReader(executor, ecsql, params, config);
643
644
  }
644
- /** Allow to execute query and read results along with meta data. The result are stepped one by one.
645
+ /** Executes a callback with a synchronous ECSQL reader on the owning database connection.
646
+ * The reader steps one row at a time without buffering result batches. Finish using it before the callback completes.
647
+ * Return materialized rows or computed values rather than the reader. For asynchronous execution, use [[createQueryReader]].
648
+ * The prepared statement may be reused from the statement cache between completed calls.
645
649
  *
646
650
  * See also:
647
- * - [ECSQL Overview]($docs/learning/backend/ExecutingECSQL)
648
- * - [Code Examples]($docs/learning/backend/ECSQLCodeExamples)
651
+ * - [Choosing a query reader]($docs/learning/backend/ExecutingECSQL)
652
+ * - [Synchronous query examples]($docs/learning/backend/WithQueryReaderCodeExamples)
649
653
  * - [ECSQL Row Format]($docs/learning/ECSQLRowFormat)
650
654
  * @param ecsql The ECSQL query to execute.
651
- * @param callback the callback to invoke on the prepared ECSqlReader
655
+ * @param callback the callback to invoke on the prepared ECSqlSyncReader
652
656
  * @param params The values to bind to the parameters (if the ECSQL has any).
653
657
  * @param config Allow to specify certain flags which control how query is executed.
654
658
  * @returns the value returned by `callback`.
655
659
  * @throws IModelError if db is not open.
656
- * Use this method for true step-by-step row consumption without intermediate result or page caching.
657
- * The prepared ECSQL statement may be reused from the statement cache between completed calls.
658
660
  * @beta
659
661
  * */
660
662
  withQueryReader(ecsql, callback, params, config) {
@@ -1416,7 +1418,10 @@ class IModelDb extends core_common_1.IModel {
1416
1418
  const result = await reader.next();
1417
1419
  if (result.done)
1418
1420
  throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, "PRAGMA checksum(schema_token) returned no rows");
1419
- return result.value.sha3_256;
1421
+ const token = result.value.sha3_256;
1422
+ if (typeof token !== "string")
1423
+ throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, "PRAGMA checksum(schema_token) returned an invalid sha3_256 column");
1424
+ return token;
1420
1425
  },
1421
1426
  };
1422
1427
  }
@@ -1435,7 +1440,9 @@ class IModelDb extends core_common_1.IModel {
1435
1440
  const token = result.value.schemaToken;
1436
1441
  if (data === undefined || data === null)
1437
1442
  throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, `${pragma} returned null data column`);
1438
- return { data, schemaToken: token ?? "" };
1443
+ if (typeof token !== "string")
1444
+ throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR, `${pragma} returned an invalid schemaToken column`);
1445
+ return { data, schemaToken: token };
1439
1446
  }
1440
1447
  /** Get the linkTableRelationships for this IModel */
1441
1448
  get relationships() {