Skip to content

Custom Column/Property Names  #3372

@letynsoft

Description

@letynsoft

Description/Steps to reproduce

Hi,
Is there any way how to specify a custom column name using the @Property decorator with loopback4?

I have following property

  @property({
    type: 'number',
    name: 'shift_id',
  })
  shiftId?: number;

But the mssql connector (migrate script) doesn't seem to support this (is attemping to create duplicate columns, ...).

I have wrote a little quick-fix (rewriting modelDefinition when define() is called), but that's ugly

Expected result

To migrate the schema

Actual Result

Cannot migrate database schema { RequestError: Column names in each table must be unique. Column name 'shift_id' in table 'dbo.Ntls' is specified more than once

Additional information

$ node -e 'console.log(process.platform, process.arch, process.versions.node)'
linux x64 10.16.0

$ npm ls --prod --depth 0 | grep loopback
├── @loopback/boot@1.4.2
├── @loopback/context@1.20.0
├── @loopback/core@1.8.3
├── @loopback/openapi-v3@1.6.3
├── @loopback/repository@1.8.0
├── @loopback/rest@1.16.1
├── @loopback/rest-explorer@1.2.3
├── @loopback/service-proxy@1.2.3
├── loopback-connector-mssql@3.3.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions