@ -216,7 +216,13 @@ module.exports = {
if (remoteTableLayout[foreignKey.column].isPrimaryKey === true) {
let field = [ localField, async function (_, { $make, $getProperty }) {
return $make(`dlayer-knex.${foreignKey.table}`, { id: await $getProperty(this, name) })
let id = await $getProperty(this, name);
if (id != null) {
return $make(`dlayer-knex.${foreignKey.table}`, { id: id });
} else {
return null;
}
}];
selfRelationFields.push(field);