shuttle-hq / synth

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

Postgres enum import not fetching values with Prisma #445

Open ghost opened 8 months ago

ghost commented 8 months ago

Describe the bug Hi team, love your work. It's very close to saving us a lot of time - we're just running into a small issue.

We generate enums in Postgres with Prisma. You can see the type in information_schema.columns below.

To Reproduce

  1. Schema (if applicable)
    table_schema             | public
    table_name               | AllergyIntolerance
    column_name              | clinicalStatus
    ordinal_position         | 3
    column_default           |
    is_nullable              | NO
    data_type                | USER-DEFINED
    character_maximum_length |
    character_octet_length   |
    numeric_precision        |
    numeric_precision_radix  |
    numeric_scale            |
    datetime_precision       |
    interval_type            |
    interval_precision       |
    character_set_catalog    |
    character_set_schema     |
    character_set_name       |
    collation_catalog        |
    collation_schema         |
    collation_name           |
    domain_catalog           |
    domain_schema            |
    domain_name              |
    udt_schema               | public
    udt_name                 | AllergyIntoleranceClinicalStatus
    scope_catalog            |
    scope_schema             |
    scope_name               |
    maximum_cardinality      |
    dtd_identifier           | 3
    is_self_referencing      | NO
    is_identity              | NO
    identity_generation      |
    identity_start           |
    identity_increment       |
    identity_maximum         |
    identity_minimum         |
    identity_cycle           | NO
    is_generated             | NEVER
    generation_expression    |
    is_updatable             | YES

The values exist in psql:

ubuntu=# \dT+ "AllergyIntoleranceClinicalStatus"
List of data types
-[ RECORD 1 ]-----+-----------------------------------
Schema            | public
Name              | "AllergyIntoleranceClinicalStatus"
Internal name     | AllergyIntoleranceClinicalStatus
Size              | 4
Elements          | active                            +
                  | inactive                          +
                  | resolved
Owner             | postgres
Access privileges |
Description       |
  1. For some reason it correctly identifies a categorical field but doesn't fetch the values.
    ...
    "clinicalStatus": {
      "type": "string",
      "categorical": {}
    },
    ...

Expected behavior We would expect the imported schema file to look like

...
    "clinicalStatus": {
      "type": "string",
      "categorical": {"active", "inactive", "resolved"}
    },
...

Environment (please complete the following information):