loopbackio / loopbackio/loopback-datasource-juggler

Replace deprecated util._extend with Object.assign to ensure compatibility with modern Node.js

Open
#2,530 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
282
Forks
366
Avg merge
17h 4m
Merged PRs (30d)
10

Description

I used [patch-package](https://github.com/ds300/patch-package) to patch `loopback-datasource-juggler@3.36.1` for the project I'm working on.

Here is the diff that solved my problem:

```diff
diff --git a/node_modules/loopback-datasource-juggler/lib/dao.js b/node_modules/loopback-datasource-juggler/lib/dao.js
index bd9c818..d62991e 100644
--- a/node_modules/loopback-datasource-juggler/lib/dao.js
+++ b/node_modules/loopback-datasource-juggler/lib/dao.js
@@ -207,9 +207,9 @@ DataAccessObject.applyProperties = function(data, inst) {
let properties = this.definition.settings.properties;
properties = properties || this.definition.settings.attributes;
if (typeof properties === 'object') {
- util._extend(data, properties);
+ Object.assign(data, properties);
} else if (typeof properties === 'function') {
- util._extend(data, properties.call(this, data, inst) || {});
+ Object.assign(data, properties.call(this, data, inst) || {});
} else if (properties !== false) {
const scope = this.defaultScope(data, inst) || {};
if (typeof scope.where === 'object') {
diff --git a/node_modules/loopback-datasource-juggler/lib/model.js b/node_modules/loopback-datasource-juggler/lib/model.js
index 6ca3f33..e53ede5 100644
--- a/node_modules/loopback-datasource-juggler/lib/model.js
+++ b/node_modules/loopback-datasource-juggler/lib/model.js
@@ -24,7 +24,7 @@ const DataAccessUtils = require('./model-utils');
const Observer = require('./observer');
const Hookable = require('./hooks');
const validations = require('./validations');
-const _extend = util._extend;
+const _extend = Object.assign;
const utils = require('./utils');
const fieldsToArray = utils.fieldsToArray;
const uuid = require('uuid');
diff --git a/node_modules/loopback-datasource-juggler/lib/validations.js b/node_modules/loopback-datasource-juggler/lib/validations.js
index 82184e0..2f250ed 100644
--- a/node_modules/loopback-datasource-juggler/lib/validations.js
+++ b/node_modules/loopback-datasource-juggler/lib/validations.js
@@ -7,7 +7,7 @@

const g = require('strong-globalize')();
const util = require('util');
-const extend = util._extend;
+const extend = Object.assign;

/*!
* Module exports
```

This issue body was [partially generated by patch-package](https://github.com/ds300/patch-package/issues/296).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review lib/dao.js, lib/model.js, and lib/validations.js, starting with each util._extend or _extend reference shown in the issue. Replace the deprecated usage with Object.assign while preserving the surrounding calls, then verify that the project’s existing checks pass and no deprecated references remain in these files.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.