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.

Sudently relation between tables "does not exist"

See original GitHub issue

Bug report

Describe the bug

I Have the following query:

  id,
  user (
    first_name,
    last_name
  ),
  created_at,
  appointments:appointments.specialist (count),
  account (
    balance
  )

It was working since the 17 of september of 2021 until this morning, no changes were made to this code since that date. And the request is responding “column specialists.appointments does not exist”.

Here’s the CURL generated by the frontend:

curl '.../specialists?select=id%2Cuser%28first_name%2Clast_name%29%2Ccreated_at%2Cappointments%3Aappointments.specialist%28count%29%2Caccount%28balance%29&deleted=eq.false&offset=0&limit=5'

Using the supabase-js library:

  supabase
    .from('specialists')
    .select(
       `
          id,
          user (
            first_name,
            last_name
          ),
          created_at,
          appointments:appointments.specialist (count),
          account (
            balance
          )
       `).eq('deleted', false)

If this “appointments:appointments.specialist(count)” is eliminated the query works

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Create a table called “specialists” or whatever you want
  2. Create a second table called “appointments” or whatever you want and add a releation between this table and the first one. It can be “specialist -> specialists.id”
  3. Fetch the table “specialist” and join with "appointments.

Expected behavior

A success request as it was before

Screenshots

The curl request from insomnia: imagen

The relation in “appointments”: imagen

System information

  • macOS and Windows
  • chrome, firefox
  • Version of supabase-js: ^1.22.4
  • Version of Node.js: v14.17.5

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
tavoohohcommented, Dec 2, 2021

@steve-chavez it did work!! So the issue was related with the new version of postgrest.

Thank you

1reaction
steve-chavezcommented, Dec 2, 2021

@tavoohoh Can you change appointments.specialist to appointments!specialist? As in:

  supabase
    .from('specialists')
    .select(
       `
          id,
          user (
            first_name,
            last_name
          ),
          created_at,
          appointments:appointments!specialist(count),
          account (
            balance
          )
       `).eq('deleted', false)

Btw, if you only do appointments(count) now, this should show a more friendlier error message suggesting the above syntax.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot simply use PostgreSQL table name ("relation does not ...
From what I've read, this error means that you're not referencing the table name correctly. One common reason is that the table is...
Read more >
SQL Error: relation "schema.table" does not exist"
This error message can appear when a table no longer exists but still shows in the list of tables for this schema.
Read more >
Flow suddenly cannot access Excel table
Hi I have a flow set up which takes Form responses and puts them in an Excel table. This has been running for...
Read more >
Postgres : Relation does not exist error
But when I try to fire a select * query, it gave me this error: dump=> select * from Approvals; ERROR: relation "approvals"...
Read more >
Solved: Can´t create a relationship between two columns be...
one of that column must have unique product numbers. you can't have Many to Many relation but only One to Many or Many...
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