shuttle-hq / synth

The Declarative Data Generator
https://www.getsynth.com/
Apache License 2.0
1.36k stars 105 forks source link

Support generated Postgres columns #415

Open seantalbot-jisc opened 1 year ago

seantalbot-jisc commented 1 year ago

Required Functionality Synth seems to have trouble with a generated timestamp column.

Proposed Solution It should ignore the column.

Use case Relevant postgres schema:

CREATE TABLE
    a_table (
        id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
        created_date TIMESTAMP NOT NULL DEFAULT NOW(),
        updated_date TIMESTAMP NULL
        -- etc.
    );

ALTER TABLE
    a_table 
ADD COLUMN
    last_modified_date TIMESTAMP GENERATED ALWAYS AS (GREATEST(created_date, updated_date)) STORED;

When trying to generate data using synth:

 synth generate --seed 1234  --size 10 --to <uri> testing
...
Error: At namespace "testing"

Caused by:
    0: Failed to insert data for collection a_table
    1: One or more database inserts failed: error returned from database: cannot insert into column "last_modified_date": cannot insert into column "last_modified_date"

Synth version 0.6.9