title: TypeORM select all rows but limit 25
body: <p><code>CandidateEntity</code></p>
  <pre><code>@Entity({ name: 'users' })
  export class CandidateEntity {
      @PrimaryGeneratedColumn()
      public id: number;
  
      @OneToOne(() =&gt; CandidateEmployeeInfoEntity, employeeInfo =&gt; employeeInfo.candidate)
      public employeeInfo: CandidateEmployeeInfoEntity;
  }
  
  </code></pre>
  <p><code>EmployeeInfoEntity</code></p>
  <pre><code>@Entity({ name: 'candidates_employee_infos' })
  export class CandidateEmployeeInfoEntity {
      @PrimaryGeneratedColumn()
      public id: number;
  
      @Column({ type: 'bool', nullable: false })
      public relocation: boolean;
  
      @Column({ type: 'text', nullable: true })
      public softSkills: string;
  
      @OneToOne(() =&gt; CandidateEntity, candidate =&gt; candidate.employeeInfo)
      public candidate: CandidateEntity;
  
      @Column({ type: 'integer' })
      public candidateId: number;
  }
  </code></pre>
  <p>I create query to select first 25 rows from 104 rows in database</p>
  <pre><code>const {
      perPage = 25,
      page = 1,
  } = params;
  const skip = (perPage * page) - perPage;
  
  let candidatesQuery = this.candidateRepository.createQueryBuilder('candidates');
  candidatesQuery = candidatesQuery.leftJoinAndSelect(`candidates.employeeInfo`, 'employeeInfo'); // problem in this relation
  candidatesQuery = candidatesQuery.skip(skip);
  candidatesQuery = candidatesQuery.take(perPage);
  
  const { entities, raw } = await candidatesQuery.getRawAndEntities();
  const count = await candidatesQuery.getCount();
  
  console.log(entities.length) // 104 rows
  console.log(raw.length) // 104 rows
  console.log(count) // 104 rows
  </code></pre>
  <p>Output sql query when typeorm return not correct results</p>
  <p>first query</p>
  <pre><code>SELECT DISTINCT &quot;distinctAlias&quot;.&quot;candidates_id&quot; as &quot;ids_candidates_id&quot; FROM (SELECT &quot;candidates&quot;.&quot;id&quot; AS &quot;candidates_id&quot;, &quot;candidates&quot;.&quot;uuid&quot; AS &quot;candidates_uuid&quot;, &quot;candidates&quot;.&quot;role&quot; AS &quot;candidates_role&quot;, &quot;candidates&quot;.&quot;first_name&quot; AS &quot;candidates_first_name&quot;, &quot;candidates&quot;.&quot;last_name&quot; AS &quot;candidates_last_name&quot;, &quot;candidates&quot;.&quot;email&quot; AS &quot;candidates_email&quot;, &quot;candidates&quot;.&quot;phone&quot; AS &quot;candidates_phone&quot;, &quot;candidates&quot;.&quot;phone_prefix&quot; AS &quot;candidates_phone_prefix&quot;, &quot;candidates&quot;.&quot;country_id&quot; AS &quot;candidates_country_id&quot;, &quot;candidates&quot;.&quot;city_id&quot; AS &quot;candidates_city_id&quot;, &quot;candidates&quot;.&quot;avatar&quot; AS &quot;candidates_avatar&quot;, &quot;candidates&quot;.&quot;confirmed_at&quot; AS &quot;candidates_confirmed_at&quot;, &quot;candidates&quot;.&quot;is_generated&quot; AS &quot;candidates_is_generated&quot;, &quot;candidates&quot;.&quot;created_at&quot; AS &quot;candidates_created_at&quot;, &quot;candidates&quot;.&quot;birthday&quot; AS &quot;candidates_birthday&quot;, &quot;candidates&quot;.&quot;type&quot; AS &quot;candidates_type&quot;, &quot;employeeInfo&quot;.&quot;id&quot; AS &quot;employeeInfo_id&quot;, &quot;employeeInfo&quot;.&quot;hourly_rate_from&quot; AS &quot;employeeInfo_hourly_rate_from&quot;, &quot;employeeInfo&quot;.&quot;hourly_rate_to&quot; AS &quot;employeeInfo_hourly_rate_to&quot;, &quot;employeeInfo&quot;.&quot;hourly_rate_currency&quot; AS &quot;employeeInfo_hourly_rate_currency&quot;, &quot;employeeInfo&quot;.&quot;salary_rate_from&quot; AS &quot;employeeInfo_salary_rate_from&quot;, &quot;employeeInfo&quot;.&quot;salary_rate_to&quot; AS &quot;employeeInfo_salary_rate_to&quot;, &quot;employeeInfo&quot;.&quot;salary_rate_currency&quot; AS &quot;employeeInfo_salary_rate_currency&quot;, &quot;employeeInfo&quot;.&quot;relocation&quot; AS &quot;employeeInfo_relocation&quot;, &quot;employeeInfo&quot;.&quot;soft_skills&quot; AS &quot;employeeInfo_soft_skills&quot;, &quot;employeeInfo&quot;.&quot;candidate_id&quot; AS &quot;employeeInfo_candidate_id&quot; FROM &quot;users&quot; &quot;candidates&quot; LEFT JOIN &quot;candidates_employee_infos&quot; &quot;employeeInfo&quot; ON &quot;employeeInfo&quot;.&quot;candidate_id&quot;=&quot;candidates&quot;.&quot;id&quot; WHERE  &quot;candidates&quot;.&quot;type&quot; IN ($1)) &quot;distinctAlias&quot; ORDER BY &quot;candidates_id&quot; ASC LIMIT 25
  </code></pre>
  <p>second query</p>
  <pre><code>SELECT &quot;candidates&quot;.&quot;id&quot; AS &quot;candidates_id&quot;, &quot;candidates&quot;.&quot;uuid&quot; AS &quot;candidates_uuid&quot;, &quot;candidates&quot;.&quot;role&quot; AS &quot;candidates_role&quot;, &quot;candidates&quot;.&quot;first_name&quot; AS &quot;candidates_first_name&quot;, &quot;candidates&quot;.&quot;last_name&quot; AS &quot;candidates_last_name&quot;, &quot;candidates&quot;.&quot;email&quot; AS &quot;candidates_email&quot;, &quot;candidates&quot;.&quot;phone&quot; AS &quot;candidates_phone&quot;, &quot;candidates&quot;.&quot;phone_prefix&quot; AS &quot;candidates_phone_prefix&quot;, &quot;candidates&quot;.&quot;country_id&quot; AS &quot;candidates_country_id&quot;, &quot;candidates&quot;.&quot;city_id&quot; AS &quot;candidates_city_id&quot;, &quot;candidates&quot;.&quot;avatar&quot; AS &quot;candidates_avatar&quot;, &quot;candidates&quot;.&quot;confirmed_at&quot; AS &quot;candidates_confirmed_at&quot;, &quot;candidates&quot;.&quot;is_generated&quot; AS &quot;candidates_is_generated&quot;, &quot;candidates&quot;.&quot;created_at&quot; AS &quot;candidates_created_at&quot;, &quot;candidates&quot;.&quot;birthday&quot; AS &quot;candidates_birthday&quot;, &quot;candidates&quot;.&quot;type&quot; AS &quot;candidates_type&quot;, &quot;employeeInfo&quot;.&quot;id&quot; AS &quot;employeeInfo_id&quot;, &quot;employeeInfo&quot;.&quot;hourly_rate_from&quot; AS &quot;employeeInfo_hourly_rate_from&quot;, &quot;employeeInfo&quot;.&quot;hourly_rate_to&quot; AS &quot;employeeInfo_hourly_rate_to&quot;, &quot;employeeInfo&quot;.&quot;hourly_rate_currency&quot; AS &quot;employeeInfo_hourly_rate_currency&quot;, &quot;employeeInfo&quot;.&quot;salary_rate_from&quot; AS &quot;employeeInfo_salary_rate_from&quot;, &quot;employeeInfo&quot;.&quot;salary_rate_to&quot; AS &quot;employeeInfo_salary_rate_to&quot;, &quot;employeeInfo&quot;.&quot;salary_rate_currency&quot; AS &quot;employeeInfo_salary_rate_currency&quot;, &quot;employeeInfo&quot;.&quot;relocation&quot; AS &quot;employeeInfo_relocation&quot;, &quot;employeeInfo&quot;.&quot;soft_skills&quot; AS &quot;employeeInfo_soft_skills&quot;, &quot;employeeInfo&quot;.&quot;candidate_id&quot; AS &quot;employeeInfo_candidate_id&quot; FROM &quot;users&quot; &quot;candidates&quot; LEFT JOIN &quot;candidates_employee_infos&quot; &quot;employeeInfo&quot; ON &quot;employeeInfo&quot;.&quot;candidate_id&quot;=&quot;candidates&quot;.&quot;id&quot; WHERE  &quot;candidates&quot;.&quot;type&quot; IN ($1)
  </code></pre>
  <p>third query</p>
  <pre><code>SELECT COUNT(DISTINCT(&quot;candidates&quot;.&quot;id&quot;)) as &quot;cnt&quot; FROM &quot;users&quot; &quot;candidates&quot; LEFT JOIN &quot;candidates_employee_infos&quot; &quot;employeeInfo&quot; ON &quot;employeeInfo&quot;.&quot;candidate_id&quot;=&quot;candidates&quot;.&quot;id&quot; WHERE  &quot;candidates&quot;.&quot;type&quot; IN ($1)
  </code></pre>
  <p>When I remove load relation <code>employeeInfo</code>.<br />
  This line
  <code>candidatesQuery = candidatesQuery.leftJoinAndSelect('candidates.employeeInfo', 'employeeInfo');</code></p>
  <p>TypeORM return 25 rows</p>
  <pre><code>console.log(entities.length) // 25 rows
  console.log(raw.length) // 25 rows
  console.log(count) // 104 rows
  </code></pre>
  <p>Why ? And how to fix this problem ?</p>