Merge pull request #77 from strongloop/fix/skip-unknown-property-types
model-helper: ignore unknown property types
This commit is contained in:
commit
738928e622
|
@ -21,8 +21,15 @@ var modelHelper = module.exports = {
|
|||
*/
|
||||
generateModelDefinition: function generateModelDefinition(modelClass, definitions) {
|
||||
var def = modelClass.definition;
|
||||
var name = def.name;
|
||||
var out = definitions || {};
|
||||
|
||||
if (!def) {
|
||||
// The model does not have any definition, it was most likely
|
||||
// created as a placeholder for an unknown property type
|
||||
return out;
|
||||
}
|
||||
|
||||
var name = def.name;
|
||||
if (out[name]) {
|
||||
// The model is already included
|
||||
return out;
|
||||
|
|
|
@ -198,6 +198,18 @@ describe('model-helper', function() {
|
|||
expect(Object.keys(defs)).has.property('length', 1);
|
||||
});
|
||||
|
||||
// https://github.com/strongloop/loopback-explorer/issues/71
|
||||
it('should skip unknown types', function() {
|
||||
var Model8 = loopback.createModel('Model8', {
|
||||
patient: {
|
||||
model: 'physician',
|
||||
type: 'hasMany',
|
||||
through: 'appointment'
|
||||
}
|
||||
});
|
||||
var defs = modelHelper.generateModelDefinition(Model8, {});
|
||||
expect(Object.keys(defs)).to.not.contain('hasMany');
|
||||
});
|
||||
});
|
||||
|
||||
describe('hidden properties', function() {
|
||||
|
|
Loading…
Reference in New Issue