orientechnologies / orientjs

The official fast, lightweight node.js client for OrientDB
http://orientdb.com
Other
326 stars 68 forks source link

Getting error by processing subqueries in "projections" #341

Closed petervavro closed 5 years ago

petervavro commented 6 years ago

Running this :

let r = db
    .select([
        `(SELECT * FROM TableB)`
        `fieldI`,
        `fieldII`
    ])
    .from(`TableA`)
    .all()

Getting error :

{ OrientDB.RequestError: Error on execution of command: sql.SELECT (SELECT * FROM TableB), fieldI, fieldII FROM TableA DB name="dbtest" at child.Operation.parseError (/node_modules/orientjs/lib/transport/binary/protocol33/operation.js:905:13) at child.Operation.consume (/node_modules/orientjs/lib/transport/binary/protocol33/operation.js:496:35) at Connection.process (/node_modules/orientjs/lib/transport/binary/connection.js:459:17) at Connection.handleSocketData (/node_modules/orientjs/lib/transport/binary/connection.js:331:20) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at Socket.Readable.push (_stream_readable.js:208:10) at TCP.onread (net.js:601:20) From previous event: at Connection._sendOp (/node_modules/orientjs/lib/transport/binary/connection.js:87:10) at Connection.send (/node_modules/orientjs/lib/transport/binary/connection.js:71:17) at /node_modules/orientjs/lib/transport/binary/index.js:303:38 From previous event: at BinaryTransport.send (/node_modules/orientjs/lib/transport/binary/index.js:301:12) at Server.withRetry (/node_modules/orientjs/lib/server/index.js:118:18) at Server.<anonymous> (/node_modules/orientjs/lib/server/index.js:112:12) From previous event: at Server.send (/node_modules/orientjs/lib/server/index.js:111:10) at Db.<anonymous> (/node_modules/orientjs/lib/db/db.js:225:26) at runCallback (timers.js:810:20) at tryOnImmediate (timers.js:768:5) at processImmediate [as _immediateCallback] (timers.js:745:5) From previous event: at Db.<anonymous> (/node_modules/orientjs/lib/db/db.js:216:6) at /node_modules/orientjs/lib/db/db.js:239:7 From previous event: at Db.retryIfExpired (/node_modules/orientjs/lib/db/db.js:238:10) at Db.send (/node_modules/orientjs/lib/db/db.js:213:15) at Db.exec (/node_modules/orientjs/lib/db/db.js:357:22) at Db.query (/node_modules/orientjs/lib/db/db.js:391:15) at child.exec (/node_modules/orientjs/lib/db/query.js:108:20) at child.all (/node_modules/orientjs/lib/db/query.js:70:17) at Object.getServices (/server/service/services.js:495:8) at <anonymous> name: 'OrientDB.RequestError', message: 'Error on execution of command: sql.SELECT (SELECT * FROM TableB), fieldI, fieldII FROM TableA\r\n\tDB name="dbtest"', data: {}, isMVCC: [Function], isTokenException: [Function], previous: [], id: 1, type: 'com.orientechnologies.orient.core.exception.OCommandExecutionException', hasMore: 0 }

Thank you !

wolf4ood commented 6 years ago

Hi @petervavro

seems that is no valid query. did you check if this query works on Studio?

Thanks

petervavro commented 6 years ago

Yes I did, the query runs without issues on Studio. It seems like OrientJS does not accept subqueries. BTW, I am using OrientDB version 3.0.8 .

wolf4ood commented 6 years ago

@petervavro

did you use the latest APIs of OrientJS 3.0?

https://orientdb.org/docs//3.0.x/orientjs/OrientJS.html

Thanks

petervavro commented 6 years ago

I am using "version": "3.0.0". Thank you.

wolf4ood commented 6 years ago

How do you get the db instance?

Thanks

petervavro commented 6 years ago

This way :

`var server = OrientDB({ host: '10.0.1.5', port: 2424, username: 'root', password: 'root_passwd', });

var db = server.use({ name: 'GratefulDeadConcerts', username: 'admin', password: 'admin_passwd' });`

wolf4ood commented 6 years ago

@petervavro

this are the old APIs.

Please check the new APIs that make use of the new binary protocol

https://orientdb.org/docs//3.0.x/orientjs/OrientJS.html

This should solve the issue

Thanks

petervavro commented 6 years ago

Thank you. I tried but I am getting this :

342

petervavro commented 6 years ago

Now it works perfectly. Thank you ! ...But I need to say that the documentation is really confusing. Or did I miss something ?

wolf4ood commented 6 years ago

@petervavro

I'm improving the docs. It should be out in the next days. I'm adding also async/await examples

Thanks