Skip to content
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

merge does not work in node cli #271

Closed
bhoriuchi opened this issue Aug 9, 2016 · 5 comments
Closed

merge does not work in node cli #271

bhoriuchi opened this issue Aug 9, 2016 · 5 comments

Comments

@bhoriuchi
Copy link

bhoriuchi commented Aug 9, 2016

Not a huge issue and it may just be my setup but I ran into an issue when using the merge method in in node cli (node v6.3.0). The equivalent code has no issues when run inside a .js file

here is an example to reproduce

var r = require('rethinkdbdash')()

// table data
var list = [
  {
    id: '358ba8e6-838a-4f92-825d-7c25f85e42ab',
    name: 'list1',
    type: '4effeadb-19a6-4b76-9596-10d034ed47e0'
  }
]

var list_type = [
  {
    id: '4effeadb-19a6-4b76-9596-10d034ed47e0',
    name: 'shopping'
  }
]
// assume these are already loaded into rethinkdb as tables list and list_type

r.table('list').merge(function (lists) {
  return {
    type: r.table('list_type').get(lists('type'))
  }
}).run().then(function (results) {
  console.log(results)
})

works fine in a .js file but from cli throws

TypeError: Cannot read property 'unshift' of undefined
    at Term._fillArgs (/***/node_modules/rethinkdbdash/lib/term.js:2918:17)
    at Term.merge (/***/node_modules/rethinkdbdash/lib/term.js:1363:8)
    at repl:1:25
    at sigintHandlersWrap (vm.js:32:31)
    at sigintHandlersWrap (vm.js:96:12)
    at ContextifyScript.Script.runInContext (vm.js:31:12)
    at REPLServer.defaultEval (repl.js:308:29)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.<anonymous> (repl.js:489:10)
    at emitOne (events.js:101:20)
    at REPLServer.emit (events.js:188:7)
    at REPLServer.Interface._onLine (readline.js:232:10)
    at REPLServer.Interface._line (readline.js:574:8)
    at REPLServer.Interface._ttyWrite (readline.js:851:14)
    at ReadStream.onkeypress (readline.js:119:10)

and when printing the args _error has

    _error: 
     { ReqlDriverError: Cannot convert `function (lists) { return {type: r.table('list_type').get(lists('type'))} }` to datum..
         at Term.expr (/***/node_modules/rethinkdbdash/lib/term.js:2400:21)
         at Term.merge (/***/node_modules/rethinkdbdash/lib/term.js:1361:33)
         at repl:1:61
         at sigintHandlersWrap (vm.js:32:31)
         at sigintHandlersWrap (vm.js:96:12)
         at ContextifyScript.Script.runInContext (vm.js:31:12)
         at REPLServer.defaultEval (repl.js:308:29)
         at bound (domain.js:280:14)
         at REPLServer.runBound [as eval] (domain.js:293:12)
         at REPLServer.<anonymous> (repl.js:489:10)
         at emitOne (events.js:101:20)
         at REPLServer.emit (events.js:188:7)
         at REPLServer.Interface._onLine (readline.js:232:10)
         at REPLServer.Interface._line (readline.js:574:8)
         at REPLServer.Interface._ttyWrite (readline.js:851:14)
         at ReadStream.onkeypress (readline.js:119:10)
       msg: 'Cannot convert `function (lists) { return {type: r.table(\'list_type\').get(lists(\'type\'))} }` to datum.',
       message: 'Cannot convert `function (lists) { return {type: r.table(\'list_type\').get(lists(\'type\'))} }` to datum..' }
@neumino
Copy link
Owner

neumino commented Aug 13, 2016

Looked a bit into it and opened nodejs/node#8089 to get some clarification on the expected behavior. If this is working as intended, I could convert the x instanceof Function to typeof x === 'function'.

@neumino
Copy link
Owner

neumino commented Aug 13, 2016

There's actually also an issue with the unshift error. This is because the code is going in a path that should never be reached... I'll wait a bit for some answer, and will push this fix regardless of whether the issue is working as intended or not.

@neumino
Copy link
Owner

neumino commented Aug 13, 2016

Looks like it's a bug in node CLI -- nodejs/node#7788

@neumino
Copy link
Owner

neumino commented Aug 13, 2016

Ok, I just pushed a fix in 2.3.20 for the unshift error message. The root issue is in node, not in rethinkdbdash, so I'm closing this issue.

@neumino neumino closed this as completed Aug 13, 2016
@bhoriuchi
Copy link
Author

great, thanks for the quick and thorough response

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

No branches or pull requests

2 participants