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: count() method for multiple primary keys for cockroachdb (typeor…
…m#6745) * fix: count() method for multiple primary keys for cockroachdb Cockroachdb does not support concat() for different types at the moment. To fix this problem, each primary key is cast to the text type. * fix: add doublequote * fix: add doublequote * test: update and move tests for count() method for multiple primary keys * fix: count() method for multiple primary keys for oracle Oracle does not support CONCAT() for more than 2 arguments at the moment. To solve this problem, operator || is used instead of CONCAT().
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 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,13 @@ | ||
import {Entity, PrimaryColumn} from "../../../../../src"; | ||
|
||
@Entity("tests") | ||
export class Test { | ||
@PrimaryColumn() | ||
varcharField: string; | ||
|
||
@PrimaryColumn("uuid") | ||
uuidField: string; | ||
|
||
@PrimaryColumn() | ||
intField: number; | ||
} |
22 changes: 22 additions & 0 deletions
22
test/functional/query-builder/count/query-builder-count.ts
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,22 @@ | ||
import {closeTestingConnections, createTestingConnections, reloadTestingDatabases} from "../../../utils/test-utils"; | ||
import {Connection} from "../../../../src/connection/Connection"; | ||
import {expect} from "chai"; | ||
import {Test} from "./entity/Test"; | ||
|
||
describe("query builder > count", () => { | ||
|
||
let connections: Connection[]; | ||
before(async () => connections = await createTestingConnections({ | ||
entities: [Test], | ||
schemaCreate: true, | ||
dropSchema: true, | ||
})); | ||
beforeEach(() => reloadTestingDatabases(connections)); | ||
after(() => closeTestingConnections(connections)); | ||
|
||
it("Count query should be completed successfully", () => Promise.all(connections.map(async connection => { | ||
const count = await connection.getRepository(Test).count(); | ||
expect(count).to.be.equal(0); | ||
}))); | ||
|
||
}); |