Skip to content

Conversation

@Idered
Copy link

@Idered Idered commented Jan 24, 2021

I need to get possible enum values for given column.

This PR extends inspector.columnInfo('table') with

  • udt_name - user defined type. For enums this will return enum name, for other types it will return type name eg. varchar
  • enum_values - if column is enum then this will be an array of possible values

Example result for inspector.columnInfo('user', 'role'):

{ 
    name: 'role',
    table: 'user',
    type: 'USER-DEFINED',
    udt_name: 'user_role_enum', // NEW
    enum_values: [ 0, 1 ], // NEW
    default_value: 0,
    max_length: null,
    precision: null,
    scale: null,
    is_nullable: true,
    is_primary_key: false,
    has_auto_increment: false,
    foreign_key_column: null,
    foreign_key_table: null,
    comment: null,
    schema: 'public',
    foreign_key_schema: null 
}

TODO:

  • PostgreSQL
  • MySQL
  • MSSQL
  • OracleDB
  • SQLite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant