UtilsApi sql query error after update to v 7.0.0
Just updated from v 4.0.0 to 7.0.0 and I get this error when running an sql query.
var res = await utils.sql('SELECT VERSION() as v');
Error: Multiple matches found constructing 'SqlResponse' with oneOf schemas Object, [Object]. Input: [{"columns":[{"v":{"type":"string"}}],"data":[{"v":"7.4.6 b2ff82920@25022808"}],"total":1,"error":"","warning":""}]
what changes do I have to make to my sql queries for this to work? I checked the docs and I can't see what I've done wrong.
https://github.com/manticoresoftware/manticoresearch-javascript/blob/master/docs/UtilsApi.md#sql
This is a bug which is fixed in the dev version now. You can use it until the next release.
@Nick-S-2018 is there any other workaround for those who can't upgrade to the dev version?
ok. I used the dev version and now I get
var res = await utils.sql('SHOW TABLES');
console.log(res);
SqlResponse {
toJSON: [Function (anonymous)],
actualInstance: [
{
columns: [Array],
data: [Array],
total: 1,
error: '',
warning: ''
}
]
}
Is this the expected output?
I guess I figured it out. In the previous version res was an array now that same array is returned by res.toJSON().
Should I go ahead and use this in this manner from now on?
Yes, currently this is the correct way to handle response result. We hope to find a neater solution in future releases.