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

Allow attach/detach db to IModelDb connection #7530

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
lint
  • Loading branch information
khanaffan committed Jan 8, 2025
commit e603c2738d76025c0bf63fa5ab4b060775d1fca0
5 changes: 2 additions & 3 deletions core/backend/src/test/ecdb/ECDb.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ describe("ECDb", () => {
it("attach/detach file", async () => {
const fileName1 = "source_file.ecdb";
const ecdbPath1: string = path.join(outDir, fileName1);
let id: Id64String;
using(ECDbTestHelper.createECDb(outDir, fileName1,
`<ECSchema schemaName="Test" alias="test" version="01.00.00" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.1">
<ECEntityClass typeName="Person" modifier="Sealed">
Expand All @@ -71,7 +70,7 @@ describe("ECDb", () => {
</ECEntityClass>
</ECSchema>`), (testECDb: ECDb) => {
assert.isTrue(testECDb.isOpen);
id = testECDb.withPreparedStatement("INSERT INTO test.Person(Name,Age) VALUES('Mary', 45)", (stmt: ECSqlStatement) => {
testECDb.withPreparedStatement("INSERT INTO test.Person(Name,Age) VALUES('Mary', 45)", (stmt: ECSqlStatement) => {
const res: ECSqlInsertResult = stmt.stepForInsert();
assert.equal(res.status, DbResult.BE_SQLITE_DONE);
assert.isDefined(res.id);
Expand All @@ -91,7 +90,7 @@ describe("ECDb", () => {
testECDb.detachDb("source");
expect(() => testECDb.withPreparedStatement("SELECT Name, Age FROM source.test.Person", () => { })).to.throw("ECClass 'source.test.Person' does not exist or could not be loaded.");
});
using(ECDbTestHelper.createECDb(outDir, "file3.ecdb"), async (testECDb: ECDb) => {
await using(ECDbTestHelper.createECDb(outDir, "file3.ecdb"), async (testECDb: ECDb) => {
testECDb.attachDb(ecdbPath1, "source");
const reader = testECDb.createQueryReader("SELECT Name, Age FROM source.test.Person", undefined, new QueryOptionsBuilder().setUsePrimaryConnection(true).getOptions());
assert.equal(await reader.step(), true);
Expand Down
Loading