kayak / pypika

PyPika is a python SQL query builder that exposes the full richness of the SQL language using a syntax that reflects the resulting query. PyPika excels at all sorts of SQL queries but is especially useful for data analysis.
http://pypika.readthedocs.io/en/latest/
Apache License 2.0
2.5k stars 295 forks source link

dialect parameter without effect #790

Open thmsklngr opened 8 months ago

thmsklngr commented 8 months ago

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 commented 8 months ago

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