question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

missing FROM-clause entry for table "???????"

See original GitHub issue

Issue type:

[x] question [ ] bug report [ ] feature request [x] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [ ] mysql / mariadb [ ] oracle [X] postgres [ ] sqlite [ ] sqljs [ ] react-native [ ] expo

TypeORM version:

[ ] latest [ ] @next [X] 0.x.x (0.2.7)

Steps to reproduce or a small repository showing the problem: My test in pgAdmin4 SELECT “campaignId”, COUNT (“campaignId”) AS “totalCampaign” FROM public.??? WHERE “campaignId” = ANY (ARRAY [31,30,28,29,23,19,24,20,21,22]) GROUP BY “campaignId” it’s OK

const countContact = await this.???Repository.createQueryBuilder(‘???’) .select(‘???.campaignId’) .addSelect(‘COUNT(???.campaignId)’, ‘totalCampaign’) .where(‘???.campaingId = ANY(:data)’, {data}) .groupBy(‘???.campaignId’) .execute();

The query is wrong, Thank

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
captainjapengcommented, Feb 24, 2020

Same issue:

SELECT
    "organization"."id" AS "organization_id",
    "organization"."active" AS "organization_active",
    "organization"."createdAt" AS "organization_createdAt",
    "organization"."createdById" AS "organization_createdById",
    "organization"."createdByOrganizationId" AS "organization_createdByOrganizationId",
    "organization"."updatedAt" AS "organization_updatedAt",
    "organization"."updatedById" AS "organization_updatedById",
    "organization"."updatedByOrganizationId" AS "organization_updatedByOrganizationId",
    "organization"."key" AS "organization_key",
    "organization"."name" AS "organization_name",
    "organization"."isAdmin" AS "organization_isAdmin"
FROM
    "organization" "organization"
    INNER JOIN "user" "User" ON "User"."organizationId" = organization.organizationId
WHERE
    (
        "User"."organizationId" = $ 1
        AND "User"."id" = $ 2
    )

As you can see, I have defined a @JoinColumn but it’s not getting respected. And the generated query’s inner join doesn’t have double quotes in it.

Here is my entity definition:


@ObjectType({ isAbstract: true })
export class Node {
  @Field(type => ID)
  @PrimaryGeneratedColumn('uuid')
  id: string

  ...
}

@Entity()
@ObjectType()
export class Organization extends Node {
  ...
}

export class MultiTenantNode {
  @PrimaryColumn('uuid')
  organizationId: string

  @ManyToOne(type => Organization, { lazy: true })
  @JoinColumn({ name: 'organizationId', referencedColumnName: 'id' })
  organization: Lazy<Organization>

  @Field(type => ID)
  @PrimaryGeneratedColumn('uuid')
  id: string
}

@Entity()
@ObjectType()
export class User extends MultiTenantNode {
  ...
}
3reactions
aliarshad9691commented, May 2, 2019

I ma facing same issue, when trying to save entity with many2many relationship. This is the query its generating: SELECT Campaign_businessGroups_rid.Business_Group_Id AS "Business_Group_Id", Campaign_businessGroups_rid.Campaign_Id AS "Campaign_Id" FROM "Business_Group" "Business_Group" INNER JOIN "Campaign_Business_Group" "Campaign_businessGroups_rid" ON (Campaign_businessGroups_rid.Campaign_Id = $1 AND Campaign_businessGroups_rid.Business_Group_Id = "Business_Group"."Business_Group_Id") ORDER BY Campaign_businessGroups_rid.Business_Group_Id ASC, Campaign_businessGroups_rid.Campaign_Id ASC'

This is the error I am getting: QueryFailedError: missing FROM-clause entry for table "campaign_businessgroups_rid"

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix “ERROR: missing FROM-clause entry for table” in ...
If you're getting “ERROR: missing FROM-clause entry for table” in PostgreSQL when using an operator such as UNION , INTERSECT , or EXCEPT ......
Read more >
sql - "missing FROM-clause entry for table" error for a rails ...
I can't see how this answers the question, other than a very hard-to-notice correction of the query (changing "INNER JOIN vcustomer" to "INNER ......
Read more >
Missing FROM-clause entry for table
Missing FROM-clause entry for table. Explanation. An alias is specified for a table but not used in the WHERE clause. Example: SELECT *....
Read more >
PostgreSQL - ERROR: missing FROM-clause entry for table
I have multiple prices per each locl_ntwrk_id , so what I am trying to do is to get only the last price per...
Read more >
Missing FROM-clause entry for table in postgres CTE
You are facing with SQL Error [42P01]: ERROR: missing FROM-clause entry for table "a_cte" error because you never select from a_cte .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found