typeorm: missing FROM-clause entry for table "???????"
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
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 4
- Comments: 15 (2 by maintainers)
Same issue:
As you can see, I have defined a
@JoinColumnbut it’s not getting respected. And the generated query’s inner join doesn’t have double quotes in it.Here is my entity definition:
Hello Everyone.
@pleerock @Kononnable I think this could be possibly reopened.
I started facing the same issue today with TypeORM 0.2.24 using PostgreSQL driver when trying to fetch entities with
@ManyToManyrelation.I don’t know why, but the generated query is missing the double quotes which seems to be the reason of missing FROM-clause entry for table errors.
Here is a simplified extract from my entities:
See I have both sides of ManyToMany relation defined with a custom-named
@JoinTable.Now, when I try to fetch
Optionswith relatedOptionValues, e.g.I get this query generated and this FAILS:
Please note the bold parts - they are missing double quotes. I compared that to a different but similar relation in other part of my apps, and there the query includes double quotes! This is what I found in different sources can cause such
missing FROM-clause entry for tableerrors.@ishan123456789 provided me a hint to check if the
simple-jsonmay be causing this issue. So I removed the relation:and voliá! It magically works. There has to be something wrong with the query and/or pivot table being generated automatically by TypeORM for
@ManyToManyrelation when we have an entity containingsimple-jsoncolumn.Any help kindly appreciated!
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"You can follow my solution if another do not work. Just change your table name from Snake case to Camel case https://github.com/typeorm/typeorm/issues/3521#issuecomment-767252311
Same problem here, it was resolved by using alias as the name of the table that i want to join with…!
+1