-
Notifications
You must be signed in to change notification settings - Fork 26
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
Pretty printing: Quoting in table names #3
Comments
Thanks for the report! No thought has been given to the issue of quoted identifiers, even though the parser sort of handles them, so thanks for the patch. I will try to see if there is anything else preventing the proper handling of identifiers that need quoting. Let me know if you have any other issues. |
I've looked into this a little more: So parsing something like 'select * from Reader' could be parsed then pretty printed as either 'select * from Reader' or 'select * from "Reader"'. If the table name in the catalog is e.g. 'reader', then the original sql is fine, but outputting the identifier with quotes would change the meaning of the sql query. I think the correct solution is to represent quoted and unquoted identifiers explicitly in the ast, (with fixes to the parser, typechecker and pretty printer). This doesn't seem too difficult and I have put it on my todo list. |
fixed in this commit: not comprehensively tested, please reopen bug with example if you find something still broken for quoted identifiers |
PostgreSQL (and, I think, many other RDBMs) requires table identifiers to be quoted in many cases. But HsSqlPpp does not quote them.
For example, printStatement generates:
select ... from Record r, Submmission s ...
while we need:
select ... from "Record" r, "Submission" s ...
Seems such a quoting might be done with simple patch. In Pretty.lhs replace convDqi definition with following:
The text was updated successfully, but these errors were encountered: