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

Ambiguous meaning of # in different SQL dialects #60

Open
jdorn opened this issue Jan 27, 2014 · 2 comments
Open

Ambiguous meaning of # in different SQL dialects #60

jdorn opened this issue Jan 27, 2014 · 2 comments

Comments

@jdorn
Copy link
Owner

jdorn commented Jan 27, 2014

In MySQL, # is the start of a single line comment.
In SQL Server, # is used to prefix temporary table names.
In Microsoft Access SQL, # is used to surround dates.
In Oracle SQL, # is a valid character in an unquoted identifier.

These are just the ones I was able to find with a few minutes of searching.

Currently, it uses the MySQL meaning and highlights/formats it as a comment.

I'm not sure what the correct thing to do is.

@hhellbusch
Copy link

Perhaps an optional parameter or config to specify which dialect to use. I'd prefer this as it would allow me to tell the formatter which dialect to use.

@Deltachaos
Copy link

For SAP ASE # indicates a temporary table when used as a table name. Would it not be the best to remove the # from comments now?

On the other hand i also prefer @hhellbusch suggestion of giving the formater information about which dialect it should use. Would this be a satisfiable solution to you @jdorn? If so i would implement it that way.

My suggestion is to make the SqlFormater class instanceable and give a dialect as argument in the construct. Then i would create multiple dialect classes which conains the dialect tokens etc.
Then i would deprecate the use of the static format method and would instantiate a new instance there and call the new method on the object.

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

3 participants