manticoresearch-javascript icon indicating copy to clipboard operation
manticoresearch-javascript copied to clipboard

UtilsApi sql query error after update to v 7.0.0

Open marz0405 opened this issue 11 months ago • 4 comments

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

marz0405 avatar Mar 12 '25 05:03 marz0405

This is a bug which is fixed in the dev version now. You can use it until the next release.

Nick-S-2018 avatar Mar 12 '25 09:03 Nick-S-2018

@Nick-S-2018 is there any other workaround for those who can't upgrade to the dev version?

sanikolaev avatar Mar 12 '25 10:03 sanikolaev

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?

marz0405 avatar Mar 12 '25 12:03 marz0405

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?

marz0405 avatar Mar 13 '25 04:03 marz0405

Yes, currently this is the correct way to handle response result. We hope to find a neater solution in future releases.

Nick-S-2018 avatar Mar 18 '25 10:03 Nick-S-2018