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.

Table name "..." specified more than once with nested include all.

See original GitHub issue

I’m using version 3.9.0 to interact with a PostgreSQL database.

It seems that with rather deep circular relationships include: [{all: true, nested: true}] fails with an error: table name "Some.Massive.Table.Chain.That.Actually.Cuts.Off.Somewh" specified more than once.

Because it cuts it off I’m actually not sure where it failed, but I have a (not really) good idea.

I have a model User, which has one UserAccount, which (and I’m paraphrasing this structure to not divulge too much company info) has many Item models, which has one Purchase model, which belongs to one UserTransaction model, which belongs to one PaymentMethod model, which belongs to the User model.

The Item and UserAccount BOTH have one Address model, which also belongs to an Event model, which belongs to an EventType model, which also belongs to the UserTransaction model.

It’s pretty convoluted, so I’m not sure where it fails. It cuts off on the UserTransaction model in the error message.

It may be that crazy circular dependencies like this cannot be done, but there should at least be a warning in the documentation for that.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
mickhansencommented, Sep 30, 2015

For hasMany associations you can check out include.separate: true. But yeah that’s a mighty massive include. Long names being cut off is a known issue i’m afraid, we have not implemented a solution yet (not quite content with having to uglify table names).

0reactions
franciscopessoacommented, Jan 20, 2022

Thanks @mickhansen, I was having problems bringing in data that related to a bridge table, and the separete solved my problem by creating this query in a subquery.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sequelize belongTo association giving error "table name ...
When I .findAll like below, the error returns: Unhandled rejection SequelizeDatabaseError: table name "contact" specified more than once. Are ...
Read more >
Tables and Views — PostgREST 9.0.0 documentation
You can sort by nested fields of JSON Columns with the JSON operators. Limits and Pagination . PostgREST uses HTTP range headers...
Read more >
Correlation Names - SQL Reference
A correlation name is associated with a table, view, alias, nested table ... each one contains no more than one reference to EMPLOYEE...
Read more >
Subqueries (SQL Server) - Microsoft Learn
A subquery can itself include one or more subqueries. Any number of subqueries can be nested in a statement. The following query finds...
Read more >
Documentation: 8.4: Table Expressions - PostgreSQL
If more than one table reference is listed in the FROM clause they are ... after the table name to explicitly specify that...
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