Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: select + addOrderBy broke in 0.3.14 (#9961)
* added test for #9960 * fixing the issue * limiting only to postgres because of NULLS FIRST syntax * lint
- Loading branch information
Showing
3 changed files
with
55 additions
and
3 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,12 @@ | ||
import { Entity } from "../../../../src/decorator/entity/Entity" | ||
import { Column } from "../../../../src/decorator/columns/Column" | ||
import { PrimaryGeneratedColumn } from "../../../../src/decorator/columns/PrimaryGeneratedColumn" | ||
|
||
@Entity() | ||
export class ExampleEntity { | ||
@PrimaryGeneratedColumn() | ||
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,42 @@ | ||
import { DataSource } from "../../../src" | ||
import { | ||
closeTestingConnections, | ||
createTestingConnections, | ||
reloadTestingDatabases, | ||
} from "../../utils/test-utils" | ||
import { ExampleEntity } from "./entity/ExampleEntity" | ||
import { expect } from "chai" | ||
|
||
describe("github issues > #9960", () => { | ||
let dataSources: DataSource[] | ||
|
||
before(async () => { | ||
dataSources = await createTestingConnections({ | ||
entities: [ExampleEntity], | ||
enabledDrivers: ["postgres"], | ||
}) | ||
}) | ||
|
||
beforeEach(() => reloadTestingDatabases(dataSources)) | ||
after(() => closeTestingConnections(dataSources)) | ||
|
||
it("select + order by must work without issues", async () => { | ||
await Promise.all( | ||
dataSources.map(async (dataSource) => { | ||
const example1 = new ExampleEntity() | ||
example1.name = "example #1" | ||
await dataSource.manager.save(example1) | ||
|
||
const examples = await dataSource.manager | ||
.createQueryBuilder(ExampleEntity, "example") | ||
.select(["example.id", "example.name"]) | ||
.addOrderBy("example.name", "DESC", "NULLS LAST") | ||
.take(1) | ||
.skip(0) | ||
.getMany() | ||
|
||
expect(examples).to.be.eql([{ id: 1, name: "example #1" }]) | ||
}), | ||
) | ||
}) | ||
}) |