fix: add missing property in model generated
Signed-off-by: Muhammad Aaqil <aaqilniz@yahoo.com> Update lib/datasource.js Co-authored-by: Samarpan Bhattacharya <this.is.samy@gmail.com>
This commit is contained in:
parent
d29bec72a8
commit
6ffad9f7d6
|
@ -1666,11 +1666,12 @@ DataSource.prototype.discoverSchemas = function(tableName, options, cb) {
|
|||
const propName = nameMapper('column', item.columnName);
|
||||
schema.properties[propName] = {
|
||||
type: item.type,
|
||||
required: (item.nullable === 'N' || item.nullable === 'NO' ||
|
||||
required: !item.generated && (item.nullable === 'N' || item.nullable === 'NO' ||
|
||||
item.nullable === 0 || item.nullable === false),
|
||||
length: item.dataLength,
|
||||
precision: item.dataPrecision,
|
||||
scale: item.dataScale,
|
||||
generated: item.generated,
|
||||
};
|
||||
|
||||
if (pks[item.columnName]) {
|
||||
|
@ -1683,6 +1684,7 @@ DataSource.prototype.discoverSchemas = function(tableName, options, cb) {
|
|||
dataPrecision: item.dataPrecision,
|
||||
dataScale: item.dataScale,
|
||||
nullable: item.nullable,
|
||||
generated: item.generated,
|
||||
};
|
||||
// merge connector-specific properties
|
||||
if (item[dbType]) {
|
||||
|
@ -1830,10 +1832,11 @@ DataSource.prototype.discoverSchemasSync = function(modelName, options) {
|
|||
const propName = nameMapper('column', item.columnName);
|
||||
schema.properties[propName] = {
|
||||
type: item.type,
|
||||
required: (item.nullable === 'N'),
|
||||
required: !item.generated && item.nullable === 'N',
|
||||
length: item.dataLength,
|
||||
precision: item.dataPrecision,
|
||||
scale: item.dataScale,
|
||||
generated: item.generated,
|
||||
};
|
||||
|
||||
if (pks[item.columnName]) {
|
||||
|
@ -1846,6 +1849,7 @@ DataSource.prototype.discoverSchemasSync = function(modelName, options) {
|
|||
dataPrecision: item.dataPrecision,
|
||||
dataScale: item.dataScale,
|
||||
nullable: i.nullable,
|
||||
generated: i.generated,
|
||||
};
|
||||
});
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ describe('Memory connector with mocked discovery', function() {
|
|||
dataPrecision: null,
|
||||
dataScale: null,
|
||||
nullable: 0,
|
||||
generated: true,
|
||||
},
|
||||
{
|
||||
owner: 'STRONGLOOP',
|
||||
|
@ -44,6 +45,7 @@ describe('Memory connector with mocked discovery', function() {
|
|||
dataPrecision: null,
|
||||
dataScale: null,
|
||||
nullable: 0,
|
||||
generated: undefined,
|
||||
},
|
||||
{
|
||||
owner: 'STRONGLOOP',
|
||||
|
@ -54,6 +56,7 @@ describe('Memory connector with mocked discovery', function() {
|
|||
dataPrecision: 10,
|
||||
dataScale: 0,
|
||||
nullable: 1,
|
||||
generated: undefined,
|
||||
},
|
||||
{
|
||||
owner: 'STRONGLOOP',
|
||||
|
@ -64,6 +67,7 @@ describe('Memory connector with mocked discovery', function() {
|
|||
dataPrecision: 10,
|
||||
dataScale: 0,
|
||||
nullable: 1,
|
||||
generated: undefined,
|
||||
}];
|
||||
|
||||
ds.discoverModelProperties = function(modelName, options, cb) {
|
||||
|
@ -214,11 +218,13 @@ describe('Memory connector with mocked discovery', function() {
|
|||
dataScale: 0,
|
||||
dataType: 'int',
|
||||
nullable: 1,
|
||||
generated: undefined,
|
||||
},
|
||||
precision: 10,
|
||||
required: false,
|
||||
scale: 0,
|
||||
type: undefined,
|
||||
generated: undefined,
|
||||
},
|
||||
locationId: {
|
||||
length: 20,
|
||||
|
@ -229,11 +235,13 @@ describe('Memory connector with mocked discovery', function() {
|
|||
dataScale: null,
|
||||
dataType: 'varchar',
|
||||
nullable: 0,
|
||||
generated: undefined,
|
||||
},
|
||||
precision: null,
|
||||
required: true,
|
||||
scale: null,
|
||||
type: undefined,
|
||||
generated: undefined,
|
||||
},
|
||||
productId: {
|
||||
length: 20,
|
||||
|
@ -244,11 +252,13 @@ describe('Memory connector with mocked discovery', function() {
|
|||
dataScale: null,
|
||||
dataType: 'varchar',
|
||||
nullable: 0,
|
||||
generated: true,
|
||||
},
|
||||
precision: null,
|
||||
required: true,
|
||||
required: false,
|
||||
scale: null,
|
||||
type: undefined,
|
||||
generated: true,
|
||||
},
|
||||
total: {
|
||||
length: null,
|
||||
|
@ -259,11 +269,13 @@ describe('Memory connector with mocked discovery', function() {
|
|||
dataScale: 0,
|
||||
dataType: 'int',
|
||||
nullable: 1,
|
||||
generated: undefined,
|
||||
},
|
||||
precision: 10,
|
||||
required: false,
|
||||
scale: 0,
|
||||
type: undefined,
|
||||
generated: undefined,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -381,6 +393,7 @@ describe('discoverModelProperties', function() {
|
|||
dataPrecision: null,
|
||||
dataScale: null,
|
||||
nullable: 0,
|
||||
generated: undefined,
|
||||
},
|
||||
{
|
||||
owner: 'STRONGLOOP',
|
||||
|
@ -391,6 +404,7 @@ describe('discoverModelProperties', function() {
|
|||
dataPrecision: null,
|
||||
dataScale: null,
|
||||
nullable: 0,
|
||||
generated: undefined,
|
||||
},
|
||||
{
|
||||
owner: 'STRONGLOOP',
|
||||
|
|
Loading…
Reference in New Issue