Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try-catch errors with misspelling in SQL #1526

Closed
addlistener opened this issue Oct 24, 2022 · 10 comments
Closed

Try-catch errors with misspelling in SQL #1526

addlistener opened this issue Oct 24, 2022 · 10 comments

Comments

@addlistener
Copy link

addlistener commented Oct 24, 2022

@mathiasrw Check it out. You can fork it to see the error messages.

The server breaks when there's no such function. Ideally it should be caught by the try block.

https://replit.com/@jchnxu/DeficientSubstantialSystemsanalysis#index.js

@mathiasrw
Copy link
Member

Hmm. I cant replicate this. Any chance you can make a jsfiddle with it? https://jsfiddle.net/8brvex4f/

I dont understand where use median - and what is wrongFuncName(email_domain)?


Bonus info
Alasql is async and returns a promise if you call alasql.async or if you put the first argument in an array, or if you engage with a file like CSV or excel. So instead of the function in the second parameter you can do something like

app.use(async ctx => {
  ctx.body = 'Hello World';
  const { columns, data: objects } = await alasql.promise("SELECT RECORDSET wrongFuncName(`email_domain`) FROM CSV('some.csv') AS `temp`")
  });
});

@addlistener
Copy link
Author

addlistener commented Oct 24, 2022

OP edited. Sorry for my vague description.

@mathiasrw And thanks for the bonus. I tried alasql.promise and it's the same bug.

@mathiasrw
Copy link
Member

Might be related to #1491 - try v2.1.5 and see if that helps

@addlistener
Copy link
Author

addlistener commented Oct 24, 2022

I updated the dep to 2.1.5 and it's still breaking.
https://replit.com/@jchnxu/DeficientSubstantialSystemsanalysis#index.js

I ask not because there's a bug in the median function but for a generic way to handle typos in functions. If I mistype the function name it should not bring my server down. Instead I should be able to catch the error.

image

@mathiasrw
Copy link
Member

mathiasrw commented Oct 25, 2022

Ahhhhhh. I got it now. Its probably because the execution is run in a new Function context. Hmm. Should be doable...

@mathiasrw mathiasrw changed the title Server down when alasql.fn.median is not a function Try-catch errors with misspelling in SQL Oct 25, 2022
@Chaitanyaprasad60
Copy link

Hi, Seems like issue is not yet resolved. Can you assign it to me?

@Chaitanyaprasad60
Copy link

I found a way to catch the error and due to this, the server will not go down. But I am unable to return the error through the callback function. As "cb" is not available in the scope of the function. Any ideas ??

@mathiasrw
Copy link
Member

What function does not have the callback avaliable?

@Chaitanyaprasad60
Copy link

yy.Select.prototype.compileSelect2 This Function. Where the error is actually occurring

@mathiasrw
Copy link
Member

Fix released as part of v4.1.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants