Open jonathantjm opened 2 months ago
Hey @jonathantjm, thanks for the report.
This is showing a similar TOAST related error to #63, we need to investigate if there are issues with Postgres TOAST. The fact that making the totable row size slightly smaller tops the problems very much suggests there it is TOAST related (along with the error message).
I am getting a very similar error when trying to convert my project from using sqlite to pglite:
error when generating label: error: expected one dependency record for TOAST table, found 4
This happens when running this code:
await db.unsafeExec({
sql: `ALTER TABLE action_reports ADD COLUMN label text GENERATED ALWAYS AS (coalesce(year::text, action_report_id::text)) stored;`,
})
on this table:
CREATE TABLE action_reports(
action_report_id uuid PRIMARY KEY DEFAULT NULL,
account_id uuid DEFAULT NULL REFERENCES accounts(account_id) ON DELETE CASCADE ON UPDATE CASCADE,
action_id uuid DEFAULT NULL REFERENCES actions(action_id) ON DELETE CASCADE ON UPDATE CASCADE,
year integer DEFAULT NULL,
data jsonb DEFAULT NULL,
label_replace_by_generated_column text DEFAULT NULL
);
CREATE INDEX ON action_reports USING btree(account_id);
CREATE INDEX ON action_reports USING btree(action_id);
CREATE INDEX ON action_reports USING btree(year);
This is currently preventing me from using pglite.
It seems that it doesn't matter what label is generated. The error also occurs on another table:
CREATE TABLE users(
user_id uuid PRIMARY KEY DEFAULT NULL,
email text DEFAULT NULL,
label_replace_by_generated_column text DEFAULT NULL
);
CREATE INDEX ON users USING btree(email);
when running:
await db.unsafeExec({
sql: `
ALTER TABLE users ADD COLUMN label text GENERATED ALWAYS AS (coalesce(email::text, user_id::text)) stored;`,
})
Attempting to change column type throws error
expected one dependency record for TOAST table, found 4
Reproduction:
The following actions individually will cause the code to execute successfully:
38
38
to 10ALTER COLUMN
statementcreated_at
column as typeTIMESTAMPTZ(3)
in theCREATE TABLE
statementEdit: formatting