Search code examples
typescriptpostgresqltypeorm

typeorm generating extra column in select?


why the following typeorm query

const result6 = await getConnection()
        .createQueryBuilder()
        .select('actor.name')
        .from(Actor,'actor')
        .innerJoin('actor.castings','casting')
        .where('casting.movieId = :id',{id:27})
        .getMany();

produces this result:

SELECT "actor"."name" AS "actor_name", "actor"."id" AS "actor_id" 
FROM "actor" "actor" 
 INNER JOIN "casting" "casting" ON "casting"."actorId"="actor"."id" 
WHERE "casting"."movieId" = $1

why actor.id is also selected?


Solution

  • i just done some testing, and i noticed that the id is always included in the queries for some reason, but the returned values don't include it, it only includes what you put on the select.