forked from typeorm/typeorm
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: SqlQueryRunner.hasColumn was not working (typeorm#6146)
* fixed typeorm#5718 * removed .only
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import "reflect-metadata"; | ||
import {Connection} from "../../../src/connection/Connection"; | ||
import {closeTestingConnections, createTestingConnections} from "../../utils/test-utils"; | ||
|
||
describe("query runner > has column", () => { | ||
|
||
let connections: Connection[]; | ||
before(async () => { | ||
connections = await createTestingConnections({ | ||
entities: [__dirname + "/entity/*{.js,.ts}"], | ||
schemaCreate: true, | ||
dropSchema: true, | ||
}); | ||
}); | ||
after(() => closeTestingConnections(connections)); | ||
|
||
it("should correctly check if column exist", () => Promise.all(connections.map(async connection => { | ||
const queryRunner = connection.createQueryRunner(); | ||
|
||
let hasIdColumn = await queryRunner.hasColumn("post", "id"); | ||
let hasNameColumn = await queryRunner.hasColumn("post", "name"); | ||
let hasVersionColumn = await queryRunner.hasColumn("post", "version"); | ||
let hasDescriptionColumn = await queryRunner.hasColumn("post", "description"); | ||
|
||
hasIdColumn.should.be.true; | ||
hasNameColumn.should.be.true; | ||
hasVersionColumn.should.be.true; | ||
hasDescriptionColumn.should.be.false; | ||
|
||
await queryRunner.release(); | ||
}))); | ||
|
||
}); |