neumino / reqlite

Reqlite - RethinkDB in JavaScript
MIT License
338 stars 25 forks source link

r.uuid() not implemented #85

Closed nodesocket closed 7 years ago

nodesocket commented 8 years ago

r.uuid() does not seem to be implemented. Is that right?

neumino commented 8 years ago

Looks implemented to me. https://github.com/neumino/reqlite/blob/8609293f629684a37e848bbb7f58a0071011b6b2/test/control-structures.js#L1003 Please provide a script that prove otherwise if you think it's not the case.

nodesocket commented 8 years ago

Ok, here is a test case, note I am using the orm thinky. Perhaps that could be the problem.

Start reqlite:

node node_modules/reqlite/lib/node.js --silent

Try to generate a uuid and print it out:

'use strict';

const thinky = require('thinky')();

console.log(thinky.r.uuid());

This however seems to print the entire r object and all its properties instead of a uuid.

{ [Function]
  _query: [ 169 ],
  _r:
   { [Function]
     row: { [Function] _query: [Object], _r: [Circular] },
     monday: { [Function] _query: [Object], _r: [Circular] },
     tuesday: { [Function] _query: [Object], _r: [Circular] },
     wednesday: { [Function] _query: [Object], _r: [Circular] },
     thursday: { [Function] _query: [Object], _r: [Circular] },
     friday: { [Function] _query: [Object], _r: [Circular] },
     saturday: { [Function] _query: [Object], _r: [Circular] },
     sunday: { [Function] _query: [Object], _r: [Circular] },
     january: { [Function] _query: [Object], _r: [Circular] },
     february: { [Function] _query: [Object], _r: [Circular] },
     march: { [Function] _query: [Object], _r: [Circular] },
     april: { [Function] _query: [Object], _r: [Circular] },
     may: { [Function] _query: [Object], _r: [Circular] },
     june: { [Function] _query: [Object], _r: [Circular] },
     july: { [Function] _query: [Object], _r: [Circular] },
     august: { [Function] _query: [Object], _r: [Circular] },
     september: { [Function] _query: [Object], _r: [Circular] },
     october: { [Function] _query: [Object], _r: [Circular] },
     november: { [Function] _query: [Object], _r: [Circular] },
     december: { [Function] _query: [Object], _r: [Circular] },
     minval: { [Function] _query: [Object], _r: [Circular] },
     maxval: { [Function] _query: [Object], _r: [Circular] },
     nextVarId: 1,
     _Term: [Function: Term],
     _poolMaster:
      PoolMaster {
        _r: [Circular],
        _line: [Object],
        _pools: [Object],
        _healthyPools: [Object],
        _healthy: true,
        _init: false,
        _index: 0,
        _indexUnknown: 0,
        _discovery: true,
        _options: [Object],
        _log: [Function],
        _draining: false,
        _numConnections: 1,
        _numAvailableConnections: 0,
        _hasPrintWarningLocalhost: false,
        _feed: null,
        _consecutiveFails: -1,
        _timeoutError: 1000,
        _maxExponent: 6,
        _seed: 0,
        _servers: [Object],
        _timeout: [Object] },
     _options: {} } }
neumino commented 8 years ago

r.uuid() is a ReQL term, it will be executed on the server and replaced with an actual uuid. What you are seeing now is the Reql term [100].

nodesocket commented 8 years ago

Ok diving into the actual root of the problem. If I run reqlite using the following model, it breaks:

thinky.createModel('event', {
    id: type.string().uuid(4).default(thinky.r.uuid())
});

However, when starting an actual instance of RethinkDB locally, running the exact same model code works. I.E. breaks only with reqlite. Furthermore, if I replace .default('6bafff6b-aec1-44c5-a5b0-77d7044fcd7c') this works with both reqlite and an actual instance of RethinkDB locally.

neumino commented 8 years ago

What doesn't work with reqlite?

nodesocket commented 8 years ago

I guess I am not clear why when I use an actual local instance of RethinkDB .default(thinky.r.uuid()) works, but when using reqlite it fails.

nodesocket commented 8 years ago

@neumino I'm happy to give you a test case of this. Basically, what do you need?

neumino commented 8 years ago

A simple script that use a driver (rethinkdb or rethinkdbdash, but not thinky) that I can run that works against RethinkDB and doesn't work against reqlite.