from django.db.models.sql import compiler

class SQLCompiler(compiler.SQLCompiler):
    def as_sql(self, with_limits=True, with_col_aliases=False):
        sql, params = super(SQLCompiler, self).as_sql(with_limits=False, with_col_aliases=with_col_aliases)
        if with_limits:
            limits = []
            if self.query.high_mark is not None:
                limits.append('FIRST %d' % (self.query.high_mark - self.query.low_mark))
            if self.query.low_mark:
                if self.query.high_mark is None:
                    val = self.connection.ops.no_limit_value()
                    if val:
                        limits.append('FIRST %d' % val)
                limits.append('SKIP %d' % self.query.low_mark)
            sql = 'SELECT %s %s' % (' '.join(limits), sql[6:].strip())
        return sql, params

class SQLInsertCompiler(compiler.SQLInsertCompiler):
    pass

class SQLDeleteCompiler(compiler.SQLDeleteCompiler):
    pass

class SQLUpdateCompiler(compiler.SQLUpdateCompiler):
    pass

class SQLAggregateCompiler(compiler.SQLAggregateCompiler):
    pass

class SQLDateCompiler(compiler.SQLDateCompiler):
    pass