Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
*
* �2018-2019 EdgeVerve Systems Limited (a fully owned Infosys subsidiary),
* Bangalore, India. All Rights Reserved.
*
*/
// Author : Atul
const utils = require('loopback-datasource-juggler/lib/utils');
var idEquals = utils.idEquals;
const HasOne = require('loopback-datasource-juggler/lib/relation-definition').HasOne;
const ModelBaseClass = require('loopback-datasource-juggler/lib/model.js');
const g = require('strong-globalize')();
/* eslint-disable no-undefined */
// Atul : Functions from relation-definition.js are overloaded. These functions are overriden so that
// this.fetch() call, options can be passed. HasOne.prototype.update and destroy() overriden
// default loopback-datasource-juggler doesn't pass options and hence it would crash
function preventFkOverride(inst, data, fkProp) {
if (!fkProp) return undefined;
if (data[fkProp] !== undefined && !idEquals(data[fkProp], inst[fkProp])) {
var err = new Error(g.f(
'Cannot override foreign key %s from %s to %s',
fkProp,
inst[fkProp],