@itwin/core-backend 5.14.0-dev.8 → 5.15.0-dev.1
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/CHANGELOG.md +33 -1
- package/lib/cjs/BriefcaseManager.d.ts +6 -0
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +1 -1
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/ChangesetReader.d.ts +1 -1
- package/lib/cjs/ChangesetReader.js +2 -2
- package/lib/cjs/ChangesetReader.js.map +1 -1
- package/lib/cjs/ChangesetReaderTypes.d.ts +4 -1
- package/lib/cjs/ChangesetReaderTypes.d.ts.map +1 -1
- package/lib/cjs/ChangesetReaderTypes.js +3 -0
- package/lib/cjs/ChangesetReaderTypes.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +63 -6
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +62 -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/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +6 -3
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +53 -38
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +47 -27
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IpcHost.d.ts.map +1 -1
- package/lib/cjs/IpcHost.js +51 -17
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/SchemaSync.d.ts +2 -2
- package/lib/cjs/SchemaSync.d.ts.map +1 -1
- package/lib/cjs/SchemaSync.js +2 -2
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.d.ts +16 -8
- package/lib/cjs/SqliteChangesetReader.d.ts.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js +11 -1
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +4 -0
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts +90 -5
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.js +59 -1
- package/lib/cjs/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/cjs/internal/IntegrityCheck.d.ts +57 -0
- package/lib/cjs/internal/IntegrityCheck.d.ts.map +1 -1
- package/lib/cjs/internal/IntegrityCheck.js.map +1 -1
- package/lib/cjs/internal/annotations/fieldSpecs.d.ts +82 -0
- package/lib/cjs/internal/annotations/fieldSpecs.d.ts.map +1 -0
- package/lib/cjs/internal/annotations/fieldSpecs.js +187 -0
- package/lib/cjs/internal/annotations/fieldSpecs.js.map +1 -0
- package/lib/cjs/internal/annotations/fields.d.ts +39 -2
- package/lib/cjs/internal/annotations/fields.d.ts.map +1 -1
- package/lib/cjs/internal/annotations/fields.js +140 -13
- package/lib/cjs/internal/annotations/fields.js.map +1 -1
- package/lib/esm/BriefcaseManager.d.ts +6 -0
- package/lib/esm/BriefcaseManager.d.ts.map +1 -1
- package/lib/esm/BriefcaseManager.js +1 -1
- package/lib/esm/BriefcaseManager.js.map +1 -1
- package/lib/esm/ChangesetReader.d.ts +1 -1
- package/lib/esm/ChangesetReader.js +2 -2
- package/lib/esm/ChangesetReader.js.map +1 -1
- package/lib/esm/ChangesetReaderTypes.d.ts +4 -1
- package/lib/esm/ChangesetReaderTypes.d.ts.map +1 -1
- package/lib/esm/ChangesetReaderTypes.js +3 -0
- package/lib/esm/ChangesetReaderTypes.js.map +1 -1
- package/lib/esm/ECDb.d.ts +63 -6
- package/lib/esm/ECDb.d.ts.map +1 -1
- package/lib/esm/ECDb.js +62 -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/Element.d.ts.map +1 -1
- package/lib/esm/Element.js +6 -3
- package/lib/esm/Element.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +53 -38
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +47 -27
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/IpcHost.d.ts.map +1 -1
- package/lib/esm/IpcHost.js +52 -18
- package/lib/esm/IpcHost.js.map +1 -1
- package/lib/esm/SchemaSync.d.ts +2 -2
- package/lib/esm/SchemaSync.d.ts.map +1 -1
- package/lib/esm/SchemaSync.js +2 -2
- package/lib/esm/SchemaSync.js.map +1 -1
- package/lib/esm/SqliteChangesetReader.d.ts +16 -8
- package/lib/esm/SqliteChangesetReader.d.ts.map +1 -1
- package/lib/esm/SqliteChangesetReader.js +11 -1
- package/lib/esm/SqliteChangesetReader.js.map +1 -1
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +4 -0
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts +90 -5
- package/lib/esm/annotations/ElementDrivesTextAnnotation.d.ts.map +1 -1
- package/lib/esm/annotations/ElementDrivesTextAnnotation.js +60 -2
- package/lib/esm/annotations/ElementDrivesTextAnnotation.js.map +1 -1
- package/lib/esm/internal/IntegrityCheck.d.ts +57 -0
- package/lib/esm/internal/IntegrityCheck.d.ts.map +1 -1
- package/lib/esm/internal/IntegrityCheck.js.map +1 -1
- package/lib/esm/internal/annotations/fieldSpecs.d.ts +82 -0
- package/lib/esm/internal/annotations/fieldSpecs.d.ts.map +1 -0
- package/lib/esm/internal/annotations/fieldSpecs.js +179 -0
- package/lib/esm/internal/annotations/fieldSpecs.js.map +1 -0
- package/lib/esm/internal/annotations/fields.d.ts +39 -2
- package/lib/esm/internal/annotations/fields.d.ts.map +1 -1
- package/lib/esm/internal/annotations/fields.js +140 -13
- package/lib/esm/internal/annotations/fields.js.map +1 -1
- package/lib/esm/test/AnnotationTestUtils.d.ts +9 -0
- package/lib/esm/test/AnnotationTestUtils.d.ts.map +1 -1
- package/lib/esm/test/AnnotationTestUtils.js +17 -0
- package/lib/esm/test/AnnotationTestUtils.js.map +1 -1
- package/lib/esm/test/annotations/FieldFormat.test.d.ts +2 -0
- package/lib/esm/test/annotations/FieldFormat.test.d.ts.map +1 -0
- package/lib/esm/test/annotations/FieldFormat.test.js +738 -0
- package/lib/esm/test/annotations/FieldFormat.test.js.map +1 -0
- package/lib/esm/test/annotations/FieldFormattingLifecycle.test.d.ts +2 -0
- package/lib/esm/test/annotations/FieldFormattingLifecycle.test.d.ts.map +1 -0
- package/lib/esm/test/annotations/FieldFormattingLifecycle.test.js +323 -0
- package/lib/esm/test/annotations/FieldFormattingLifecycle.test.js.map +1 -0
- package/lib/esm/test/annotations/FieldSpecs.test.d.ts +2 -0
- package/lib/esm/test/annotations/FieldSpecs.test.d.ts.map +1 -0
- package/lib/esm/test/annotations/FieldSpecs.test.js +54 -0
- package/lib/esm/test/annotations/FieldSpecs.test.js.map +1 -0
- package/lib/esm/test/annotations/Fields.test.js +221 -27
- package/lib/esm/test/annotations/Fields.test.js.map +1 -1
- package/lib/esm/test/ecdb/CSVImport.test.d.ts +2 -0
- package/lib/esm/test/ecdb/CSVImport.test.d.ts.map +1 -0
- package/lib/esm/test/ecdb/CSVImport.test.js +186 -0
- package/lib/esm/test/ecdb/CSVImport.test.js.map +1 -0
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js +19 -2
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECDb.test.js +207 -95
- package/lib/esm/test/ecdb/ECDb.test.js.map +1 -1
- package/lib/esm/test/ecdb/ECSqlAst.test.js +2 -2
- package/lib/esm/test/ecdb/ECSqlAst.test.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/lib/esm/test/ecsql/dataset/ECSqlDatasets.d.ts.map +1 -1
- package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js +7 -0
- package/lib/esm/test/ecsql/dataset/ECSqlDatasets.js.map +1 -1
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js +86 -7
- package/lib/esm/test/ecsql/src/ECSqlTestRunner.test.js.map +1 -1
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js +65 -1
- package/lib/esm/test/hubaccess/BriefcaseManager.test.js.map +1 -1
- package/lib/esm/test/imodel/IModelElements.test.js +5 -0
- package/lib/esm/test/imodel/IModelElements.test.js.map +1 -1
- package/lib/esm/test/standalone/ChangesetReader.test.js +111 -2
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/test/standalone/DgnDomainMergeConflict.test.js +61 -0
- package/lib/esm/test/standalone/DgnDomainMergeConflict.test.js.map +1 -1
- package/lib/esm/test/standalone/SQLiteDb.test.d.ts.map +1 -1
- package/lib/esm/test/standalone/SQLiteDb.test.js +116 -0
- package/lib/esm/test/standalone/SQLiteDb.test.js.map +1 -1
- package/package.json +16 -14
|
@@ -80,6 +80,118 @@ describe("ECDb", () => {
|
|
|
80
80
|
__disposeResources(env_1);
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
|
+
it("supports opt-in fallback for a missing navigation relationship class id", () => {
|
|
84
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
85
|
+
try {
|
|
86
|
+
const ecdb = __addDisposableResource(env_2, ECDbTestHelper.createECDb(outDir, "nav-rel-class-id-fallback.ecdb", `
|
|
87
|
+
<ECSchema schemaName="NavFallback" alias="nf" version="01.00.00" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.2">
|
|
88
|
+
<ECEntityClass typeName="Hub" modifier="Sealed">
|
|
89
|
+
<ECProperty propertyName="Name" typeName="string"/>
|
|
90
|
+
</ECEntityClass>
|
|
91
|
+
<ECEntityClass typeName="Spoke" modifier="Sealed">
|
|
92
|
+
<ECProperty propertyName="Name" typeName="string"/>
|
|
93
|
+
<ECNavigationProperty propertyName="Owner" relationshipName="HubOwnsSpokes" direction="Backward"/>
|
|
94
|
+
</ECEntityClass>
|
|
95
|
+
<ECRelationshipClass typeName="HubOwnsSpokes" strength="Referencing" modifier="Abstract">
|
|
96
|
+
<Source multiplicity="(0..1)" polymorphic="False" roleLabel="owns">
|
|
97
|
+
<Class class="Hub"/>
|
|
98
|
+
</Source>
|
|
99
|
+
<Target multiplicity="(0..*)" polymorphic="True" roleLabel="is owned by">
|
|
100
|
+
<Class class="Spoke"/>
|
|
101
|
+
</Target>
|
|
102
|
+
</ECRelationshipClass>
|
|
103
|
+
<ECRelationshipClass typeName="HubOwnsSpoke" strength="Referencing" modifier="Sealed">
|
|
104
|
+
<BaseClass>HubOwnsSpokes</BaseClass>
|
|
105
|
+
<Source multiplicity="(0..1)" polymorphic="False" roleLabel="owns">
|
|
106
|
+
<Class class="Hub"/>
|
|
107
|
+
</Source>
|
|
108
|
+
<Target multiplicity="(0..*)" polymorphic="True" roleLabel="is owned by">
|
|
109
|
+
<Class class="Spoke"/>
|
|
110
|
+
</Target>
|
|
111
|
+
</ECRelationshipClass>
|
|
112
|
+
</ECSchema>`), false);
|
|
113
|
+
const insert = (ecsql, bind) => ecdb.withCachedWriteStatement(ecsql, (statement) => {
|
|
114
|
+
bind?.(statement);
|
|
115
|
+
const result = statement.stepForInsert();
|
|
116
|
+
assert.equal(result.status, DbResult.BE_SQLITE_DONE);
|
|
117
|
+
assert.isDefined(result.id);
|
|
118
|
+
return result.id;
|
|
119
|
+
});
|
|
120
|
+
const queryClassId = (className) => {
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
122
|
+
return ecdb.withPreparedStatement("SELECT c.ECInstanceId FROM meta.ECClassDef c JOIN meta.ECSchemaDef s ON c.Schema.Id=s.ECInstanceId WHERE s.Name='NavFallback' AND c.Name=?", (statement) => {
|
|
123
|
+
statement.bindString(1, className);
|
|
124
|
+
assert.equal(statement.step(), DbResult.BE_SQLITE_ROW);
|
|
125
|
+
return statement.getValue(0).getId();
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
const hubClassId = queryClassId("Hub");
|
|
129
|
+
const rootRelationshipClassId = queryClassId("HubOwnsSpokes");
|
|
130
|
+
const derivedRelationshipClassId = queryClassId("HubOwnsSpoke");
|
|
131
|
+
const hubId = insert("INSERT INTO nf.Hub(Name) VALUES('hub')");
|
|
132
|
+
const legacySpokeId = insert("INSERT INTO nf.Spoke(Name, Owner.Id, Owner.RelECClassId) VALUES('legacy', ?, NULL)", (statement) => statement.bindId(1, hubId));
|
|
133
|
+
const normalSpokeId = insert("INSERT INTO nf.Spoke(Name, Owner.Id, Owner.RelECClassId) VALUES('normal', ?, ?)", (statement) => {
|
|
134
|
+
statement.bindId(1, hubId);
|
|
135
|
+
statement.bindId(2, derivedRelationshipClassId);
|
|
136
|
+
});
|
|
137
|
+
ecdb.saveChanges();
|
|
138
|
+
const queryCount = (ecsql, ids = []) => {
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
140
|
+
return ecdb.withPreparedStatement(ecsql, (statement) => {
|
|
141
|
+
ids.forEach((id, index) => statement.bindId(index + 1, id));
|
|
142
|
+
assert.equal(statement.step(), DbResult.BE_SQLITE_ROW);
|
|
143
|
+
return statement.getValue(0).getInteger();
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
assert.equal(queryCount("SELECT COUNT(*) FROM nf.HubOwnsSpokes"), 1);
|
|
147
|
+
assert.equal(queryCount("SELECT COUNT(*) FROM nf.HubOwnsSpokes ECSQLOPTIONS NAV_REL_CLASSID_FALLBACK"), 2);
|
|
148
|
+
assert.equal(queryCount("SELECT COUNT(*) FROM nf.HubOwnsSpoke"), 1);
|
|
149
|
+
assert.equal(queryCount("SELECT COUNT(*) FROM nf.HubOwnsSpoke ECSQLOPTIONS NAV_REL_CLASSID_FALLBACK"), 1);
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
151
|
+
ecdb.withPreparedStatement("SELECT ECClassId, SourceECInstanceId, TargetECInstanceId FROM nf.HubOwnsSpokes WHERE TargetECInstanceId=? ECSQLOPTIONS NAV_REL_CLASSID_FALLBACK", (statement) => {
|
|
152
|
+
statement.bindId(1, legacySpokeId);
|
|
153
|
+
assert.equal(statement.step(), DbResult.BE_SQLITE_ROW);
|
|
154
|
+
assert.equal(statement.getValue(0).getId(), rootRelationshipClassId);
|
|
155
|
+
assert.equal(statement.getValue(1).getId(), hubId);
|
|
156
|
+
assert.equal(statement.getValue(2).getId(), legacySpokeId);
|
|
157
|
+
assert.equal(statement.step(), DbResult.BE_SQLITE_DONE);
|
|
158
|
+
});
|
|
159
|
+
const relationsCountSql = `SELECT COUNT(*) FROM ECVLib.Relations(?, ?, 'forward')
|
|
160
|
+
ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES`;
|
|
161
|
+
assert.equal(queryCount(relationsCountSql, [hubId, hubClassId]), 1);
|
|
162
|
+
assert.equal(queryCount(`${relationsCountSql} NAV_REL_CLASSID_FALLBACK`, [hubId, hubClassId]), 2);
|
|
163
|
+
assert.equal(queryCount(relationsCountSql, [hubId, hubClassId]), 1);
|
|
164
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
165
|
+
ecdb.withPreparedStatement(`SELECT RelatedECInstanceId, RelationshipECClassId, RelationshipECInstanceId, NavPropertyName
|
|
166
|
+
FROM ECVLib.Relations(?, ?, 'forward') WHERE RelatedECInstanceId=?
|
|
167
|
+
ECSQLOPTIONS ENABLE_EXPERIMENTAL_FEATURES NAV_REL_CLASSID_FALLBACK`, (statement) => {
|
|
168
|
+
statement.bindId(1, hubId);
|
|
169
|
+
statement.bindId(2, hubClassId);
|
|
170
|
+
statement.bindId(3, legacySpokeId);
|
|
171
|
+
assert.equal(statement.step(), DbResult.BE_SQLITE_ROW);
|
|
172
|
+
assert.equal(statement.getValue(0).getId(), legacySpokeId);
|
|
173
|
+
assert.equal(statement.getValue(1).getId(), rootRelationshipClassId);
|
|
174
|
+
assert.equal(statement.getValue(2).getId(), legacySpokeId);
|
|
175
|
+
assert.equal(statement.getValue(3).getString(), "Owner");
|
|
176
|
+
assert.equal(statement.step(), DbResult.BE_SQLITE_DONE);
|
|
177
|
+
});
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
179
|
+
ecdb.withPreparedStatement(`SELECT Owner.RelECClassId FROM nf.Spoke WHERE ECInstanceId=?
|
|
180
|
+
ECSQLOPTIONS NAV_REL_CLASSID_FALLBACK`, (statement) => {
|
|
181
|
+
statement.bindId(1, legacySpokeId);
|
|
182
|
+
assert.equal(statement.step(), DbResult.BE_SQLITE_ROW);
|
|
183
|
+
assert.isTrue(statement.getValue(0).isNull);
|
|
184
|
+
});
|
|
185
|
+
assert.equal(queryCount("SELECT COUNT(*) FROM nf.HubOwnsSpoke WHERE TargetECInstanceId=?", [normalSpokeId]), 1);
|
|
186
|
+
}
|
|
187
|
+
catch (e_2) {
|
|
188
|
+
env_2.error = e_2;
|
|
189
|
+
env_2.hasError = true;
|
|
190
|
+
}
|
|
191
|
+
finally {
|
|
192
|
+
__disposeResources(env_2);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
83
195
|
it("should be able to close an ECDb", () => {
|
|
84
196
|
const ecdb = ECDbTestHelper.createECDb(outDir, "close.ecdb");
|
|
85
197
|
assert.isTrue(ecdb.isOpen);
|
|
@@ -87,58 +199,44 @@ describe("ECDb", () => {
|
|
|
87
199
|
assert.isFalse(ecdb.isOpen);
|
|
88
200
|
});
|
|
89
201
|
it("should be able to open an ECDb", () => {
|
|
90
|
-
const
|
|
202
|
+
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
91
203
|
try {
|
|
92
204
|
const fileName = "open.ecdb";
|
|
93
205
|
const ecdbPath = path.join(outDir, fileName);
|
|
94
206
|
{
|
|
95
|
-
const
|
|
207
|
+
const env_4 = { stack: [], error: void 0, hasError: false };
|
|
96
208
|
try {
|
|
97
|
-
const testECDb = __addDisposableResource(
|
|
209
|
+
const testECDb = __addDisposableResource(env_4, ECDbTestHelper.createECDb(outDir, fileName), false);
|
|
98
210
|
assert.isTrue(testECDb.isOpen);
|
|
99
211
|
}
|
|
100
|
-
catch (
|
|
101
|
-
|
|
102
|
-
|
|
212
|
+
catch (e_3) {
|
|
213
|
+
env_4.error = e_3;
|
|
214
|
+
env_4.hasError = true;
|
|
103
215
|
}
|
|
104
216
|
finally {
|
|
105
|
-
__disposeResources(
|
|
217
|
+
__disposeResources(env_4);
|
|
106
218
|
}
|
|
107
219
|
}
|
|
108
|
-
const ecdb = __addDisposableResource(
|
|
220
|
+
const ecdb = __addDisposableResource(env_3, new ECDb(), false);
|
|
109
221
|
ecdb.openDb(ecdbPath, ECDbOpenMode.ReadWrite);
|
|
110
222
|
assert.isTrue(ecdb.isOpen);
|
|
111
223
|
}
|
|
112
|
-
catch (
|
|
113
|
-
|
|
114
|
-
|
|
224
|
+
catch (e_4) {
|
|
225
|
+
env_3.error = e_4;
|
|
226
|
+
env_3.hasError = true;
|
|
115
227
|
}
|
|
116
228
|
finally {
|
|
117
|
-
__disposeResources(
|
|
229
|
+
__disposeResources(env_3);
|
|
118
230
|
}
|
|
119
231
|
});
|
|
120
232
|
it("Open ECDb with upgrade option", () => {
|
|
121
233
|
const fileName = "open.ecdb";
|
|
122
234
|
const ecdbPath = path.join(outDir, fileName);
|
|
123
|
-
{
|
|
124
|
-
const env_4 = { stack: [], error: void 0, hasError: false };
|
|
125
|
-
try {
|
|
126
|
-
const testECDb = __addDisposableResource(env_4, ECDbTestHelper.createECDb(outDir, fileName), false);
|
|
127
|
-
assert.isTrue(testECDb.isOpen);
|
|
128
|
-
}
|
|
129
|
-
catch (e_4) {
|
|
130
|
-
env_4.error = e_4;
|
|
131
|
-
env_4.hasError = true;
|
|
132
|
-
}
|
|
133
|
-
finally {
|
|
134
|
-
__disposeResources(env_4);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
235
|
{
|
|
138
236
|
const env_5 = { stack: [], error: void 0, hasError: false };
|
|
139
237
|
try {
|
|
140
|
-
const
|
|
141
|
-
assert.
|
|
238
|
+
const testECDb = __addDisposableResource(env_5, ECDbTestHelper.createECDb(outDir, fileName), false);
|
|
239
|
+
assert.isTrue(testECDb.isOpen);
|
|
142
240
|
}
|
|
143
241
|
catch (e_5) {
|
|
144
242
|
env_5.error = e_5;
|
|
@@ -152,7 +250,7 @@ describe("ECDb", () => {
|
|
|
152
250
|
const env_6 = { stack: [], error: void 0, hasError: false };
|
|
153
251
|
try {
|
|
154
252
|
const ecdb = __addDisposableResource(env_6, new ECDb(), false);
|
|
155
|
-
assert.doesNotThrow(() => ecdb.openDb(ecdbPath, ECDbOpenMode.
|
|
253
|
+
assert.doesNotThrow(() => ecdb.openDb(ecdbPath, ECDbOpenMode.Readonly));
|
|
156
254
|
}
|
|
157
255
|
catch (e_6) {
|
|
158
256
|
env_6.error = e_6;
|
|
@@ -166,7 +264,7 @@ describe("ECDb", () => {
|
|
|
166
264
|
const env_7 = { stack: [], error: void 0, hasError: false };
|
|
167
265
|
try {
|
|
168
266
|
const ecdb = __addDisposableResource(env_7, new ECDb(), false);
|
|
169
|
-
assert.doesNotThrow(() => ecdb.openDb(ecdbPath, ECDbOpenMode.
|
|
267
|
+
assert.doesNotThrow(() => ecdb.openDb(ecdbPath, ECDbOpenMode.ReadWrite));
|
|
170
268
|
}
|
|
171
269
|
catch (e_7) {
|
|
172
270
|
env_7.error = e_7;
|
|
@@ -176,13 +274,27 @@ describe("ECDb", () => {
|
|
|
176
274
|
__disposeResources(env_7);
|
|
177
275
|
}
|
|
178
276
|
}
|
|
277
|
+
{
|
|
278
|
+
const env_8 = { stack: [], error: void 0, hasError: false };
|
|
279
|
+
try {
|
|
280
|
+
const ecdb = __addDisposableResource(env_8, new ECDb(), false);
|
|
281
|
+
assert.doesNotThrow(() => ecdb.openDb(ecdbPath, ECDbOpenMode.FileUpgrade));
|
|
282
|
+
}
|
|
283
|
+
catch (e_8) {
|
|
284
|
+
env_8.error = e_8;
|
|
285
|
+
env_8.hasError = true;
|
|
286
|
+
}
|
|
287
|
+
finally {
|
|
288
|
+
__disposeResources(env_8);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
179
291
|
});
|
|
180
292
|
it("attach/detach newer profile version", async () => {
|
|
181
|
-
const
|
|
293
|
+
const env_9 = { stack: [], error: void 0, hasError: false };
|
|
182
294
|
try {
|
|
183
295
|
const fileName1 = "source_file.ecdb";
|
|
184
296
|
const ecdbPath1 = path.join(outDir, fileName1);
|
|
185
|
-
const testECDb = __addDisposableResource(
|
|
297
|
+
const testECDb = __addDisposableResource(env_9, ECDbTestHelper.createECDb(outDir, fileName1, `<ECSchema schemaName="Test" alias="test" version="01.00.00" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.1">
|
|
186
298
|
<ECEntityClass typeName="Person" modifier="Sealed">
|
|
187
299
|
<ECProperty propertyName="Name" typeName="string"/>
|
|
188
300
|
<ECProperty propertyName="Age" typeName="int"/>
|
|
@@ -221,7 +333,7 @@ describe("ECDb", () => {
|
|
|
221
333
|
}
|
|
222
334
|
return result;
|
|
223
335
|
};
|
|
224
|
-
const testECDb0 = __addDisposableResource(
|
|
336
|
+
const testECDb0 = __addDisposableResource(env_9, ECDbTestHelper.createECDb(outDir, "file2.ecdb"), false);
|
|
225
337
|
// following call will not fail but unknow ECDb profile will cause it to be attach as SQLite.
|
|
226
338
|
testECDb0.attachDb(ecdbPath1, "source");
|
|
227
339
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
@@ -251,7 +363,7 @@ describe("ECDb", () => {
|
|
|
251
363
|
]);
|
|
252
364
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
253
365
|
expect(() => testECDb0.withPreparedStatement("SELECT Name, Age FROM source.test.Person", () => { })).to.throw("ECClass 'source.test.Person' does not exist or could not be loaded.");
|
|
254
|
-
const testECDb1 = __addDisposableResource(
|
|
366
|
+
const testECDb1 = __addDisposableResource(env_9, ECDbTestHelper.createECDb(outDir, "file4.ecdb"), false);
|
|
255
367
|
testECDb1.attachDb(ecdbPath1, "source");
|
|
256
368
|
const reader1 = testECDb1.createQueryReader("SELECT Name, Age FROM source.test.Person");
|
|
257
369
|
let expectThrow = false;
|
|
@@ -289,20 +401,20 @@ describe("ECDb", () => {
|
|
|
289
401
|
},
|
|
290
402
|
]);
|
|
291
403
|
}
|
|
292
|
-
catch (
|
|
293
|
-
|
|
294
|
-
|
|
404
|
+
catch (e_9) {
|
|
405
|
+
env_9.error = e_9;
|
|
406
|
+
env_9.hasError = true;
|
|
295
407
|
}
|
|
296
408
|
finally {
|
|
297
|
-
__disposeResources(
|
|
409
|
+
__disposeResources(env_9);
|
|
298
410
|
}
|
|
299
411
|
});
|
|
300
412
|
it("attach/detach file & db_list pragma", async () => {
|
|
301
|
-
const
|
|
413
|
+
const env_10 = { stack: [], error: void 0, hasError: false };
|
|
302
414
|
try {
|
|
303
415
|
const fileName1 = "source_file.ecdb";
|
|
304
416
|
const ecdbPath1 = path.join(outDir, fileName1);
|
|
305
|
-
const testECDb = __addDisposableResource(
|
|
417
|
+
const testECDb = __addDisposableResource(env_10, ECDbTestHelper.createECDb(outDir, fileName1, `<ECSchema schemaName="Test" alias="test" version="01.00.00" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.1">
|
|
306
418
|
<ECEntityClass typeName="Person" modifier="Sealed">
|
|
307
419
|
<ECProperty propertyName="Name" typeName="string"/>
|
|
308
420
|
<ECProperty propertyName="Age" typeName="int"/>
|
|
@@ -328,7 +440,7 @@ describe("ECDb", () => {
|
|
|
328
440
|
return result;
|
|
329
441
|
});
|
|
330
442
|
};
|
|
331
|
-
const testECDb0 = __addDisposableResource(
|
|
443
|
+
const testECDb0 = __addDisposableResource(env_10, ECDbTestHelper.createECDb(outDir, "file2.ecdb"), false);
|
|
332
444
|
testECDb0.attachDb(ecdbPath1, "source");
|
|
333
445
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
334
446
|
testECDb0.withPreparedStatement("SELECT Name, Age FROM source.test.Person", (stmt) => {
|
|
@@ -362,14 +474,14 @@ describe("ECDb", () => {
|
|
|
362
474
|
]);
|
|
363
475
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
364
476
|
expect(() => testECDb0.withPreparedStatement("SELECT Name, Age FROM source.test.Person", () => { })).to.throw("ECClass 'source.test.Person' does not exist or could not be loaded.");
|
|
365
|
-
const testECDb1 = __addDisposableResource(
|
|
477
|
+
const testECDb1 = __addDisposableResource(env_10, ECDbTestHelper.createECDb(outDir, "file3.ecdb"), false);
|
|
366
478
|
testECDb1.attachDb(ecdbPath1, "source");
|
|
367
479
|
const reader1 = testECDb1.createQueryReader("SELECT Name, Age FROM source.test.Person", undefined, new QueryOptionsBuilder().setUsePrimaryConnection(true).getOptions());
|
|
368
480
|
assert.equal(await reader1.step(), true);
|
|
369
481
|
assert.equal(reader1.current.name, "Mary");
|
|
370
482
|
assert.equal(reader1.current.age, 45);
|
|
371
483
|
testECDb1.detachDb("source");
|
|
372
|
-
const testECDb2 = __addDisposableResource(
|
|
484
|
+
const testECDb2 = __addDisposableResource(env_10, ECDbTestHelper.createECDb(outDir, "file4.ecdb"), false);
|
|
373
485
|
testECDb2.attachDb(ecdbPath1, "source");
|
|
374
486
|
const reader2 = testECDb2.createQueryReader("SELECT Name, Age FROM source.test.Person");
|
|
375
487
|
assert.equal(await reader2.step(), true);
|
|
@@ -389,24 +501,24 @@ describe("ECDb", () => {
|
|
|
389
501
|
}
|
|
390
502
|
assert.isTrue(expectThrow);
|
|
391
503
|
}
|
|
392
|
-
catch (
|
|
393
|
-
|
|
394
|
-
|
|
504
|
+
catch (e_10) {
|
|
505
|
+
env_10.error = e_10;
|
|
506
|
+
env_10.hasError = true;
|
|
395
507
|
}
|
|
396
508
|
finally {
|
|
397
|
-
__disposeResources(
|
|
509
|
+
__disposeResources(env_10);
|
|
398
510
|
}
|
|
399
511
|
});
|
|
400
512
|
it("should be able to import a schema", () => {
|
|
401
|
-
const
|
|
513
|
+
const env_11 = { stack: [], error: void 0, hasError: false };
|
|
402
514
|
try {
|
|
403
515
|
const fileName = "schemaimport.ecdb";
|
|
404
516
|
const ecdbPath = path.join(outDir, fileName);
|
|
405
517
|
let id;
|
|
406
518
|
{
|
|
407
|
-
const
|
|
519
|
+
const env_12 = { stack: [], error: void 0, hasError: false };
|
|
408
520
|
try {
|
|
409
|
-
const testECDb = __addDisposableResource(
|
|
521
|
+
const testECDb = __addDisposableResource(env_12, ECDbTestHelper.createECDb(outDir, fileName, `<ECSchema schemaName="Test" alias="test" version="01.00.00" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.1">
|
|
410
522
|
<ECEntityClass typeName="Person" modifier="Sealed">
|
|
411
523
|
<ECProperty propertyName="Name" typeName="string"/>
|
|
412
524
|
<ECProperty propertyName="Age" typeName="int"/>
|
|
@@ -422,15 +534,15 @@ describe("ECDb", () => {
|
|
|
422
534
|
});
|
|
423
535
|
testECDb.saveChanges();
|
|
424
536
|
}
|
|
425
|
-
catch (
|
|
426
|
-
|
|
427
|
-
|
|
537
|
+
catch (e_11) {
|
|
538
|
+
env_12.error = e_11;
|
|
539
|
+
env_12.hasError = true;
|
|
428
540
|
}
|
|
429
541
|
finally {
|
|
430
|
-
__disposeResources(
|
|
542
|
+
__disposeResources(env_12);
|
|
431
543
|
}
|
|
432
544
|
}
|
|
433
|
-
const ecdb = __addDisposableResource(
|
|
545
|
+
const ecdb = __addDisposableResource(env_11, new ECDb(), false);
|
|
434
546
|
ecdb.openDb(ecdbPath, ECDbOpenMode.Readonly);
|
|
435
547
|
assert.isTrue(ecdb.isOpen);
|
|
436
548
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
@@ -442,55 +554,55 @@ describe("ECDb", () => {
|
|
|
442
554
|
assert.equal(row.age, 45);
|
|
443
555
|
});
|
|
444
556
|
}
|
|
445
|
-
catch (
|
|
446
|
-
|
|
447
|
-
|
|
557
|
+
catch (e_12) {
|
|
558
|
+
env_11.error = e_12;
|
|
559
|
+
env_11.hasError = true;
|
|
448
560
|
}
|
|
449
561
|
finally {
|
|
450
|
-
__disposeResources(
|
|
562
|
+
__disposeResources(env_11);
|
|
451
563
|
}
|
|
452
564
|
});
|
|
453
565
|
it("should be able to get schema props", () => {
|
|
454
|
-
const
|
|
566
|
+
const env_13 = { stack: [], error: void 0, hasError: false };
|
|
455
567
|
try {
|
|
456
568
|
const fileName = "schema-props.ecdb";
|
|
457
569
|
const ecdbPath = path.join(outDir, fileName);
|
|
458
570
|
{
|
|
459
|
-
const
|
|
571
|
+
const env_14 = { stack: [], error: void 0, hasError: false };
|
|
460
572
|
try {
|
|
461
|
-
const testECDb = __addDisposableResource(
|
|
573
|
+
const testECDb = __addDisposableResource(env_14, ECDbTestHelper.createECDb(outDir, fileName), false);
|
|
462
574
|
assert.isTrue(testECDb.isOpen);
|
|
463
575
|
}
|
|
464
|
-
catch (
|
|
465
|
-
|
|
466
|
-
|
|
576
|
+
catch (e_13) {
|
|
577
|
+
env_14.error = e_13;
|
|
578
|
+
env_14.hasError = true;
|
|
467
579
|
}
|
|
468
580
|
finally {
|
|
469
|
-
__disposeResources(
|
|
581
|
+
__disposeResources(env_14);
|
|
470
582
|
}
|
|
471
583
|
}
|
|
472
|
-
const ecdb = __addDisposableResource(
|
|
584
|
+
const ecdb = __addDisposableResource(env_13, new ECDb(), false);
|
|
473
585
|
ecdb.openDb(ecdbPath);
|
|
474
586
|
const schema = ecdb.getSchemaProps("ECDbMeta");
|
|
475
587
|
assert.equal(schema.name, "ECDbMeta");
|
|
476
588
|
}
|
|
477
|
-
catch (
|
|
478
|
-
|
|
479
|
-
|
|
589
|
+
catch (e_14) {
|
|
590
|
+
env_13.error = e_14;
|
|
591
|
+
env_13.hasError = true;
|
|
480
592
|
}
|
|
481
593
|
finally {
|
|
482
|
-
__disposeResources(
|
|
594
|
+
__disposeResources(env_13);
|
|
483
595
|
}
|
|
484
596
|
});
|
|
485
597
|
it("Run plain SQL", () => {
|
|
486
|
-
const
|
|
598
|
+
const env_15 = { stack: [], error: void 0, hasError: false };
|
|
487
599
|
try {
|
|
488
600
|
const fileName = "plainseql.ecdb";
|
|
489
601
|
const ecdbPath = path.join(outDir, fileName);
|
|
490
602
|
{
|
|
491
|
-
const
|
|
603
|
+
const env_16 = { stack: [], error: void 0, hasError: false };
|
|
492
604
|
try {
|
|
493
|
-
const testECDb = __addDisposableResource(
|
|
605
|
+
const testECDb = __addDisposableResource(env_16, ECDbTestHelper.createECDb(outDir, fileName), false);
|
|
494
606
|
assert.isTrue(testECDb.isOpen);
|
|
495
607
|
testECDb.withPreparedSqliteStatement("CREATE TABLE Test(Id INTEGER PRIMARY KEY, Name TEXT NOT NULL, Code INTEGER)", (stmt) => {
|
|
496
608
|
assert.equal(stmt.step(), DbResult.BE_SQLITE_DONE);
|
|
@@ -515,15 +627,15 @@ describe("ECDb", () => {
|
|
|
515
627
|
});
|
|
516
628
|
testECDb.saveChanges();
|
|
517
629
|
}
|
|
518
|
-
catch (
|
|
519
|
-
|
|
520
|
-
|
|
630
|
+
catch (e_15) {
|
|
631
|
+
env_16.error = e_15;
|
|
632
|
+
env_16.hasError = true;
|
|
521
633
|
}
|
|
522
634
|
finally {
|
|
523
|
-
__disposeResources(
|
|
635
|
+
__disposeResources(env_16);
|
|
524
636
|
}
|
|
525
637
|
}
|
|
526
|
-
const ecdb = __addDisposableResource(
|
|
638
|
+
const ecdb = __addDisposableResource(env_15, new ECDb(), false);
|
|
527
639
|
ecdb.openDb(ecdbPath, ECDbOpenMode.Readonly);
|
|
528
640
|
assert.isTrue(ecdb.isOpen);
|
|
529
641
|
ecdb.withPreparedSqliteStatement("SELECT Id,Name,Code FROM Test ORDER BY Id", (stmt) => {
|
|
@@ -553,12 +665,12 @@ describe("ECDb", () => {
|
|
|
553
665
|
assert.equal(stmt.step(), DbResult.BE_SQLITE_DONE);
|
|
554
666
|
});
|
|
555
667
|
}
|
|
556
|
-
catch (
|
|
557
|
-
|
|
558
|
-
|
|
668
|
+
catch (e_16) {
|
|
669
|
+
env_15.error = e_16;
|
|
670
|
+
env_15.hasError = true;
|
|
559
671
|
}
|
|
560
672
|
finally {
|
|
561
|
-
__disposeResources(
|
|
673
|
+
__disposeResources(env_15);
|
|
562
674
|
}
|
|
563
675
|
});
|
|
564
676
|
it("test unit labels in composite formats", () => {
|
|
@@ -672,9 +784,9 @@ describe("ECDb", () => {
|
|
|
672
784
|
ecdb.closeDb();
|
|
673
785
|
});
|
|
674
786
|
it("should drop a single schema", () => {
|
|
675
|
-
const
|
|
787
|
+
const env_17 = { stack: [], error: void 0, hasError: false };
|
|
676
788
|
try {
|
|
677
|
-
const ecdb = __addDisposableResource(
|
|
789
|
+
const ecdb = __addDisposableResource(env_17, ECDbTestHelper.createECDb(outDir, "test.ecdb", `<ECSchema schemaName="Test" alias="ts" version="01.00.00" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.2">
|
|
678
790
|
<ECEntityClass typeName="Foo" modifier="Sealed">
|
|
679
791
|
<ECProperty propertyName="n" typeName="int"/>
|
|
680
792
|
</ECEntityClass>
|
|
@@ -686,16 +798,16 @@ describe("ECDb", () => {
|
|
|
686
798
|
ecdb.dropSchemas(["Test"]);
|
|
687
799
|
expect(() => ecdb.getSchemaProps("Test")).to.throw();
|
|
688
800
|
}
|
|
689
|
-
catch (
|
|
690
|
-
|
|
691
|
-
|
|
801
|
+
catch (e_17) {
|
|
802
|
+
env_17.error = e_17;
|
|
803
|
+
env_17.hasError = true;
|
|
692
804
|
}
|
|
693
805
|
finally {
|
|
694
|
-
__disposeResources(
|
|
806
|
+
__disposeResources(env_17);
|
|
695
807
|
}
|
|
696
808
|
});
|
|
697
809
|
it("should drop multiple schemas", () => {
|
|
698
|
-
const
|
|
810
|
+
const env_18 = { stack: [], error: void 0, hasError: false };
|
|
699
811
|
try {
|
|
700
812
|
const testSchema1Xml = `<?xml version="1.0" encoding="utf-8"?>
|
|
701
813
|
<ECSchema schemaName="TestSchema1" alias="ts1" version="01.00.00" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.1">
|
|
@@ -710,7 +822,7 @@ describe("ECDb", () => {
|
|
|
710
822
|
<ECProperty propertyName="Prop2" typeName="string"/>
|
|
711
823
|
</ECEntityClass>
|
|
712
824
|
</ECSchema>`;
|
|
713
|
-
const ecdb = __addDisposableResource(
|
|
825
|
+
const ecdb = __addDisposableResource(env_18, ECDbTestHelper.createECDb(outDir, "drop-multiple-schemas.ecdb"), false);
|
|
714
826
|
assert.isTrue(ecdb.isOpen);
|
|
715
827
|
const schema1Path = path.join(outDir, "TestSchema1.ecschema.xml");
|
|
716
828
|
IModelJsFs.writeFileSync(schema1Path, testSchema1Xml);
|
|
@@ -732,12 +844,12 @@ describe("ECDb", () => {
|
|
|
732
844
|
IModelJsFs.removeSync(schema1Path);
|
|
733
845
|
IModelJsFs.removeSync(schema2Path);
|
|
734
846
|
}
|
|
735
|
-
catch (
|
|
736
|
-
|
|
737
|
-
|
|
847
|
+
catch (e_18) {
|
|
848
|
+
env_18.error = e_18;
|
|
849
|
+
env_18.hasError = true;
|
|
738
850
|
}
|
|
739
851
|
finally {
|
|
740
|
-
__disposeResources(
|
|
852
|
+
__disposeResources(env_18);
|
|
741
853
|
}
|
|
742
854
|
});
|
|
743
855
|
});
|