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

Better Error Messages #640

Closed
nbdamian opened this issue Mar 29, 2016 · 7 comments
Closed

Better Error Messages #640

nbdamian opened this issue Mar 29, 2016 · 7 comments

Comments

@nbdamian
Copy link
Contributor

Could I suggest error messages be similar to sql, for example:
If a column you are querying does not exist, you would error log:
Unknown column 'columnname' in 'tablename' or Column 'columnname' doesn't exist in 'tablename'

Also, a lot of errors are not being handled and return javascript errors, perhaps we should go through some common errors we know of and then add better error logging to them.

@mathiasrw
Copy link
Member

Really good idea. Do you know if there is a standardised SQL error list?

perhaps we should go through some common errors we know of and then add better error logging to them

Do you have any inputs which ones to start with?

@nbdamian
Copy link
Contributor Author

I'm not sure there are any global standards for sql errors, but I would expect oracle to be a good choice.
https://docs.oracle.com/cd/B28359_01/server.111/b28278/toc.htm

@nbdamian
Copy link
Contributor Author

I would say definitely, start with the basics, ones that happen with incorrect syntax, or missing something important.
E.G
Incorrect Column Name / Column does not exists
Missing table in FROM
Missing parenthesis

@mathiasrw mathiasrw self-assigned this Mar 31, 2016
@mathiasrw
Copy link
Member

The parenthesis is tricky as its part of the parser generated from JISON

Now - I got the most common errors with error in table name and error in column name

> alasql('create table abc (a int)')
1

> alasql('select a from abc')
[]

> alasql('select b from abc')
Uncaught Error: Column does not exists: b

> alasql('select a from abcd')
Uncaught Error: Table does not exists: abcd

Please try it out in the last version of https://github.com/agershun/alasql/blob/develop/dist/alasql.js

@nbdamian
Copy link
Contributor Author

nbdamian commented Apr 8, 2016

Perfect, although I am unsure whether it was caused by this update, but it seems that it is now required to wrap any columns with ``.
If you don't wrap them it returns:

Uncaught Error: Column does not exists: 

Is this intentional?

Version: v0.2.5-develop-1262

@mathiasrw
Copy link
Member

Hmm, what sql are you using. I cant replicate it:

// alasql.version: 0.2.5-develop-1262

> alasql('create table abc (a int)')
1

> alasql('insert into abc values(2), (5)')
2

> alasql('column of select a from abc')
[2, 5]

> alasql('column of select b from abc')
Uncaught Error: Column does not exists: b

@nbdamian
Copy link
Contributor Author

Strange... I wonder what was causing it. Ignore then ;)

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

2 participants