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.

Not able to search in relations of relations (Nested Relations throw missing FROM-clause entry)

See original GitHub issue

I wanted to implement a search using a property from a relation of a relation from my Entity.

json searchableColumns: [ "title", "games.genres.name" ],

But i get this:

error:   ┏ missing FROM-clause entry for table "genres"
error:   ┃ [ 1] QueryFailedError: missing FROM-clause entry for table "genres"
error:   ┃ [ 2]     at PostgresQueryRunner.query (/app/node_modules/.pnpm/typeorm@0.3.10_pg@8.8.0+ts-node@10.9.1/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19)
error:   ┃ [ 3]     at runMicrotasks (<anonymous>)
error:   ┃ [ 4]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
error:   ┃ [ 5]     at async SelectQueryBuilder.loadRawResults (/app/node_modules/.pnpm/typeorm@0.3.10_pg@8.8.0+ts-node@10.9.1/node_modules/typeorm/query-builder/SelectQueryBuilder.js:2056:25)
error:   ┃ [ 6]     at async SelectQueryBuilder.getRawMany (/app/node_modules/.pnpm/typeorm@0.3.10_pg@8.8.0+ts-node@10.9.1/node_modules/typeorm/query-builder/SelectQueryBuilder.js:607:29)
error:   ┃ [ 7]     at async SelectQueryBuilder.executeEntitiesAndRawResults (/app/node_modules/.pnpm/typeorm@0.3.10_pg@8.8.0+ts-node@10.9.1/node_modules/typeorm/query-builder/SelectQueryBuilder.js:1860:26)
error:   ┃ [ 8]     at async SelectQueryBuilder.getManyAndCount (/app/node_modules/.pnpm/typeorm@0.3.10_pg@8.8.0+ts-node@10.9.1/node_modules/typeorm/query-builder/SelectQueryBuilder.js:771:36)
error:   ┃ [ 9]     at async paginate (/app/node_modules/.pnpm/nestjs-paginate@4.5.1_5lrjep46ocnlg5z2ezquymw4bm/node_modules/nestjs-paginate/lib/paginate.js:283:27)
error:   ┃ [10]     at async TagsController.get (/app/dist/controllers/tags.controller.js:32:34)
error:   ┃ [11]     at async /app/node_modules/.pnpm/@nestjs+core@9.2.0_jfowmhmgk7kwjudosrpv7e7liy/node_modules/@nestjs/core/router/router-execution-context.js:46:28
error:   ┗ [12] { context: 'ExceptionsHandler' }

Aren’t nested relations supported in the search?

Issue Analytics

  • State:open
  • Created 9 months ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dhruv1409commented, Dec 8, 2022

+1

I also have the same question

0reactions
dhruv1409commented, Dec 8, 2022

`@ManyToOne(() => GeographyClassificationEntity, geography => geography.id, { eager: true, }) @joincolumn({ name: ‘geographyClassification’, referencedColumnName: ‘id’ }) @column({ name: ‘geographyClassification’, nullable: true }) public geographyClassification: number;

@OneToMany( () => ComponentTemplateAllowedComponentTypeMappingEntity, mappingTable => mappingTable.componentTemplate, { eager: true }, ) public allowedComponentTypes: ComponentTemplateAllowedComponentTypeMappingEntity[]; ` I have these 2 relations set in my entity . So if I try like this -

const result = await paginate(query, this.lcaProcessRepo, { sortableColumns: ['id', 'isGeneralOwnership'], searchableColumns: [, 'description'], defaultSortBy: [['id', 'DESC']], defaultLimit: 10, maxLimit: 50, filterableColumns: { geographyClassification: [FilterOperator.IN], processTechnology: [FilterOperator.IN], }, relations: ['geographyClassification', 'allowedComponentTypes'], });

It only accepts allowedComponentTypes (which is ManyToOne).

If anyone can fix this issue - or let me know if I am missing anything here …

@ppetzold Can you please let me know if relations can accept ManyToOne ? because I want to populate this relation in my response search inside it as well

Read more comments on GitHub >

github_iconTop Results From Across the Web

Postgres: missing FROM-clause entry for table - Stack Overflow
In your first join 'payments_action' is not a known relation. Reorder your joins in a way that a new join only uses already...
Read more >
missing FROM-clause entry for table "???????" #3000 - GitHub
I ma facing same issue, when trying to save entity with many2many relationship. This is the query its generating: SELECT ...
Read more >
Fix “ERROR: missing FROM-clause entry for table” in ...
Another way to fix it is to use an alias for the column: (SELECT TeacherName t FROM Teachers) UNION (SELECT StudentName FROM Students)...
Read more >
Datomic Queries and Rules
Queries and rules output relations with tuples of varying arity, and Datomic's query engine can accept as inputs relation-like data in arbitrary collections....
Read more >
Database Engine events and errors - SQL Server
Consult this MSSQL error code list to find explanations for error messages for SQL Server database engine events.
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