Skip to content

Commit

Permalink
fix: test for typeorm#4165
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin-Dobell committed Jan 13, 2020
1 parent c8b93bf commit 49564e4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/query-builder/QueryExpressionMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ export class QueryExpressionMap {
map.callObservers = this.callObservers;
map.useTransaction = this.useTransaction;
map.nativeParameters = Object.assign({}, this.nativeParameters);
map.eagerRelations = this.eagerRelations;
return map;
}

Expand Down
4 changes: 3 additions & 1 deletion test/github-issues/4156/issue-4156.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ describe("github issues > #4156 QueryExpressionMap doesn't clone all values corr
await prepareData(connection);

const qb = connection.manager
.createQueryBuilder("Post", "post");
.createQueryBuilder("Post", "post")
.disableEagerRelations(true);

const [loadedPost1, loadedPost2] = await Promise.all([
qb.clone().where({ id: 1 }).getOne(),
Expand All @@ -62,6 +63,7 @@ describe("github issues > #4156 QueryExpressionMap doesn't clone all values corr

const qb = connection.manager
.createQueryBuilder("Post", "post")
.disableEagerRelations(true)
.where({ id: 1 });

const [loadedPost1, loadedPost2] = await Promise.all([
Expand Down
8 changes: 6 additions & 2 deletions test/github-issues/5334/entity/SomeEntityWithADate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import {Column, Entity} from "../../../../src";
import {Column, Entity, Generated, PrimaryColumn} from "../../../../src";

@Entity()
export default class SomeEntityWithADate {
@Column({type: "time without time zone"})
@PrimaryColumn("integer")
@Generated()
id: number;

@Column({type: "date"})
someDateField: Date;
}
16 changes: 10 additions & 6 deletions test/github-issues/5334/issue-5334.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import "reflect-metadata";
import {expect} from "chai";

import {Connection} from "../../../src";
import {closeTestingConnections, createTestingConnections, reloadTestingDatabases} from "../../utils/test-utils";
import {Connection} from "../../../src/connection/Connection";

import SomeEntityWithADate from "./entity/SomeEntityWithADate";


describe("github issues > #9999 Unable to perform find with where clause containing a date", () => {
describe("github issues > #5334 Unable to perform find with where clause containing a date", () => {

let connections: Connection[];
before(async () => connections = await createTestingConnections({
Expand All @@ -15,7 +15,7 @@ describe("github issues > #9999 Unable to perform find with where clause contain
beforeEach(() => reloadTestingDatabases(connections));
after(() => closeTestingConnections(connections));

it("should work as expected", () => Promise.all(connections.map(async connection => {
it("should findOne with Date without throwing an error", () => Promise.all(connections.map(async connection => {

const date = new Date("2020-01-13");

Expand All @@ -25,13 +25,17 @@ describe("github issues > #9999 Unable to perform find with where clause contain

const repository = connection.getRepository(SomeEntityWithADate);

const foundEntity = await repository.findOne({
const findSomeEntity = repository.findOne({
where: {
someDateField: date
}
});

expect(foundEntity).to.not.be.null;
findSomeEntity.should.not.be.rejected;

const entity = await findSomeEntity;

expect(entity).to.not.be.null;

})));

Expand Down

0 comments on commit 49564e4

Please sign in to comment.