@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.
- package/lib/cjs/ECDb.d.ts +11 -6
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +11 -6
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +2 -2
- package/lib/cjs/ECSqlStatement.js +2 -2
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +12 -10
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +19 -12
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/esm/ECDb.d.ts +11 -6
- package/lib/esm/ECDb.d.ts.map +1 -1
- package/lib/esm/ECDb.js +11 -6
- package/lib/esm/ECDb.js.map +1 -1
- package/lib/esm/ECSqlStatement.d.ts +2 -2
- package/lib/esm/ECSqlStatement.js +2 -2
- package/lib/esm/ECSqlStatement.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +12 -10
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +19 -12
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/test/ecdb/QueryReaders.test.js +105 -30
- package/lib/esm/test/ecdb/QueryReaders.test.js.map +1 -1
- package/package.json +13 -13
|
@@ -75,12 +75,87 @@ describe("QueryReaders - createQueryReader() and withQueryReader() api tests", (
|
|
|
75
75
|
after(async () => {
|
|
76
76
|
iModel.close();
|
|
77
77
|
});
|
|
78
|
+
it("formats blob results", async () => {
|
|
79
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
80
|
+
try {
|
|
81
|
+
const ecdb = __addDisposableResource(env_1, ECDbTestHelper.createECDb(KnownTestLocations.outputDir, "ecsql-reader-blobs.ecdb", `<?xml version="1.0" encoding="utf-8"?>
|
|
82
|
+
<ECSchema schemaName="MySchema" alias="myschema" version="01.00.00" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.2">
|
|
83
|
+
<ECEntityClass typeName="BlobExample">
|
|
84
|
+
<ECProperty propertyName="Data" typeName="binary" />
|
|
85
|
+
</ECEntityClass>
|
|
86
|
+
</ECSchema>`), false);
|
|
87
|
+
const blob = new Uint8Array([1, 2, 3]);
|
|
88
|
+
const insertStatus = ecdb.withWriteStatement("INSERT INTO myschema.BlobExample(Data) VALUES(?)", (stmt) => {
|
|
89
|
+
stmt.bindBlob(1, blob);
|
|
90
|
+
return stmt.step();
|
|
91
|
+
});
|
|
92
|
+
assert.equal(insertStatus, DbResult.BE_SQLITE_DONE);
|
|
93
|
+
ecdb.saveChanges();
|
|
94
|
+
for (const abbreviateBlobs of [undefined, false, true]) {
|
|
95
|
+
const query = "SELECT Data FROM myschema.BlobExample";
|
|
96
|
+
const expected = abbreviateBlobs ? '{"bytes":3}' : blob;
|
|
97
|
+
const asyncRows = await ecdb.createQueryReader(query, undefined, { abbreviateBlobs }).toArray();
|
|
98
|
+
const syncRows = ecdb.withQueryReader(query, (reader) => reader.toArray(), undefined, { abbreviateBlobs });
|
|
99
|
+
assert.deepEqual(asyncRows, [[expected]]);
|
|
100
|
+
assert.deepEqual(syncRows, [[expected]]);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (e_1) {
|
|
104
|
+
env_1.error = e_1;
|
|
105
|
+
env_1.hasError = true;
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
__disposeResources(env_1);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
it("preserves row formats and bindings", async () => {
|
|
112
|
+
const rootSelect = "SELECT ECInstanceId, ECClassId FROM bis.Element WHERE ECInstanceId=?";
|
|
113
|
+
const asyncIndexRows = await iModel.createQueryReader(rootSelect, new QueryBinder().bindId(1, "0x1")).toArray();
|
|
114
|
+
assert.isArray(asyncIndexRows[0]);
|
|
115
|
+
assert.equal(asyncIndexRows[0][0], "0x1");
|
|
116
|
+
assert.isTrue(Id64.isValidId64(asyncIndexRows[0][1]));
|
|
117
|
+
const asyncECSqlNameRows = await iModel.createQueryReader(rootSelect, new QueryBinder().bindId(1, "0x1"), { rowFormat: QueryRowFormat.UseECSqlPropertyNames }).toArray();
|
|
118
|
+
assert.equal(asyncECSqlNameRows[0].ECInstanceId, "0x1");
|
|
119
|
+
assert.isTrue(Id64.isValidId64(asyncECSqlNameRows[0].ECClassId));
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
121
|
+
const asyncJsNameRows = await iModel.createQueryReader(rootSelect, new QueryBinder().bindId(1, "0x1"), { rowFormat: QueryRowFormat.UseJsPropertyNames }).toArray();
|
|
122
|
+
assert.equal(asyncJsNameRows[0].id, "0x1");
|
|
123
|
+
assert.equal(asyncJsNameRows[0].className, "BisCore.Subject");
|
|
124
|
+
const syncIndexRows = iModel.withQueryReader(rootSelect, (reader) => reader.toArray(), new QueryBinder().bindId(1, "0x1"));
|
|
125
|
+
assert.isArray(syncIndexRows[0]);
|
|
126
|
+
assert.equal(syncIndexRows[0][0], "0x1");
|
|
127
|
+
assert.isTrue(Id64.isValidId64(syncIndexRows[0][1]));
|
|
128
|
+
const syncECSqlNameRows = iModel.withQueryReader(rootSelect, (reader) => reader.toArray(), new QueryBinder().bindId(1, "0x1"), { rowFormat: QueryRowFormat.UseECSqlPropertyNames });
|
|
129
|
+
assert.equal(syncECSqlNameRows[0].ECInstanceId, "0x1");
|
|
130
|
+
assert.isTrue(Id64.isValidId64(syncECSqlNameRows[0].ECClassId));
|
|
131
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
132
|
+
const syncJsNameRows = iModel.withQueryReader(rootSelect, (reader) => reader.toArray(), new QueryBinder().bindId(1, "0x1"), { rowFormat: QueryRowFormat.UseJsPropertyNames });
|
|
133
|
+
assert.equal(syncJsNameRows[0].id, "0x1");
|
|
134
|
+
assert.equal(syncJsNameRows[0].className, "BisCore.Subject");
|
|
135
|
+
const asyncReader = iModel.createQueryReader(rootSelect, new QueryBinder().bindId(1, "0x1"));
|
|
136
|
+
assert.isTrue(await asyncReader.step());
|
|
137
|
+
const asyncObjectRow = asyncReader.current.toRow();
|
|
138
|
+
assert.isFalse(Array.isArray(asyncObjectRow));
|
|
139
|
+
assert.equal(asyncObjectRow.ECInstanceId, "0x1");
|
|
140
|
+
const objectRow = iModel.withQueryReader(rootSelect, (reader) => {
|
|
141
|
+
assert.isTrue(reader.step());
|
|
142
|
+
return reader.current.toRow();
|
|
143
|
+
}, new QueryBinder().bindId(1, "0x1"));
|
|
144
|
+
assert.isObject(objectRow);
|
|
145
|
+
assert.equal(objectRow.ECInstanceId, "0x1");
|
|
146
|
+
const arrayRows = iModel.withQueryReader(rootSelect, (reader) => reader.toArray(), new QueryBinder().bindId(1, "0x1"));
|
|
147
|
+
assert.isArray(arrayRows[0]);
|
|
148
|
+
const idSetRows = await iModel.createQueryReader("SELECT ECInstanceId FROM bis.Element WHERE InVirtualSet(?, ECInstanceId)", new QueryBinder().bindIdSet(1, ["0x1", "0x2"])).toArray();
|
|
149
|
+
assert.isTrue(idSetRows.some((row) => row[0] === "0x1"));
|
|
150
|
+
const syncIdSetRows = iModel.withQueryReader("SELECT ECInstanceId FROM bis.Element WHERE InVirtualSet(?, ECInstanceId)", (reader) => reader.toArray(), new QueryBinder().bindIdSet(1, ["0x1", "0x2"]));
|
|
151
|
+
assert.sameDeepMembers(syncIdSetRows, idSetRows);
|
|
152
|
+
});
|
|
78
153
|
describe("bind Id64 enumerable", async () => {
|
|
79
154
|
const outDir = KnownTestLocations.outputDir;
|
|
80
155
|
it("ecsql reader simple", async () => {
|
|
81
|
-
const
|
|
156
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
82
157
|
try {
|
|
83
|
-
const ecdb = __addDisposableResource(
|
|
158
|
+
const ecdb = __addDisposableResource(env_2, ECDbTestHelper.createECDb(outDir, "test.ecdb", `<ECSchema schemaName="Test" alias="ts" version="01.00.00" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.2">
|
|
84
159
|
<ECEntityClass typeName="Foo" modifier="Sealed">
|
|
85
160
|
<ECProperty propertyName="n" typeName="int"/>
|
|
86
161
|
</ECEntityClass>
|
|
@@ -106,18 +181,18 @@ describe("QueryReaders - createQueryReader() and withQueryReader() api tests", (
|
|
|
106
181
|
const reader = ecdb.createQueryReader("SELECT ECInstanceId, Name FROM meta.ECClassDef WHERE InVirtualSet(?, ECInstanceId)", params, optionBuilder.getOptions());
|
|
107
182
|
await readerCallback(reader);
|
|
108
183
|
}
|
|
109
|
-
catch (
|
|
110
|
-
|
|
111
|
-
|
|
184
|
+
catch (e_2) {
|
|
185
|
+
env_2.error = e_2;
|
|
186
|
+
env_2.hasError = true;
|
|
112
187
|
}
|
|
113
188
|
finally {
|
|
114
|
-
__disposeResources(
|
|
189
|
+
__disposeResources(env_2);
|
|
115
190
|
}
|
|
116
191
|
});
|
|
117
192
|
it("ecsql reader simple for IdSet", async () => {
|
|
118
|
-
const
|
|
193
|
+
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
119
194
|
try {
|
|
120
|
-
const ecdb = __addDisposableResource(
|
|
195
|
+
const ecdb = __addDisposableResource(env_3, ECDbTestHelper.createECDb(outDir, "test.ecdb", `<ECSchema schemaName="Test" alias="ts" version="01.00.00" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.2">
|
|
121
196
|
<ECEntityClass typeName="Foo" modifier="Sealed">
|
|
122
197
|
<ECProperty propertyName="n" typeName="int"/>
|
|
123
198
|
</ECEntityClass>
|
|
@@ -143,18 +218,18 @@ describe("QueryReaders - createQueryReader() and withQueryReader() api tests", (
|
|
|
143
218
|
const reader = ecdb.createQueryReader("SELECT ECInstanceId, Name FROM meta.ECClassDef, IdSet(?) WHERE id = ECInstanceId ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES", params, optionBuilder.getOptions());
|
|
144
219
|
await readerCallback(reader);
|
|
145
220
|
}
|
|
146
|
-
catch (
|
|
147
|
-
|
|
148
|
-
|
|
221
|
+
catch (e_3) {
|
|
222
|
+
env_3.error = e_3;
|
|
223
|
+
env_3.hasError = true;
|
|
149
224
|
}
|
|
150
225
|
finally {
|
|
151
|
-
__disposeResources(
|
|
226
|
+
__disposeResources(env_3);
|
|
152
227
|
}
|
|
153
228
|
});
|
|
154
229
|
it("bindIdSet throws on invalid integer Ids", () => {
|
|
155
|
-
const
|
|
230
|
+
const env_4 = { stack: [], error: void 0, hasError: false };
|
|
156
231
|
try {
|
|
157
|
-
const ecdb = __addDisposableResource(
|
|
232
|
+
const ecdb = __addDisposableResource(env_4, ECDbTestHelper.createECDb(outDir, "test.ecdb", `<ECSchema schemaName="Test" alias="ts" version="01.00.00" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.2">
|
|
158
233
|
<ECEntityClass typeName="Foo" modifier="Sealed">
|
|
159
234
|
<ECProperty propertyName="n" typeName="int"/>
|
|
160
235
|
</ECEntityClass>
|
|
@@ -164,18 +239,18 @@ describe("QueryReaders - createQueryReader() and withQueryReader() api tests", (
|
|
|
164
239
|
const params = new QueryBinder();
|
|
165
240
|
expect(() => params.bindIdSet(1, ["50"])).to.throw(/is not a valid Id64String/);
|
|
166
241
|
}
|
|
167
|
-
catch (
|
|
168
|
-
|
|
169
|
-
|
|
242
|
+
catch (e_4) {
|
|
243
|
+
env_4.error = e_4;
|
|
244
|
+
env_4.hasError = true;
|
|
170
245
|
}
|
|
171
246
|
finally {
|
|
172
|
-
__disposeResources(
|
|
247
|
+
__disposeResources(env_4);
|
|
173
248
|
}
|
|
174
249
|
});
|
|
175
250
|
it("ecsql reader simple using query reader", async () => {
|
|
176
|
-
const
|
|
251
|
+
const env_5 = { stack: [], error: void 0, hasError: false };
|
|
177
252
|
try {
|
|
178
|
-
const ecdb = __addDisposableResource(
|
|
253
|
+
const ecdb = __addDisposableResource(env_5, ECDbTestHelper.createECDb(outDir, "test.ecdb", `<ECSchema schemaName="Test" alias="ts" version="01.00.00" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.2">
|
|
179
254
|
<ECEntityClass typeName="Foo" modifier="Sealed">
|
|
180
255
|
<ECProperty propertyName="n" typeName="int"/>
|
|
181
256
|
</ECEntityClass>
|
|
@@ -215,12 +290,12 @@ describe("QueryReaders - createQueryReader() and withQueryReader() api tests", (
|
|
|
215
290
|
const reader = ecdb.createQueryReader("SELECT ECInstanceId, n FROM ts.Foo WHERE ECInstanceId=:firstId", params, { limit: { count: 1 } });
|
|
216
291
|
await readerCallback(reader);
|
|
217
292
|
}
|
|
218
|
-
catch (
|
|
219
|
-
|
|
220
|
-
|
|
293
|
+
catch (e_5) {
|
|
294
|
+
env_5.error = e_5;
|
|
295
|
+
env_5.hasError = true;
|
|
221
296
|
}
|
|
222
297
|
finally {
|
|
223
|
-
__disposeResources(
|
|
298
|
+
__disposeResources(env_5);
|
|
224
299
|
}
|
|
225
300
|
});
|
|
226
301
|
it("ecsql reader simple using query row reader", async () => {
|
|
@@ -255,10 +330,10 @@ describe("QueryReaders - createQueryReader() and withQueryReader() api tests", (
|
|
|
255
330
|
await readerCallback(reader);
|
|
256
331
|
});
|
|
257
332
|
it("should bind Range3d", async () => {
|
|
258
|
-
const
|
|
333
|
+
const env_6 = { stack: [], error: void 0, hasError: false };
|
|
259
334
|
try {
|
|
260
335
|
const testRange = new Range3d(1.2, 2.3, 3.4, 4.5, 5.6, 6.7);
|
|
261
|
-
const ecdb = __addDisposableResource(
|
|
336
|
+
const ecdb = __addDisposableResource(env_6, ECDbTestHelper.createECDb(outDir, "bindrange3d.ecdb", `<ECSchema schemaName="Test" alias="test" version="01.00.00" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.1">
|
|
262
337
|
<ECEntityClass typeName="Foo" modifier="Sealed">
|
|
263
338
|
<ECProperty propertyName="Range3d" typeName="binary"/>
|
|
264
339
|
</ECEntityClass>
|
|
@@ -280,12 +355,12 @@ describe("QueryReaders - createQueryReader() and withQueryReader() api tests", (
|
|
|
280
355
|
const actualRange = new Range3d(...rangeFloatArray);
|
|
281
356
|
assert.isTrue(actualRange.isAlmostEqual(testRange));
|
|
282
357
|
}
|
|
283
|
-
catch (
|
|
284
|
-
|
|
285
|
-
|
|
358
|
+
catch (e_6) {
|
|
359
|
+
env_6.error = e_6;
|
|
360
|
+
env_6.hasError = true;
|
|
286
361
|
}
|
|
287
362
|
finally {
|
|
288
|
-
__disposeResources(
|
|
363
|
+
__disposeResources(env_6);
|
|
289
364
|
}
|
|
290
365
|
});
|
|
291
366
|
});
|