Next query executed after failed query returns invalid output #21

Closed
opened 2017-03-14 06:40:52 +00:00 by jacobborisov · 5 comments
jacobborisov commented 2017-03-14 06:40:52 +00:00 (Migrated from github.com)

Hello. I have following script to perform a test:

const basex = require('basex')
var session = new basex.Session()

function performQuery(q_str) {
    return new Promise(rs => {
        var q = session.query(q_str)
        q.execute((e, r) => {
            console.log("Result: ", r.result, "; Error:", e)
            rs()
        })
    })
}

var invalid_query = '(map {"key": "value"})("missing")("key")'
var correct_query = '(map {"key": "value"})("key")'

If I try to perform two correct queries in turn:

performQuery(correct_query).then(
    performQuery(correct_query)
)

all seem to be work as expected:

Result:  value ; Error: null
Result:  value ; Error: null

But if I put invalid query at first:

performQuery(invalid_query).then(
    performQuery(correct_query)
)

result of the next query also incorrect:

Result:  undefined ; Error:
Result:   ; Error: null

Is it a bug in your library or I simply doing something wrong? Thanks.

Hello. I have following script to perform a test: ``` const basex = require('basex') var session = new basex.Session() function performQuery(q_str) { return new Promise(rs => { var q = session.query(q_str) q.execute((e, r) => { console.log("Result: ", r.result, "; Error:", e) rs() }) }) } var invalid_query = '(map {"key": "value"})("missing")("key")' var correct_query = '(map {"key": "value"})("key")' ``` If I try to perform two correct queries in turn: ``` performQuery(correct_query).then( performQuery(correct_query) ) ``` all seem to be work as expected: ``` Result: value ; Error: null Result: value ; Error: null ``` But if I put invalid query at first: ``` performQuery(invalid_query).then( performQuery(correct_query) ) ``` result of the next query also incorrect: ``` Result: undefined ; Error: Result: ; Error: null ``` Is it a bug in your library or I simply doing something wrong? Thanks.
apb2006 commented 2017-03-14 12:37:30 +00:00 (Migrated from github.com)

Hi Jacob,
Looks like a bug in my library (in the parsing of the error response ) to me.
I will take a look and try to fix it in the next day or so. This project has been a bit neglected (last used with Node 0.6)
Meantime you could try https://github.com/alxarch/basex-stream which appears to handle the comms in the cleaner fashion.
/Andy

Hi Jacob, Looks like a bug in my library (in the parsing of the error response ) to me. I will take a look and try to fix it in the next day or so. This project has been a bit neglected (last used with Node 0.6) Meantime you could try https://github.com/alxarch/basex-stream which appears to handle the comms in the cleaner fashion. /Andy
apb2006 commented 2017-03-14 17:47:24 +00:00 (Migrated from github.com)

query.results was handling errors ok but query.execute was not pulling error message from stream. Will package and push to npm this week.

`query.results` was handling errors ok but `query.execute` was not pulling error message from stream. Will package and push to npm this week.
apb2006 commented 2017-03-15 10:30:45 +00:00 (Migrated from github.com)

v0.8.0 now released to npm should fix this issue. Thanks for reporting.

v0.8.0 now released to npm should fix this issue. Thanks for reporting.
jacobborisov commented 2017-03-15 10:48:02 +00:00 (Migrated from github.com)

I can confirm that the problem has been fixed in my case. Thanks for the quick resolution!

I can confirm that the problem has been fixed in my case. Thanks for the quick resolution!
apb2006 commented 2017-03-15 10:50:54 +00:00 (Migrated from github.com)

thanks

thanks
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
quodatum/basex-node#21
No description provided.