L
L
Ler Den2018-05-05 15:18:19
PostgreSQL
Ler Den, 2018-05-05 15:18:19

Links between databases not implemented by postgresql?

There is a table artist and user_artist

artist:
- id (PK)
- name
user_artist:
- id (PK)
- userId(FK)
- artistId(FK)
- added

The following query returns an error
ссылки между базами не реализованы: user_artist.added

return db.query(`
                SELECT artist.name  AS "artistName", artist.id AS "artistId", user_artist.added
                FROM user_artist
                INNER JOIN artist
                ON artist.id = user_artist."artistId"
                WHERE user_artist."userId" = $(userId) 
                AND user_artist.added::timestamp < to_timestamp($(index) / 1000)
                ORDER BY user_artist.added $(order)
                LIMIT $(limit);`, obj);

If removed ORDER BY user_artist.added $(order), the error disappears.
Here is the exact structure of the user_artist table
create table user_artist
(
  "id" serial primary key,
  "userId" serial REFERENCES user (id) on delete cascade,
  "artistId" serial REFERENCES artist (id) on delete cascade,
  "added" timestamp,
  unique ("userId", "artistId")
);

What's wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2018-05-05
@melkij

Links between different bases are really not implemented.
Therefore, the parser considers that you are accessing different databases in one request. Show the query that you send to the database, and not how the query is built.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question