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

dialect parameter without effect #790

Open
thmsklngr opened this issue Feb 2, 2024 · 1 comment
Open

dialect parameter without effect #790

thmsklngr opened this issue Feb 2, 2024 · 1 comment

Comments

@thmsklngr
Copy link

Hi,
I tried to create a query for MySQL today and found out that regardless I define, the query always looks the same.

Example:

> from pypika import Table, Query, Dialects
> Query.from_('bar', dialect=Dialects.MYSQL).select('foo')
'SELECT "foo" FROM "bar"'

> q = Query.from_('bar').select('foo')
> q.get_sql(dialect=Dialects.MYSQL)
'SELECT "foo" FROM "bar"'

The ony way to get a correct MySQL query is to either use MySQLQuery from pypika.dialects or you use q.get_sql(quote_char='`').

Of course it could be that I may have a wrong understanding of pypika.Dialects, but there's not much explanation out there.

Regards, Thomas

@wd60622
Copy link
Contributor

wd60622 commented Feb 3, 2024

I believe using the dialect specific Query class is the recommended way of using. That's somewhere in the README

I am not sure if passing dialect kwarg is recommended. Definitely confusing to not get the behavior out of it though
It could be that the kwarg is never used

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

2 participants