-
-
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: sqlite temporary tables now honor withoutRowid (#8431)
* fix: sqlite temporary tables now honor withoutRowid Closes: #8430 * merge master * fixed `withoutRowid` on table recreation; added test; Co-authored-by: Thrasher <thrasher@grayshift.com> Co-authored-by: Alex Messer <dmzt08@gmail.com>
- Loading branch information
1 parent
c4f4650
commit b8d04dc
Showing
5 changed files
with
78 additions
and
8 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
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,10 @@ | ||
import { Column, Entity, PrimaryColumn } from "../../../../src" | ||
|
||
@Entity({ withoutRowid: true }) | ||
export class Post { | ||
@PrimaryColumn() | ||
id: number | ||
|
||
@Column() | ||
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,50 @@ | ||
import "reflect-metadata" | ||
import { DataSource } from "../../../src" | ||
import { | ||
reloadTestingDatabases, | ||
createTestingConnections, | ||
closeTestingConnections, | ||
} from "../../utils/test-utils" | ||
import { expect } from "chai" | ||
|
||
describe("github issues > #8430 sqlite temporary tables do not honor withoutRowid", () => { | ||
let connections: DataSource[] = [] | ||
before( | ||
async () => | ||
(connections = await createTestingConnections({ | ||
entities: [__dirname + "/entity/*{.js,.ts}"], | ||
enabledDrivers: ["sqlite", "better-sqlite3"], | ||
})), | ||
) | ||
beforeEach(() => reloadTestingDatabases(connections)) | ||
after(() => closeTestingConnections(connections)) | ||
|
||
// ------------------------------------------------------------------------- | ||
// Specifications | ||
// ------------------------------------------------------------------------- | ||
|
||
it("should keep 'withoutRowid' after table recreation", () => | ||
Promise.all( | ||
connections.map(async (connection) => { | ||
const queryRunner = connection.createQueryRunner() | ||
const table = await queryRunner.getTable("post") | ||
|
||
expect(table!.withoutRowid).to.be.true | ||
|
||
let nameColumn = table!.findColumnByName("name")! | ||
const changedColumn = nameColumn.clone() | ||
changedColumn.name = "changedName" | ||
|
||
await queryRunner.changeColumn( | ||
table!, | ||
nameColumn, | ||
changedColumn, | ||
) | ||
|
||
const changedTable = await queryRunner.getTable("post") | ||
await queryRunner.release() | ||
|
||
expect(changedTable!.withoutRowid).to.be.true | ||
}), | ||
)) | ||
}) |