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

[bug]syntext error when parsing mysql:query #83

Open
johnzeng opened this issue Apr 1, 2017 · 1 comment
Open

[bug]syntext error when parsing mysql:query #83

johnzeng opened this issue Apr 1, 2017 · 1 comment

Comments

@johnzeng
Copy link

johnzeng commented Apr 1, 2017

I happened to find out that the refactor doesn't work for my sql wrapper module, so I did some debugging, and I find out that if the file contains the following codes, the parser will results in error like error syntax before query:

case mysql:query(xxx,xxx,xxx) of
  .....

After some more debug, I find out that wrangler has a function called wrangler_syntax:query_expr, and i know that there is some syntax called query syntax for Mnesia, so I believe you are making some assertion that a query must be the begin of query syntax ....

This should be a bug because the mysql mode is working fine so the syntax should be ok for erlang compiler.

Here is the mysql driver. You can see it's using query as a main API.

I am trying to create a patch, but the syntax file is a little complicate ...

@johnzeng
Copy link
Author

johnzeng commented Apr 1, 2017

Refer to this , query was a legacy keywords for erlang:

Legacy in the grammar
Try to use "query" as an atom in Erlang, e.g. {query, "SELECT * FROM foobar"}. What happens?
syntax error before: ','
This is because 'query' is a reserved word which was reserved for Mnemosyne queries. Never heard of Mnemosyne? That's because it's an archaic way of querying Erlang's built-in database, Mnesia, and has been replaced with Query List Comprehensions (QLC). However, it remains around for backwards compatibility.
You can't use "query" as a function name. You can't tag a tuple with "query". You can't do anything with "query" except invoke a deprecated legacy API which no one uses anymore.

Also refer to erlang's document, query is no longer a reversed word in erlang.

So, removing query as a reserverd word in wrangler_scan.erl fixed my bug.

%reserved_word('query') -> true;

But it's not a final solution for this tool because I believe there are still some people using this syntax, although I haven't seen any.

That's all I can help. Let me know your idea.

@johnzeng johnzeng changed the title [buy]syntext error when parsing mysql:query [bug]syntext error when parsing mysql:query Aug 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant