ArsenyYankovsky / typeorm-aurora-data-api-driver

A bridge between TypeORM and Aurora Data API
MIT License
175 stars 38 forks source link

Error: 'Undefined' string value interpreted as undefined value for entity text field #128

Open ahubertaircall opened 2 years ago

ahubertaircall commented 2 years ago

Package versions and database engine type (please complete the following information):

Describe the bug

Hello, When trying to insert the bellow entity using TypeOrmAuroraDataApiDriver and a text string value 'undefined':

@Entity(SchemaName.MESSAGE)
export class MessageRecord {
  @PrimaryColumn({
    length: 191,
  })
  id: string;

  @Column({
    length: 191,
  })
  conversationId: string;

  @Column({ type: 'text', charset: 'utf8mb4' })
  text: string;

with the following code:

connection.getRepository(MessageRecord);
    const messageRecord: MessageRecord = {
      id,
      conversationId: 'conversationId',
      text,
      ...
    };

the execution fails. Indeed the aurora data api is returning the following error "BadRequestException: Cannot find parameter: param_2". So it seems the driver is interpreting the string 'undefined' as a real undefined values and does not provide it to the server making the request fail. Note:

To Reproduce With the following entity and the given client code:

@Entity(SchemaName.MESSAGE)
export class MessageRecord {
  @PrimaryColumn({
    length: 191,
  })
  id: string;

  @Column({
    length: 191,
  })
  conversationId: string;

  @Column({ type: 'text', charset: 'utf8mb4' })
  text: string;
connection.getRepository(MessageRecord);
    const messageRecord: MessageRecord = {
      id,
      conversationId: 'conversationId',
      text,
      ...
    };