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

Cannot insert nested document that contains r.now() or a Date object #13

Closed
jmdobry opened this issue Apr 12, 2014 · 8 comments
Closed

Comments

@jmdobry
Copy link

jmdobry commented Apr 12, 2014

The following throws an error:

var r = require('rethinkdbdash')({
    db: 'test',
    min: 0,
    max: 1,
    bufferSize: 0
});

r.table('test').insert({
    field: 'test',
    field2: { nested: 'test' },
    date: r.now()
}).run().finally(function () {
        r.getPool().drain();
    });

Error:

> node test.js

/Users/jason/test/node_modules/rethinkdbdash/lib/term.js:817
    if (expression === undefined) throw new Error.ReqlDriverError("Cannot conv
                                        ^
ReqlDriverError: Cannot convert `undefined` with r.expr().
    at Term.expr (/Users/jason/test/node_modules/rethinkdbdash/lib/term.js:817:41)
    at new Json (/Users/jason/test/node_modules/rethinkdbdash/lib/term.js:2462:30)
    at Term.json (/Users/jason/test/node_modules/rethinkdbdash/lib/term.js:877:12)
    at Term._exprJSON (/Users/jason/test/node_modules/rethinkdbdash/lib/term.js:958:68)
    at Term.exprJSON (/Users/jason/test/node_modules/rethinkdbdash/lib/term.js:883:23)
    at new Insert (/Users/jason/test/node_modules/rethinkdbdash/lib/term.js:2476:32)
    at Term.insert (/Users/jason/test/node_modules/rethinkdbdash/lib/term.js:218:12)
    at Object.<anonymous> (/Users/jason/test/test.js:8:17)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)

While both of the following work fine:

var r = require('rethinkdbdash')({
    db: 'test',
    min: 0,
    max: 1,
    bufferSize: 0
});

r.table('test').insert({
    date: r.now()
}).run().finally(function () {
        r.getPool().drain();
    });
var r = require('rethinkdbdash')({
    db: 'test',
    min: 0,
    max: 1,
    bufferSize: 0
});

r.table('test').insert({
    field: 'test',
    field2: { nested: 'test' }
}).run().finally(function () {
        r.getPool().drain();
    });
@jmdobry
Copy link
Author

jmdobry commented Apr 12, 2014

Even this fails with the same error:

var r = require('rethinkdbdash')({
    db: 'test',
    min: 0,
    max: 1,
    bufferSize: 0
});

r.table('test').insert({
    field: 'test',
    field2: { nested: 'test' },
    date: new Date()
}).run().finally(function () {
        r.getPool().drain();
    });

Must be dates in general

@jmdobry jmdobry changed the title Cannot insert nested document that contains r.now() Cannot insert nested document that contains r.now() or a Date object Apr 12, 2014
@neumino
Copy link
Owner

neumino commented Apr 12, 2014

Hum, I may have broken something when I fixed #10

I'll look into that.

neumino added a commit that referenced this issue Apr 12, 2014
neumino added a commit that referenced this issue Apr 12, 2014
@neumino
Copy link
Owner

neumino commented Apr 12, 2014

All theses tests works fine for me with Node 0.11.10
https://github.com/neumino/rethinkdbdash/blob/master/test/writing-data.js#L162

@jmdobry -- which version of rethinkdbdash are you using?
1.12.3 fixed a bug in r.json (used in insert).

@jmdobry
Copy link
Author

jmdobry commented Apr 12, 2014

@neumino [email protected] Node v0.10.26

@jmdobry
Copy link
Author

jmdobry commented Apr 12, 2014

@neumino I'm also still on RethinkDB 1.11.3. Should rethinkdbdash work with that version?

@neumino
Copy link
Owner

neumino commented Apr 12, 2014

@jmdobry -- it should work as long as you don't use the commands that were changed (avg, group etc.). In this case, the error is thrown before Node send the query, so it's definitively a bug in the JavaScript code.

I just tried with Node 0.10.26 and I don't have any problem to run your scripts. The documents get properly inserted.

Can you try with 0.11.4 to see if it was because of previousKeys that wasn't properly declared?

@jmdobry
Copy link
Author

jmdobry commented Apr 12, 2014

@neumino It worked. Thanks.

@neumino
Copy link
Owner

neumino commented Apr 12, 2014

Ah cool, I'm glad we could sort it out.

Thanks for reporting the bug!

@neumino neumino closed this as completed Apr 12, 2014
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