fix: set nullable under jsonSchema in property to true in case of nullable property
Signed-off-by: Muhammad Aaqil <aaqilniz@yahoo.com>
This commit is contained in:
parent
025b22a9af
commit
f14ae8af4b
|
@ -1668,12 +1668,13 @@ DataSource.prototype.discoverSchemas = function(tableName, options, cb) {
|
||||||
type: item.type,
|
type: item.type,
|
||||||
required: !item.generated && (item.nullable === 'N' || item.nullable === 'NO' ||
|
required: !item.generated && (item.nullable === 'N' || item.nullable === 'NO' ||
|
||||||
item.nullable === 0 || item.nullable === false),
|
item.nullable === 0 || item.nullable === false),
|
||||||
|
jsonSchema: {nullable: item.nullable === 'Y' || item.nullable === 'YES' ||
|
||||||
|
item.nullable === 1 || item.nullable === true},
|
||||||
length: item.dataLength,
|
length: item.dataLength,
|
||||||
precision: item.dataPrecision,
|
precision: item.dataPrecision,
|
||||||
scale: item.dataScale,
|
scale: item.dataScale,
|
||||||
generated: item.generated,
|
generated: item.generated,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (pks[item.columnName]) {
|
if (pks[item.columnName]) {
|
||||||
schema.properties[propName].id = pks[item.columnName];
|
schema.properties[propName].id = pks[item.columnName];
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,19 @@ describe('Memory connector with mocked discovery', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should have jsonSchema: {nullable: true} in property for `available`', function(done) {
|
||||||
|
ds.discoverSchemas('INVENTORY', {}, function(err, schemas) {
|
||||||
|
if (err) return done(err);
|
||||||
|
schemas.should.have.property('STRONGLOOP.INVENTORY');
|
||||||
|
const s = schemas['STRONGLOOP.INVENTORY'];
|
||||||
|
s.name.should.be.eql('Inventory');
|
||||||
|
s.properties.available.should.have.property('jsonSchema');
|
||||||
|
s.properties.available.jsonSchema.should.have.property('nullable');
|
||||||
|
s.properties.available.jsonSchema.nullable.should.be.eql(true);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should keep the column names the same as database', function(done) {
|
it('should keep the column names the same as database', function(done) {
|
||||||
ds.discoverSchemas('INVENTORY', {disableCamelCase: true}, function(err, schemas) {
|
ds.discoverSchemas('INVENTORY', {disableCamelCase: true}, function(err, schemas) {
|
||||||
if (err) return done(err);
|
if (err) return done(err);
|
||||||
|
@ -211,6 +224,9 @@ describe('Memory connector with mocked discovery', function() {
|
||||||
properties: {
|
properties: {
|
||||||
available: {
|
available: {
|
||||||
length: null,
|
length: null,
|
||||||
|
jsonSchema: {
|
||||||
|
nullable: true,
|
||||||
|
},
|
||||||
memory: {
|
memory: {
|
||||||
columnName: 'AVAILABLE',
|
columnName: 'AVAILABLE',
|
||||||
dataLength: null,
|
dataLength: null,
|
||||||
|
@ -228,6 +244,9 @@ describe('Memory connector with mocked discovery', function() {
|
||||||
},
|
},
|
||||||
locationId: {
|
locationId: {
|
||||||
length: 20,
|
length: 20,
|
||||||
|
jsonSchema: {
|
||||||
|
nullable: false,
|
||||||
|
},
|
||||||
memory: {
|
memory: {
|
||||||
columnName: 'LOCATION_ID',
|
columnName: 'LOCATION_ID',
|
||||||
dataLength: 20,
|
dataLength: 20,
|
||||||
|
@ -245,6 +264,9 @@ describe('Memory connector with mocked discovery', function() {
|
||||||
},
|
},
|
||||||
productId: {
|
productId: {
|
||||||
length: 20,
|
length: 20,
|
||||||
|
jsonSchema: {
|
||||||
|
nullable: false,
|
||||||
|
},
|
||||||
memory: {
|
memory: {
|
||||||
columnName: 'PRODUCT_ID',
|
columnName: 'PRODUCT_ID',
|
||||||
dataLength: 20,
|
dataLength: 20,
|
||||||
|
@ -262,6 +284,9 @@ describe('Memory connector with mocked discovery', function() {
|
||||||
},
|
},
|
||||||
total: {
|
total: {
|
||||||
length: null,
|
length: null,
|
||||||
|
jsonSchema: {
|
||||||
|
nullable: true,
|
||||||
|
},
|
||||||
memory: {
|
memory: {
|
||||||
columnName: 'TOTAL',
|
columnName: 'TOTAL',
|
||||||
dataLength: null,
|
dataLength: null,
|
||||||
|
|
Loading…
Reference in New Issue