SQLObjectでMATCH AGAINST を発行する。

http://d.hatena.ne.jp/tasukuchan/20070213/learn_turbogears
■[Python]TurboGearsを勉強するもMATCH AGAINSTできねっす

ということで勉強がてらMATCH AGAINST を発行する方法

from sqlobject.sqlbuilder import *
class Match(SQLExpression):
    """ 
    >>> Select(Table("a").x, where=Match([Table("a").s, Table("b").x], "x")).__sqlrepr__(db="mysql")
    ... "SELECT a.x FROM a WHERE Match (a.s, b.x) Against ('x')"
    """
    def __init__(self, cols, against):
        self.cols = cols        
        self.against = against
    def __sqlrepr__(self, db):
        return "Match (%s) Against (%s)" % (", ".join([sqlrepr(v, db) for v in self.cols]), sqlrepr(self.against, db))