Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Do not add NULL/NOT NULL for stored columns (#7708)
closes: #7698
- Loading branch information
Showing
3 changed files
with
48 additions
and
2 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,21 @@ | ||
import { Column, Entity, PrimaryGeneratedColumn } from "../../../../src"; | ||
|
||
@Entity() | ||
export class Test { | ||
|
||
@PrimaryGeneratedColumn({ type: 'int' }) | ||
id: number; | ||
|
||
@Column() | ||
firstName: string | ||
|
||
@Column() | ||
lastName: string | ||
|
||
@Column({ | ||
generatedType: 'STORED', | ||
// asExpression is needed here or generatedType above will be ignored | ||
asExpression: "concat(`firstName`,' ',`lastName`)", | ||
}) | ||
name: string; | ||
} |
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,25 @@ | ||
import "reflect-metadata"; | ||
import { Connection } from "../../../src"; | ||
import { closeTestingConnections, createTestingConnections, reloadTestingDatabases } from "../../utils/test-utils"; | ||
import { Test } from "./entity/Test"; | ||
|
||
describe("github issues > #7698 MariaDB STORED columns don't accept [NULL | NOT NULL]", () => { | ||
|
||
let connections: Connection[]; | ||
before(async () => { | ||
connections = await createTestingConnections({ | ||
enabledDrivers: ["mariadb"], | ||
entities: [Test], | ||
schemaCreate: false, | ||
dropSchema: true | ||
}); | ||
}); | ||
beforeEach(() => reloadTestingDatabases(connections)); | ||
after(() => closeTestingConnections(connections)); | ||
|
||
it("should not generate queries with NULL or NOT NULL for stored columns in mariadb", () => Promise.all(connections.map(async connection => { | ||
await connection.driver.createSchemaBuilder().build(); | ||
const sqlInMemory = await connection.driver.createSchemaBuilder().log(); | ||
sqlInMemory.upQueries.length.should.be.greaterThan(0); | ||
}))); | ||
}); |