Skip to content

feat: allow empty array in createAll method #2410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ajay-prajapati07
Copy link

@ajay-prajapati07 ajay-prajapati07 commented Jun 5, 2025

Added code to allow empty array in createAll method. Currently it throws error.

Include references to all related GitHub issues and other pull requests, for example:

Fixes #2409
-->

Checklist

  • Sign off your commits with DCO (Developer Certificate of Origin)
  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • Commit messages are following our guidelines

@ajay-prajapati07 ajay-prajapati07 requested a review from dhmlau as a code owner June 5, 2025 06:31
@@ -512,11 +512,18 @@ DataAccessObject.createAll = function(dataArray, options, cb) {
options = options || {};
cb = cb || utils.createPromiseCallback();

assert(typeof dataArray === 'object' && dataArray.length,
'The data argument must be an array with length > 0');
assert(typeof dataArray === 'object' && Array.isArray(dataArray),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make it configurable in order to ensure backward compatibility ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added sir

@samarpanB
Copy link
Contributor

Also please sign off your commit. Follow DCO here - https://loopback.io/doc/en/contrib/code-contrib.html

@coveralls
Copy link

Pull Request Test Coverage Report for Build 15629436334

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 2 of 10 (20.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.06%) to 84.647%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/dao.js 2 10 20.0%
Totals Coverage Status
Change from base Build 15670951978: -0.06%
Covered Lines: 7279
Relevant Lines: 8293

💛 - Coveralls

@samarpanB
Copy link
Contributor

Can you please add a test case for this option ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allow empty array in createAll
3 participants