Skip to content

.createEach([x, y, x]) #7266

@mikermcneil

Description

@mikermcneil

Node version: Any
Sails version (sails): Any
Waterline adapter (any): Any compatible adapter and version.
ORM hook version (sails-hook-orm): 4.0.2


There's a problem with createEach() and multiple references.

To reproduce:

📺 Watch me do it (90 sec)

👁️ Or read this:

let a = {x:32,y:480};
let b = {x:-99, y:44};
let c = a;

console.log(c);
// { x: 32, y: 480 }

console.log(a === c);
// true

console.log(a !== { x:32, y: 480 });
// true

await Platform.createEach([a,b,c]);
- - - - - - - - - - - - - - - - - - - - - - - -
An error occurred:

Error [UsageError]: Invalid initial data for new records.
Details:
  Could not use one of the provided new records: Could not use specified `id`.  Invalid primary key value.  Instead of a number (the expected pk type), got: null
 [?] See https://sailsjs.com/support for help.
    at REPL7:1:10
    at Script.runInThisContext (vm.js:132:18)
    at REPLServer.defaultEval (repl.js:484:29)
    at bound (domain.js:430:14)
    at REPLServer.runBound [as eval] (domain.js:443:12)
    at REPLServer.onLine (repl.js:817:10)
    at REPLServer.emit (events.js:327:22)
    at REPLServer.EventEmitter.emit (domain.js:486:12)
    at REPLServer.Interface._onLine (readline.js:337:10)
    at REPLServer.Interface._line (readline.js:666:8)
    at REPLServer.Interface._ttyWrite (readline.js:1010:14)
    at REPLServer.self._ttyWrite (repl.js:907:9)
    at ReadStream.onkeypress (readline.js:213:10)
    at ReadStream.emit (events.js:315:20)
    at ReadStream.EventEmitter.emit (domain.js:486:12)
    at emitKeys (internal/readline/utils.js:345:14)
    at emitKeys.next (<anonymous>)
    at ReadStream.onData (readline.js:1144:36)
    at ReadStream.emit (events.js:315:20)
    at ReadStream.EventEmitter.emit (domain.js:486:12)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:284:9) {
  code: 'E_INVALID_NEW_RECORDS',
  details: 'Could not use one of the provided new records: Could not use specified `id`.  Invalid primary key value.  Instead of a number (the expected pk type), got: null'
}
- - - - - - - - - - - - - - - - - - - - - - - -

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions