I am able to connect and use Vercel’s Postgres storage addon, but encountered a bug that I can’t reproduce in normal Postgres. I have two tables with a one-to-many relationship. When I join the two tables, I expect a cartesian product – one row for each of the many relationships. However, I only get one row back!
Here’s my schema code:
DROP TABLE IF EXISTS LinksA CASCADE;
DROP TABLE IF EXISTS LinkContentsA CASCADE;
CREATE TABLE IF NOT EXISTS LinksA (id BIGSERIAL PRIMARY KEY, url TEXT);
CREATE TABLE IF NOT EXISTS LinkContentsA (
link_id BIGINT NOT NULL REFERENCES LinksA(id),
link_content TEXT NOT NULL
);
INSERT INTO LinksA (url) VALUES ('https://a.com');
INSERT INTO LinksA (url) VALUES ('https://b.com');
INSERT INTO LinkContentsA (link_id, link_content) VALUES (1, 'hello');
INSERT INTO LinkContentsA (link_id, link_content) VALUES (1, 'goodbye');
INSERT INTO LinkContentsA (link_id, link_content) VALUES (1, 'foo');
INSERT INTO LinkContentsA (link_id, link_content) VALUES (1, 'bar');
Here’s my query:
SELECT * FROM LinksA
JOIN LinkContentsA ON LinkContentsA.link_id = LinksA.id
DB Fiddle - SQL Database Playground clearly shows 4 rows (expected) but running the same thing in Vercel’s DB web UI only returns 1 row. As far as I can tell, this bug seems specific to Vercel, but it seems like such a glaring bug.