Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add enum fields in columnInfo #29

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

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.

None yet

1 participant