title: Cross schema joins with typeorm
body: <p><strong>Steps to reproduce:</strong></p>
  
  <ol>
  <li>Create 2 schema <code>a</code> and <code>b</code></li>
  <li>Create tables user, photo in both schema with these respective entities <code>UserA</code> <code>PhotoA</code>, <code>UserB</code> <code>PhotoB</code></li>
  </ol>
  
  <pre><code>// PhotoA
  import {Entity, Column, PrimaryGeneratedColumn, ManyToOne} from "typeorm";
  import { User as UserB } from "./User.b";
  import { User as UserA } from "./User.a";
  
  @Entity({schema: "a"})
  export class Photo {
  
      @PrimaryGeneratedColumn()
      id: number;
  
      @Column({
          length: 100
      })
      name: string;
  
      @ManyToOne(type =&gt; UserA)
      userA: UserA;
      @ManyToOne(type =&gt; UserB)
      userB: UserB;
  }
  </code></pre>
  
  <pre><code>// UserB
  import {Entity, Column, PrimaryGeneratedColumn, OneToMany} from "typeorm";
  import { Photo as PhotoA } from "./Photo.a";
  import { Photo as PhotoB } from "./Photo.b";
  
  @Entity({schema: "b"})
  export class User {
  
      @PrimaryGeneratedColumn()
      id: number;
  
      @Column({
          length: 100
      })
      name: string;
  
      @OneToMany(type =&gt; PhotoA, photo =&gt; photo.userB)
      photosA: PhotoA[]
      @OneToMany(type =&gt; PhotoB, photo =&gt; photo.userB)
      photosB: PhotoB[]
  }
  </code></pre>
  
  <ol start="3">
  <li>Run this code</li>
  </ol>
  
  <pre><code>import "reflect-metadata";
  import * as typeorm from "typeorm";
  import { Photo as PhotoA } from "./entities/Photo.a";
  import { User as UserB } from "./entities/User.b";
  import { PostgresConnectionOptions } from "typeorm/driver/postgres/PostgresConnectionOptions";
  import { Photo as PhotoB } from "./entities/Photo.b";
  import { User as UserA } from "./entities/User.a";
  
  class Inl {
      public async test() {
          const connection = await typeorm.createConnection({
              type: "postgres",
              host: "localhost",
              port: 5433,
              username: "test",
              password: "test",
              database: "test",
              synchronize: true,
              logging: true,
              entities: [ PhotoA, PhotoB, UserA, UserB ]
          } as PostgresConnectionOptions);
          const photoARepo = connection.getRepository(PhotoA);
          const userBRepo = connection.getRepository(UserB);
          const userBRow = new UserB();
          userBRow.name = "User in schema B";
          const userBSavedRow = await userBRepo.save(userBRow);
          const photoARow = new PhotoA();
          photoARow.name = "Photo in schema A";
          photoARow.userB = userBSavedRow;
  
          await photoARepo.save(photoARow);
  
          const photoBRow = new PhotoB();
          photoBRow.name = "Photo in schema B";
          photoBRow.userB = userBSavedRow;
  
          await photoARepo.save(photoARow);
  
          const result = await userBRepo
              .createQueryBuilder("userB")
              .select("*")
              .leftJoinAndSelect("a.photo", "photosA")
              .leftJoinAndSelect("b.photo", "photosB")
              .where({id: userBSavedRow.id})
              .getOne();
          console.log(result);
      }
  }
  new Inl().test();
  </code></pre>
  
  <p><em>RESULTS</em></p>
  
  <pre><code>query: INSERT INTO "a"."photo"("name", "userAId", "userBId") VALUES ($1, DEFAULT, $2) RETURNING "id" -- PARAMETERS: ["Photo in schema A",6]
  query: COMMIT
  query: SELECT "Photo"."id" AS "Photo_id", "Photo"."name" AS "Photo_name", "Photo"."userAId" AS "Photo_userAId", "Photo"."userBId" AS "Photo_userBId" FROM "a"."photo" "Photo" WHERE "Photo"."id" IN ($1) -- PARAMETERS: [6]
  (node:527) UnhandledPromiseRejectionWarning: Error: "a" alias was not found. Maybe you forgot to join it?
      at QueryExpressionMap.findAliasByName (/home/lewis/Projects/internationalisation/src/query-builder/QueryExpressionMap.ts:341:19)
      at JoinAttribute.getValue (/home/lewis/Projects/internationalisation/src/query-builder/JoinAttribute.ts:146:72)
      at JoinAttribute.get [as relation] (/home/lewis/Projects/internationalisation/src/query-builder/JoinAttribute.ts:162:53)
      at JoinAttribute.get [as metadata] (/home/lewis/Projects/internationalisation/src/query-builder/JoinAttribute.ts:175:18)
      at SelectQueryBuilder.join (/home/lewis/Projects/internationalisation/src/query-builder/SelectQueryBuilder.ts:1299:27)
      at SelectQueryBuilder.leftJoin (/home/lewis/Projects/internationalisation/src/query-builder/SelectQueryBuilder.ts:284:14)
      at SelectQueryBuilder.leftJoinAndSelect (/home/lewis/Projects/internationalisation/src/query-builder/SelectQueryBuilder.ts:364:14)
      at Inl.test (/home/lewis/Projects/internationalisation/index.ts:42:14)
      at &lt;anonymous&gt;
      at process._tickCallback (internal/process/next_tick.js:160:7)
  </code></pre>
  
  <p>As you can see from the log, I'm having the error <code>alias was not found</code> with the above code. Anybody has hints on this?</p>