Bug #58856 Cannot Enbeutificate
Submitted: 10 Dec 2010 6:23 Modified: 27 Jan 2012 3:19
Reporter: James Bromberger Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Utilities Severity:S3 (Non-critical)
Version:5.2.31 OS:Windows (7, XP SP3)
Assigned to: Alfredo Kojima CPU Architecture:Any
Tags: reformatter

[10 Dec 2010 6:23] James Bromberger
Description:
Trying to do SQL beautify on the following query gives an error in 5.2.31 (7100), while it parses and executes with no problems:

select concat(convert(`Protocols`.`Protocol` using utf8),'://',`Domains`.`Domain`,cast(ifnull(concat(':',`Downloaded_URLs`.`Port`),'') as char charset utf8),`Downloaded_URLs`.`Path`, cast(ifnull(concat('?',`Downloaded_URLs`.`Query_String`),'') as char charset utf8)) AS `URL`,`Downloaded_URLs`.`DateTime_UTC_Downloaded` AS `DateTime_UTC_Downloaded`,`Sites`.`SiteName` AS `SiteName`,`Downloaded_URLs`.`URL_MD5` AS `URL_MD5`,`Downloaded_URLs`.`Document_Title` AS `Document_Title` FROM `Downloaded_URLs` JOIN `Domains` ON (`Downloaded_URLs`.`DomainID` = `Domains`.`DomainID`) JOIN `Protocols` ON (`Downloaded_URLs`.`ProtocolID` = `Protocols`.`ProtocolID`) LEFT JOIN `Sites` ON (`Downloaded_URLs`.`SiteID` = `Sites`.`SiteID`) LIMIT 1;

A modal dialog box shown says "error calling SQLIDEUtils.enbeautificate: see output for details"; however, I can't see any output! ;)

How to repeat:
Paste the URL into Workbench, and chose Plugins->Utilities->Reformat Query.
[10 Dec 2010 7:04] Valeriy Kravchuk
Verified just as described on Windows XP. 

Output (use ctrl+F2 to get it) shows the following:

Traceback (most recent call last):
  File "C:\Program Files\MySQL\MySQL Workbench 5.2 CE\modules\sqlide_grt.py", line 170, in enbeautificate
    fmted = p.run()
  File "C:\Program Files\MySQL\MySQL Workbench 5.2 CE\modules\sql_reformatter.py", line 738, in run
    self.preprocess(self.ast)
  File "C:\Program Files\MySQL\MySQL Workbench 5.2 CE\modules\sql_reformatter.py", line 734, in preprocess
    self.preprocess(ch)
  File "C:\Program Files\MySQL\MySQL Workbench 5.2 CE\modules\sql_reformatter.py", line 734, in preprocess
    self.preprocess(ch)

... more like that ...

  File "C:\Program Files\MySQL\MySQL Workbench 5.2 CE\modules\sql_reformatter.py", line 734, in preprocess
    self.preprocess(ch)
  File "C:\Program Files\MySQL\MySQL Workbench 5.2 CE\modules\sql_reformatter.py", line 698, in preprocess
    children[i] = "TEXT_STRING_Q", "'%s'"%n.replace("'", r"\'"), c
AttributeError: 'NoneType' object has no attribute 'replace'
[27 Jan 2012 3:19] Philip Olson
This has been fixed since 5.2.33:

The "Reformat SQL Query" option would sometimes fail, and emit an error.