sqlparse
sqlparse copied to clipboard
Incorrect Case formatting
In the Keywords.py file current_timestamp , sum etc are mapped as Keywords. Using sqplarse doesnot change its case to uppercase while using Upper clause in the syntax.
Could you provide an example?
Formatting : SELECT MAX(D_Fiscal_period) FROM mip.mip_filter_period WHERE D_Sales_data_type IN ('SELL-IN') AND D_Period_type_desc IN ('Quarter')
Gave the result
SELECT max(d_fiscal_period) FROM mip.mip_filter_period WHERE d_sales_data_type IN ('SELL-IN') AND d_period_type_desc IN ('Quarter')
Every things okay here except I am getting MAX() case being lowered. Is this because it is associated with () whose case cannot be determined ? I am using below settings : file = open(outfile, 'w').write(sqlparse.format(sql_array, reindent=True,indent_width = 4, keyword_case='upper', identifier_case = 'lower')) Let me know if I am missing something here.
Yes, that's because of the parentheses. It counts as a function call, but not as a keyword in that case.
Minat Kumar Verma [email protected] schrieb am Tue Dec 02 2014 at 10:36:54:
Formatting : SELECT MAX(D_Fiscal_period) FROM mip.mip_filter_period WHERE D_Sales_data_type IN ('SELL-IN') AND D_Period_type_desc IN ('Quarter')
Gave the result
SELECT max(d_fiscal_period) FROM mip.mip_filter_period WHERE d_sales_data_type IN ('SELL-IN') AND d_period_type_desc IN ('Quarter')
Every things okay here except I am getting MAX() case being lowered. Is this because it is associated with () whose case cannot be determined ? I am using below settings : file = open(outfile, 'w').write(sqlparse.format(sql_array, reindent=True,indent_width = 4, keyword_case='upper', identifier_case = 'lower')) Let me know if I am missing something here.
Reply to this email directly or view it on GitHub https://github.com/andialbrecht/sqlparse/issues/150#issuecomment-65204272 .
Any work around can you suggest to overcome this ?
you can use the option identifier_case to format functions similar to keyword_case.
This was the response on another issue as well. How can you get keywords and functions to be all caps, but not column names? identifier_case also affects column names.