With a schema:
CREATE TABLE foo (
id SERIAL UNIQUE,
name VARCHAR(15) NOT NULL,
domain VARCHAR(255),
);
CREATE TABLE bar (
foo_id INT UNIQUE NOT NULL REFERENCES fleets(id),
passphrase VARCHAR
);
I need to use:
SELECT * FROM foo LEFT JOIN bar ON bar.foo_id = foo.id;
Can Postgres use the foreign key (between two tables) as a default “ON” clause when LEFT JOINing them?
i.e. I’ve already put in all the effort to logically link a couple of dozen tables with foreign keys, why do I need to repeat these in every query?
(Inferring the ON
clauses from the foreign keys appears much safer than making the querier state them.)