Commits

Olemis Lang committed 2794831

GViz QL [ refs #299 ] : OPTION no_values tested with FORMAT clause ... (failures=1)

  • Participants
  • Parent commits f596635

Comments (0)

Files changed (2)

trac-dev/gviz/tracgviz/gvizql.py

       return formatter[idx]
     elif formatter is None:
       # e.g. GViz no_values option set
-      return to_unicode(value, 'utf8')
+      return to_unicode(value).encode('utf8')
     elif coltype in cls.DATETIME_CONVERTER:
       value = cls.DATETIME_CONVERTER[coltype](value)
       supported = True
       return schema, data
     else:
       # Bare values , assume naive formatting strategy
-      return schema, ([(None, to_unicode(val, 'utf8')) for val in row]
+      return schema, ([(None, to_unicode(val).encode('utf8')) for val in row]
                       for row in data)
 
 #------------------------------------------------------
     r"""Transform the result set as determined by the GVizQL 
     expression directives and clauses.
     """
-    options = getattr(self, 'opts', None)
+    options = dict(getattr(self, 'opts', []))
     for ch in self.itereval():
       if options:
         ch.configure(options)

trac-dev/gviz/tracgviz/testing/test_gvizql.py

       salary number
       isSenior boolean
       = Row =
-         dept = (None, u'Eng')
-         salary = (None, u'1000')
-         isSenior = (None, u'True')
-      = Row =
-         dept = (None, u'Eng')
-         salary = (None, u'500')
-         isSenior = (None, u'False')
-      = Row =
-         dept = (None, u'Eng')
-         salary = (None, u'600')
-         isSenior = (None, u'False')
-      = Row =
-         dept = (None, u'Sales')
-         salary = (None, u'400')
-         isSenior = (None, u'True')
-      = Row =
-         dept = (None, u'Sales')
-         salary = (None, u'350')
-         isSenior = (None, u'False')
-      = Row =
-         dept = (None, u'Marketing')
-         salary = (None, u'800')
-         isSenior = (None, u'True')
+         dept = (None, 'Eng')
+         salary = (None, '1000')
+         isSenior = (None, 'True')
+      = Row =
+         dept = (None, 'Eng')
+         salary = (None, '500')
+         isSenior = (None, 'False')
+      = Row =
+         dept = (None, 'Eng')
+         salary = (None, '600')
+         isSenior = (None, 'False')
+      = Row =
+         dept = (None, 'Sales')
+         salary = (None, '400')
+         isSenior = (None, 'True')
+      = Row =
+         dept = (None, 'Sales')
+         salary = (None, '350')
+         isSenior = (None, 'False')
+      = Row =
+         dept = (None, 'Marketing')
+         salary = (None, '800')
+         isSenior = (None, 'True')
+
+
+      >>> parse("select dept , salary, isSenior format salary '#,##0.00' "
+      ...       "options no_values", 'opts', 'cols', 'fmt')
+      *****
+      * Tokens
+      *****
+      Token.Keyword.Reserved select
+      Token.Name.Variable dept
+      Token.Punctuation ,
+      Token.Name.Variable salary
+      Token.Punctuation ,
+      Token.Name.Variable isSenior
+      Token.Keyword.Reserved format
+      Token.Name.Variable salary
+      Token.Literal.String.Single '#,##0.00'
+      Token.Keyword.Reserved options
+      Token.Name.Variable no_values
+      *****
+      * Parsing
+      *****
+      [('no_values', None)]
+      ['dept', 'salary', 'isSenior']
+      [('salary', '#,##0.00')]
+      *****
+      * Result
+      *****
+      = Columns =
+      dept string
+      salary number
+      isSenior boolean
+      = Row =
+         dept = (None, 'Eng')
+         salary = (None, '1,000.00')
+         isSenior = (None, 'true')
+      = Row =
+         dept = (None, 'Eng')
+         salary = (None, '500.00')
+         isSenior = (None, 'false')
+      = Row =
+         dept = (None, 'Eng')
+         salary = (None, '600.00')
+         isSenior = (None, 'false')
+      = Row =
+         dept = (None, 'Sales')
+         salary = (None, '400.00')
+         isSenior = (None, 'true')
+      = Row =
+         dept = (None, 'Sales')
+         salary = (None, '350.00')
+         isSenior = (None, 'false')
+      = Row =
+         dept = (None, 'Marketing')
+         salary = (None, '800.00')
+         isSenior = (None, 'true')
 
 
       >>> parse("select `email address`, name, `date` options no_values", \