Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make classIdsToClassNames explicit parameter independent of UseJsPropertyName #7264

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/core-backend",
"comment": "Make classIdsToClassNames explicit parameter independent of UseJsPropertyNames",
"type": "none"
}
],
"packageName": "@itwin/core-backend"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/core-common",
"comment": "Make classIdsToClassNames explicit parameter independent of UseJsPropertyNames",
"type": "none"
}
],
"packageName": "@itwin/core-common"
}
8 changes: 2 additions & 6 deletions core/backend/src/ECSqlStatement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,10 @@ export class ECSqlStatement implements IterableIterator<any>, IDisposable {
* - [ECSQL row format]($docs/learning/ECSQLRowFormat) for details about the format of the returned row.
* - [Code Samples]($docs/learning/backend/ECSQLCodeExamples#working-with-the-query-result)
*/
public getRow(args?: ECSqlRowArg): any {
public getRow(args: ECSqlRowArg = { rowFormat: QueryRowFormat.UseJsPropertyNames, classIdsToClassNames: true }): any {
if (!this._stmt)
throw new Error("ECSqlStatement is not prepared");

args = args ?? {};
if (args.rowFormat === undefined) {
args.rowFormat = QueryRowFormat.UseJsPropertyNames;
}
const resp = this._stmt.toRow({
classIdsToClassNames: args.classIdsToClassNames,
useJsName: args.rowFormat === QueryRowFormat.UseJsPropertyNames,
Expand All @@ -355,7 +351,7 @@ export class ECSqlStatement implements IterableIterator<any>, IDisposable {
return this.formatCurrentRow(resp, args.rowFormat);
}

private formatCurrentRow(currentResp: any, rowFormat: QueryRowFormat = QueryRowFormat.UseJsPropertyNames): any[] | object {
private formatCurrentRow(currentResp: any, rowFormat: QueryRowFormat = QueryRowFormat.UseJsPropertyNames): any[] | { [key: string]: any } {
if (!this._stmt)
throw new Error("ECSqlStatement is not prepared");

Expand Down
3 changes: 1 addition & 2 deletions core/backend/src/test/ecdb/ECSqlQuery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import { assert } from "chai";
import { DbResult, Id64 } from "@itwin/core-bentley";
import { DbQueryRequest, DbQueryResponse, DbRequestExecutor, DbRequestKind, ECSqlReader, QueryBinder, QueryOptionsBuilder, QueryPropertyMetaData, QueryRowFormat } from "@itwin/core-common";
import { ConcurrentQuery } from "../../ConcurrentQuery";
import { _nativeDb, ECSqlStatement, IModelDb, SnapshotDb } from "../../core-backend";
import { _nativeDb, IModelDb, SnapshotDb } from "../../core-backend";
import { IModelTestUtils } from "../IModelTestUtils";
import { SequentialLogMatcher } from "../SequentialLogMatcher";
import * as path from "path";

// cspell:ignore mirukuru ibim

Expand Down
2 changes: 1 addition & 1 deletion core/backend/src/test/ecdb/ECSqlStatement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const selectSingleRow = new QueryOptionsBuilder().setLimit({ count: 1, offset: -
async function query(ecdb: ECDb, ecsql: string, params?: QueryBinder, config?: QueryOptions, callback?: (row: any) => void) {
ecdb.saveChanges();
let rowCount: number = 0;
for await (const queryRow of ecdb.createQueryReader(ecsql, params, { ...config, rowFormat: QueryRowFormat.UseJsPropertyNames })) {
for await (const queryRow of ecdb.createQueryReader(ecsql, params, { ...config, rowFormat: QueryRowFormat.UseJsPropertyNames, convertClassIdsToClassNames: true })) {
rowCount++;
if (callback)
callback(queryRow.toRow());
Expand Down
Loading
Loading