diff --git a/docs/site/Importing-LB3-models.md b/docs/site/Importing-LB3-models.md index 2ff8c2f48488..9284db890f1e 100644 --- a/docs/site/Importing-LB3-models.md +++ b/docs/site/Importing-LB3-models.md @@ -43,13 +43,6 @@ your project. It will help us to better prioritize which limitations to remove first. " %} -### Connector-specific metadata in property definitions is not imported - -_The tracking GitHub issue: -[loopback-next#3810](https://github.com/strongloop/loopback-next/issues/3810)_ - -Workaround: Add this metadata manually to the generated file. - ### Nested properties are not upgraded _The tracking GitHub issue: diff --git a/packages/cli/test/unit/import-lb3-model/migrate-model.test.js b/packages/cli/test/unit/import-lb3-model/migrate-model.test.js index 16710f007318..12400d5f37f1 100644 --- a/packages/cli/test/unit/import-lb3-model/migrate-model.test.js +++ b/packages/cli/test/unit/import-lb3-model/migrate-model.test.js @@ -77,6 +77,74 @@ describe('importLb3ModelDefinition', () => { }); }); + context('model properties with db settings', () => { + let modelData; + + const STRING_PROPERTY = { + type: 'String', + required: false, + length: 25, + precision: null, + scale: null, + postgresql: { + columnName: 'name', + dataType: 'character varying', + dataLength: 25, + dataPrecision: null, + dataScale: null, + nullable: 'YES', + }, + }; + + const NUMERIC_PROPERTY = { + type: 'Number', + required: false, + length: null, + precision: 64, + scale: 0, + postgresql: { + columnName: 'count', + dataType: 'bigint', + dataLength: null, + dataPrecision: 64, + dataScale: 0, + nullable: 'YES', + }, + }; + + before(function modelWithCustomDbSettings() { + const properties = { + name: STRING_PROPERTY, + count: NUMERIC_PROPERTY, + }; + const MyModel = givenLb3Model('MyModel', properties, {}); + modelData = importLb3ModelDefinition(MyModel, log); + }); + + it('connector metadata is migrated for string property', () => { + expect(modelData.properties) + .to.have.property('name') + .deepEqual({ + type: `'string'`, + tsType: 'string', + length: 25, + postgresql: `{columnName: 'name', dataType: 'character varying', dataLength: 25, dataPrecision: null, dataScale: null, nullable: 'YES'}`, + }); + }); + + it('connector metadata is migrated for numeric property', () => { + expect(modelData.properties) + .to.have.property('count') + .deepEqual({ + type: `'number'`, + tsType: 'number', + precision: 64, + scale: 0, + postgresql: `{columnName: 'count', dataType: 'bigint', dataLength: null, dataPrecision: 64, dataScale: 0, nullable: 'YES'}`, + }); + }); + }); + context('array properties', () => { it('correctly converts short-hand definition', () => { const MyModel = givenLb3Model('MyModel', {