def test_key_reflection_columns(self):
    regex = self.parser._re_key
    exprs = self.parser._re_keyexprs
    m = regex.match("  KEY (`id`) USING BTREE COMMENT '''comment'")
    eq_(m.group('columns'), '`id`')
    m = regex.match('  KEY (`x`, `y`) USING BTREE')
    eq_(m.group('columns'), '`x`, `y`')
    eq_(exprs.findall(m.group('columns')), [('x', '', ''), ('y', '', '')])
    m = regex.match('  KEY (`x`(25), `y`(15)) USING BTREE')
    eq_(m.group('columns'), '`x`(25), `y`(15)')
    eq_(exprs.findall(m.group('columns')), [('x', '25', ''), ('y', '15', '')])
    m = regex.match('  KEY (`x`(25) DESC, `y`(15) ASC) USING BTREE')
    eq_(m.group('columns'), '`x`(25) DESC, `y`(15) ASC')
    eq_(exprs.findall(m.group('columns')), [('x', '25', 'DESC'), ('y', '15', 'ASC')])
    m = regex.match('  KEY `foo_idx` (`x` DESC)')
    eq_(m.group('columns'), '`x` DESC')
    eq_(exprs.findall(m.group('columns')), [('x', '', 'DESC')])
    eq_(exprs.findall(m.group('columns')), [('x', '', 'DESC')])
    m = regex.match('  KEY `foo_idx` (`x` DESC, `y` ASC)')
    eq_(m.group('columns'), '`x` DESC, `y` ASC')
def test_key_reflection_columns(self):
    regex = self.parser._re_key
    exprs = self.parser._re_keyexprs
    m = regex.match("  KEY (`id`) USING BTREE COMMENT 'comment'")
    eq_(m.group('columns'), '`id`')
    m = regex.match('  KEY (`x`, `y`) USING BTREE')
    eq_(m.group('columns'), '`x`, `y`')
    eq_(exprs.findall(m.group('columns')), [('x', , ), ('y', , )])
    m = regex.match('  KEY (`x`(25), `y`(15)) USING BTREE')
    eq_(m.group('columns'), '`x`(25), `y`(15)')
    eq_(exprs.findall(m.group('columns')), [('x', '25', ), ('y', '15', )])
    m = regex.match('  KEY (`x`(25) DESC, `y`(15) ASC) USING BTREE')
    eq_(m.group('columns'), '`x`(25) DESC, `y`(15) ASC')
    eq_(exprs.findall(m.group('columns')), [('x', '25', 'DESC'), ('y', '15', 'ASC')])
    m = regex.match('  KEY `foo_idx` (`x` DESC)')
    eq_(m.group('columns'), '`x` DESC')
    eq_(exprs.findall(m.group('columns')), [('x', , 'DESC')])
    eq_(exprs.findall(m.group('columns')), [('x', , 'DESC')])
    m = regex.match('  KEY `foo_idx` (`x` DESC, `y` ASC)')
    eq_(m.group('columns'), '`x` DESC, `y` ASC')