forked from typeorm/typeorm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* master: updated changelog fixed typeorm#1504 removed only test Update one-to-one-relations.md Handle SQLite in-memory db in ConnectionOptionsReader Update eager-and-lazy-relations.md Update eager-and-lazy-relations.md Update issue-1569.ts skipped test typeorm#1569 (need to fix in @next) Update entities.md Update entities.md added test for typeorm#1581 Update select-query-builder.md create failing test case for issue 1569 # Conflicts: # docs/eager-and-lazy-relations.md
- Loading branch information
Showing
22 changed files
with
328 additions
and
7 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
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
9 changes: 9 additions & 0 deletions
9
test/functional/connection-options-reader/configs/sqlite-memory.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,9 @@ | ||
module.exports = [{ | ||
type: "sqlite", | ||
name: "file", | ||
database: "test" | ||
}, { | ||
type: "sqlite", | ||
name: "memory", | ||
database: ":memory:", | ||
}]; |
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,15 @@ | ||
import {Column, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn} from "../../../../src"; | ||
import {TestEntity2} from "./TestEntity2"; | ||
|
||
@Entity() | ||
export class TestEntity1 { | ||
|
||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column() name: string; | ||
|
||
@OneToOne(t => TestEntity2, a => a.Entity1) | ||
@JoinColumn() | ||
Entity2: TestEntity2; | ||
} |
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, JoinColumn, OneToOne, PrimaryGeneratedColumn} from "../../../../src"; | ||
import {TestEntity1} from "./TestEntity1"; | ||
import {TestEntity3} from "./TestEntity3"; | ||
|
||
@Entity() | ||
export class TestEntity2 { | ||
|
||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column() | ||
name: string; | ||
|
||
@OneToOne(t => TestEntity1, a => a.Entity2) | ||
Entity1: TestEntity1; | ||
|
||
@OneToOne(t => TestEntity3, a => a.Entity2) | ||
@JoinColumn() | ||
Entity3: TestEntity3; | ||
|
||
} |
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,18 @@ | ||
import {Column, Entity, OneToMany, OneToOne, PrimaryGeneratedColumn} from "../../../../src"; | ||
import {TestEntity2} from "./TestEntity2"; | ||
import {TestEntity4} from "./TestEntity4"; | ||
|
||
@Entity() | ||
export class TestEntity3 { | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@OneToOne(t => TestEntity2, a => a.Entity3) | ||
Entity2: TestEntity2; | ||
|
||
@Column() | ||
name: string; | ||
|
||
@OneToMany(t => TestEntity4, entity4 => entity4.Entity3) | ||
Entity4: TestEntity4[]; | ||
} |
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,15 @@ | ||
import {Column, Entity, ManyToOne, PrimaryGeneratedColumn} from "../../../../src"; | ||
import {TestEntity3} from "./TestEntity3"; | ||
|
||
@Entity() | ||
export class TestEntity4 { | ||
|
||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column() | ||
name: string; | ||
|
||
@ManyToOne(t => TestEntity3, entity3 => entity3.Entity4) | ||
Entity3: TestEntity3; | ||
} |
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,28 @@ | ||
import "reflect-metadata"; | ||
import {closeTestingConnections, createTestingConnections, reloadTestingDatabases} from "../../utils/test-utils"; | ||
import {Connection} from "../../../src/connection/Connection"; | ||
import {TestEntity1} from "./entity/TestEntity1"; | ||
|
||
describe("github issues > #1504 Cannot eagerly query Entity with relation more than 3 levels deep", () => { | ||
|
||
let connections: Connection[]; | ||
before(async () => connections = await createTestingConnections({ | ||
entities: [__dirname + "/entity/*{.js,.ts}"], | ||
enabledDrivers: ["postgres"] | ||
})); | ||
beforeEach(() => reloadTestingDatabases(connections)); | ||
after(() => closeTestingConnections(connections)); | ||
|
||
it("should not throw an error", () => Promise.all(connections.map(async connection => { | ||
|
||
await connection | ||
.getRepository(TestEntity1) | ||
.findOne(1, { relations: [ | ||
"Entity2", | ||
"Entity2.Entity3", | ||
"Entity2.Entity3.Entity4", | ||
]}); | ||
|
||
}))); | ||
|
||
}); |
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,18 @@ | ||
import { Entity, Column, PrimaryGeneratedColumn } from "../../../../src/index"; | ||
|
||
export class EmbeddedItem { | ||
@Column({ type: "integer", array: true }) | ||
arrayInsideEmbedded: number[]; | ||
} | ||
|
||
@Entity() | ||
export class Item { | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column() | ||
someText: string; | ||
|
||
@Column(type => EmbeddedItem) | ||
embedded: EmbeddedItem; | ||
} |
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,39 @@ | ||
import "reflect-metadata"; | ||
import { expect } from "chai"; | ||
import { Connection } from "../../../src/connection/Connection"; | ||
import { closeTestingConnections, createTestingConnections, reloadTestingDatabases } from "../../utils/test-utils"; | ||
import { Item, EmbeddedItem } from "./entity/Item"; | ||
|
||
describe.skip("github issue > #1569 updateById generates wrong SQL with arrays inside embeddeds", () => { | ||
|
||
let connections: Connection[] = []; | ||
before(async () => connections = await createTestingConnections({ | ||
entities: [__dirname + "/entity/*{.js,.ts}"], | ||
enabledDrivers: ["postgres"], | ||
})); | ||
beforeEach(() => reloadTestingDatabases(connections)); | ||
after(() => closeTestingConnections(connections)); | ||
|
||
it("should properly updateById arrays inside embeddeds", () => Promise.all(connections.map(async connection => { | ||
const item = new Item(); | ||
item.someText = "some"; | ||
const embedded = new EmbeddedItem(); | ||
embedded.arrayInsideEmbedded = [1, 2, 3]; | ||
item.embedded = embedded; | ||
|
||
await connection.getRepository(Item).save(item); | ||
|
||
await connection.getRepository(Item).updateById(item.id, { | ||
someText: "some2", | ||
embedded: { | ||
arrayInsideEmbedded: [1, 2], | ||
}, | ||
}); | ||
|
||
const loadedItem = await connection.getRepository(Item).findOneById(item.id); | ||
|
||
expect(loadedItem!.embedded.arrayInsideEmbedded).to.eql([1, 2]); | ||
|
||
}))); | ||
|
||
}); |
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 {Column, Entity, PrimaryGeneratedColumn} from "../../../../src"; | ||
|
||
@Entity() | ||
export class DeliverySlot { | ||
|
||
@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,20 @@ | ||
import {DeliverySlot} from "./DeliverySlot"; | ||
import {User} from "./User"; | ||
import {OrderItem} from "./OrderItem"; | ||
import {Column, Entity, ManyToOne, OneToMany} from "../../../../src"; | ||
|
||
@Entity() | ||
export class Order { | ||
|
||
@ManyToOne(type => DeliverySlot, { primary: true }) | ||
deliverySlot: DeliverySlot; | ||
|
||
@ManyToOne(type => User, user => user.recurringOrders, { primary: true }) | ||
user: User; | ||
|
||
@Column() | ||
enabled: boolean; | ||
|
||
@OneToMany(type => OrderItem, item => item.order) | ||
items: OrderItem[]; | ||
} |
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,17 @@ | ||
import {Column, Entity, ManyToOne} from "../../../../src"; | ||
import {Order} from "./Order"; | ||
import {Product} from "./Product"; | ||
|
||
@Entity() | ||
export class OrderItem { | ||
|
||
@ManyToOne(type => Order, recurringOrder => recurringOrder.items, { primary: true }) | ||
order: Order; | ||
|
||
@ManyToOne(type => Product, { primary: true }) | ||
product: Product; | ||
|
||
@Column() | ||
amount: number; | ||
|
||
} |
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 {Column, Entity} from "../../../../src"; | ||
|
||
@Entity() | ||
export class Product { | ||
|
||
@Column({ primary: true }) | ||
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,16 @@ | ||
import {Column, Entity, OneToMany, PrimaryGeneratedColumn} from "../../../../src"; | ||
import {Order} from "./Order"; | ||
|
||
@Entity() | ||
export class User { | ||
|
||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@Column({ unique: true }) | ||
email: string; | ||
|
||
@OneToMany(type => Order, recurringOrder => recurringOrder.user) | ||
recurringOrders: Order[]; | ||
|
||
} |
Oops, something went wrong.