Skip to content

Commit

Permalink
fix: test/functional/multi-schema-and-database/multi-schema-and-datab…
Browse files Browse the repository at this point in the history
…ase-basic-functionality
  • Loading branch information
uki00a committed Feb 11, 2020
1 parent e57baee commit 1e364fe
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 50 deletions.
1 change: 1 addition & 0 deletions test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,6 @@ import "./test/functional/mongodb/basic/repository-actions/mongodb-repository-ac
import "./test/functional/mongodb/basic/timestampable-columns/timestampable-columns.ts";
import "./test/functional/multi-schema-and-database/custom-junction-database/custom-junction-database.ts";
import "./test/functional/multi-schema-and-database/custom-junction-schema/custom-junction-schema.ts";
import "./test/functional/multi-schema-and-database/multi-schema-and-database-basic-functionality/multi-schema-and-database-basic-functionality.ts";

runTests();
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import {Entity} from "../../../../../src/decorator/entity/Entity";
import {Column} from "../../../../../src/decorator/columns/Column";
import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn";
import {Entity} from "../../../../../src/decorator/entity/Entity.ts";
import {Column} from "../../../../../src/decorator/columns/Column.ts";
import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts";

@Entity({ database: "secondDB", schema: "answers" })
export class Answer {

@PrimaryGeneratedColumn()
id: number;

@Column()
@Column({ type: String })
text: string;

@Column()
@Column({ type: Number })
questionId: number;

}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {Entity} from "../../../../../src/decorator/entity/Entity";
import {Column} from "../../../../../src/decorator/columns/Column";
import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn";
import {ManyToOne} from "../../../../../src/decorator/relations/ManyToOne";
import {Post} from "./Post";
import {Entity} from "../../../../../src/decorator/entity/Entity.ts";
import {Column} from "../../../../../src/decorator/columns/Column.ts";
import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts";
import {ManyToOne} from "../../../../../src/decorator/relations/ManyToOne.ts";
import {Post} from "./Post.ts";

@Entity({schema: "guest"})
export class Category {

@PrimaryGeneratedColumn()
id: number;

@Column()
@Column({ type: String })
name: string;

@ManyToOne(type => Post)
post: Post;

}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {Entity} from "../../../../../src/decorator/entity/Entity";
import {Column} from "../../../../../src/decorator/columns/Column";
import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn";
import {Entity} from "../../../../../src/decorator/entity/Entity.ts";
import {Column} from "../../../../../src/decorator/columns/Column.ts";
import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts";

@Entity({ database: "secondDB" })
export class Person {

@PrimaryGeneratedColumn()
id: number;

@Column()
@Column({ type: String })
name: string;

}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {Entity} from "../../../../../src/decorator/entity/Entity";
import {Column} from "../../../../../src/decorator/columns/Column";
import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn";
import {Entity} from "../../../../../src/decorator/entity/Entity.ts";
import {Column} from "../../../../../src/decorator/columns/Column.ts";
import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts";

@Entity()
export class Post {

@PrimaryGeneratedColumn()
id: number;

@Column()
@Column({ type: String })
name: string;

}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {Entity} from "../../../../../src/decorator/entity/Entity";
import {Column} from "../../../../../src/decorator/columns/Column";
import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn";
import {Entity} from "../../../../../src/decorator/entity/Entity.ts";
import {Column} from "../../../../../src/decorator/columns/Column.ts";
import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts";

@Entity({ database: "testDB", schema: "questions" })
export class Question {

@PrimaryGeneratedColumn()
id: number;

@Column()
@Column({ type: String })
name: string;

}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {Entity} from "../../../../../src/decorator/entity/Entity";
import {Column} from "../../../../../src/decorator/columns/Column";
import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn";
import {Entity} from "../../../../../src/decorator/entity/Entity.ts";
import {Column} from "../../../../../src/decorator/columns/Column.ts";
import {PrimaryGeneratedColumn} from "../../../../../src/decorator/columns/PrimaryGeneratedColumn.ts";

@Entity({ schema: "userSchema" })
export class User {

@PrimaryGeneratedColumn()
id: number;

@Column()
@Column({ type: String })
name: string;

}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import "reflect-metadata";
import {Connection} from "../../../../src/connection/Connection";
import {closeTestingConnections, createTestingConnections, reloadTestingDatabases} from "../../../utils/test-utils";
import {expect} from "chai";
import {Post} from "./entity/Post";
import {PostgresDriver} from "../../../../src/driver/postgres/PostgresDriver";
import {SqlServerDriver} from "../../../../src/driver/sqlserver/SqlServerDriver";
import {User} from "./entity/User";
import {Category} from "./entity/Category";
import {Person} from "./entity/Person";
import {Question} from "./entity/Question";
import {Answer} from "./entity/Answer";
import {MysqlDriver} from "../../../../src/driver/mysql/MysqlDriver";
import {Connection} from "../../../../src/connection/Connection.ts";
import {closeTestingConnections, createTestingConnections, reloadTestingDatabases} from "../../../utils/test-utils.ts";
import {expect} from "../../../deps/chai.ts";
import {runIfMain} from "../../../deps/mocha.ts";
import {Post} from "./entity/Post.ts";
// TODO(uki00a) uncomment this when PostgresDriver is implemented.
// import {PostgresDriver} from "../../../../src/driver/postgres/PostgresDriver.ts";
import {SqlServerDriver} from "../../../../src/driver/sqlserver/SqlServerDriver.ts";
import {User} from "./entity/User.ts";
import {Category} from "./entity/Category.ts";
import {Person} from "./entity/Person.ts";
import {Question} from "./entity/Question.ts";
import {Answer} from "./entity/Answer.ts";
import {MysqlDriver} from "../../../../src/driver/mysql/MysqlDriver.ts";

describe("multi-schema-and-database > basic-functionality", () => {

Expand Down Expand Up @@ -41,7 +42,7 @@ describe("multi-schema-and-database > basic-functionality", () => {
.where("post.id = :id", {id: 1})
.getSql();

if (connection.driver instanceof PostgresDriver)
if (false/* connection.driver instanceof PostgresDriver */) // TDOO(uki00a) uncomment this when PostgresDriver is implemented.
sql.should.be.equal(`SELECT "post"."id" AS "post_id", "post"."name" AS "post_name" FROM "custom"."post" "post" WHERE "post"."id" = $1`);

if (connection.driver instanceof SqlServerDriver)
Expand All @@ -64,7 +65,7 @@ describe("multi-schema-and-database > basic-functionality", () => {
.where("user.id = :id", {id: 1})
.getSql();

if (connection.driver instanceof PostgresDriver)
if (false/* connection.driver instanceof PostgresDriver */) // TODO(uki00a) uncomment this when PostgresDriver is implemented.
sql.should.be.equal(`SELECT "user"."id" AS "user_id", "user"."name" AS "user_name" FROM "userSchema"."user" "user" WHERE "user"."id" = $1`);

if (connection.driver instanceof SqlServerDriver)
Expand Down Expand Up @@ -102,7 +103,7 @@ describe("multi-schema-and-database > basic-functionality", () => {
.where("category.id = :id", {id: 1})
.getSql();

if (connection.driver instanceof PostgresDriver)
if (false/* connection.driver instanceof PostgresDriver */) // TODO(uki00a) uncomment this when PostgresDriver is implemeneted.
sql.should.be.equal(`SELECT "category"."id" AS "category_id", "category"."name" AS "category_name",` +
` "category"."postId" AS "category_postId", "post"."id" AS "post_id", "post"."name" AS "post_name"` +
` FROM "guest"."category" "category" INNER JOIN "custom"."post" "post" ON "post"."id"="category"."postId" WHERE "category"."id" = $1`);
Expand Down Expand Up @@ -140,7 +141,7 @@ describe("multi-schema-and-database > basic-functionality", () => {

(await query.getRawOne())!.should.be.not.empty;

if (connection.driver instanceof PostgresDriver)
if (false/* connection.driver instanceof PostgresDriver */) // TODO(uki00a) uncomment this when PostgresDriver is implemented.
query.getSql().should.be.equal(`SELECT * FROM "guest"."category" "category", "userSchema"."user" "user",` +
` "custom"."post" "post" WHERE "category"."id" = $1 AND "post"."id" = "category"."postId"`);

Expand Down Expand Up @@ -257,3 +258,5 @@ describe("multi-schema-and-database > basic-functionality", () => {
});

});

runIfMain(import.meta);

0 comments on commit 1e364fe

Please sign in to comment.