Skip to content

Mysql string id is null #4512

@KyDenZ

Description

@KyDenZ

Steps to reproduce

I have a MySQL database that contains data with a string format ID. A class is mapped to the data in my database. All data is returned except the id, is null.

Initialize a loopback project, add a class with an id of type string, a mysql datasource.

@property({
    type: 'string',
    id: true,
    required: true,
  })
  id?: string;

Current Behavior

The problem is that the id is in string in my database. It is not the "varchar" type that is problematic, but that the value is a string. The data comes from keyclaok, I cannot change the id in number.

Besides, when I migrate with "npm run migrate" loopback creates the id in int type.

Expected Behavior

We must be able to have ids in string from mysql.

Additional information

darwin x64 12.14.1
@loopback/boot@1.7.1
@loopback/context@1.25.1
@loopback/core@1.12.1
@loopback/openapi-v3@1.11.0
@loopback/repository@1.17.0
@loopback/rest@1.25.1
@loopback/rest-explorer@1.4.7
@loopback/service-proxy@1.3.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions