-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: synchronizing View with schema broken for oracle (#9602)
* fix view+schema broken for oracle * apply prettier * fixed missing schema in loadViews(); added test (with .only) * removed .only Co-authored-by: James Jurach <James.Jurach@apiture.com> Co-authored-by: Alex Messer <dmzt08@gmail.com>
- Loading branch information
1 parent
67973b4
commit 18b659d
Showing
4 changed files
with
87 additions
and
7 deletions.
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,14 @@ | ||
import { | ||
Entity, | ||
PrimaryGeneratedColumn, | ||
UpdateDateColumn, | ||
} from "../../../../src" | ||
|
||
@Entity({ name: "foo", schema: "SYSTEM" }) | ||
export class Foo { | ||
@PrimaryGeneratedColumn({ name: "id" }) | ||
id: number | ||
|
||
@UpdateDateColumn({ name: "updated_at" }) | ||
updatedAt: Date | ||
} |
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,13 @@ | ||
import { DataSource, ViewColumn, ViewEntity } from "../../../../src" | ||
import { Foo } from "./Foo" | ||
|
||
@ViewEntity({ | ||
name: "foo_view", | ||
schema: "SYSTEM", | ||
expression: (connection: DataSource) => | ||
connection.createQueryBuilder(Foo, "foo").select(`foo.updatedAt`), | ||
}) | ||
export class FooView { | ||
@ViewColumn() | ||
updatedAt: Date | ||
} |
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,43 @@ | ||
import "reflect-metadata" | ||
import { DataSource } from "../../../src/index" | ||
import { | ||
closeTestingConnections, | ||
createTestingConnections, | ||
} from "../../utils/test-utils" | ||
|
||
describe("github issues > #9601 view+schema+synchronize broken for oracle", () => { | ||
let connections: DataSource[] | ||
before( | ||
async () => | ||
(connections = await createTestingConnections({ | ||
entities: [__dirname + "/entity/*{.js,.ts}"], | ||
schemaCreate: false, | ||
dropSchema: true, | ||
enabledDrivers: ["oracle"], | ||
})), | ||
) | ||
after(() => closeTestingConnections(connections)) | ||
|
||
it("should recognize model changes", () => | ||
Promise.all( | ||
connections.map(async (connection) => { | ||
const sqlInMemory = await connection.driver | ||
.createSchemaBuilder() | ||
.log() | ||
sqlInMemory.upQueries.length.should.be.greaterThan(0) | ||
sqlInMemory.downQueries.length.should.be.greaterThan(0) | ||
}), | ||
)) | ||
|
||
it("should not generate queries when no model changes", () => | ||
Promise.all( | ||
connections.map(async (connection) => { | ||
await connection.driver.createSchemaBuilder().build() | ||
const sqlInMemory = await connection.driver | ||
.createSchemaBuilder() | ||
.log() | ||
sqlInMemory.upQueries.length.should.be.equal(0) | ||
sqlInMemory.downQueries.length.should.be.equal(0) | ||
}), | ||
)) | ||
}) |