spinlud / sequelize-typescript-generator

71 stars 27 forks source link

Data types for Array of integers, strings and objects are omitted during the model creation #31

Open kumarordway opened 2 years ago

kumarordway commented 2 years ago

Data types for Array of integers, strings and objects are omitted during the model creation

If the column has the array of integers as the data type it is omitted in the column type.

expected behavior: The type should be defined for array of integers, or any types of arrays.

spinlud commented 2 years ago

Hi there! What do you mean by "Array of integers, strings and objects are omitted during the model creation"?

Could you provide an example?

cheers🍺

kumarordway commented 2 years ago

In postgress, type of column can be an array of strings or array integers etc. via json objects. For these columns the datatype is missed example here

 @Column({
    field: 'source_id',
    allowNull: true,
    defaultValue: Sequelize.literal("'{}'::integer[]"),
  })
    sourceId?: any;

See that this is missing type in column definition. this needs to be fixed with

@Column({
    field: 'xxx',
    allowNull: true,
    defaultValue: Sequelize.literal("'{}'::integer[]"),
    type: DataType.ARRAY(DataType.INTEGER),
  })
  sourceId?: any;

column definition in postgres information_schema for this column looks like this

 columns_default = "'{}'::integer[]"
 is_nullable = "YES"
 data_type="ARRAY"