def _compile(self, parts):
        sep = u",\n"
        and_ = u' %s\n' % AND
        select = [u'%s AS `%s`' % (v, k) for k, v in parts['select'].items()]
        stmt = u"SELECT\n%s\nFROM\n%s" % (sep.join(select),
                                          u"\n".join(parts['from']))
        if parts.get('where'):
            stmt = u"%s\nWHERE\n%s" % (stmt, and_.join(parts['where']))
        if parts.get('group_by'):
            stmt = u"%s\nGROUP BY\n%s" % (stmt, parts['group_by'])
        if parts.get('having'):
            stmt = u"%s\nHAVING\n%s" % (stmt, and_.join(parts['having']))
        if parts.get('order_by'):
            stmt = u"%s\nORDER BY\n%s" % (stmt, sep.join(parts['order_by']))
        if len(parts['limit']):
            stmt = u"%s\nLIMIT %s" % (stmt, ', '.join([str(i) for i in
                                                       parts['limit']]))
        return stmt
dataset/ETHPy150Open mozilla/addons-server/src/olympia/editors/sql_model.py/RawSQLManager._compile/original