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