diff --git a/sqlbase7_sa/base.py b/sqlbase7_sa/base.py index ae45cd6..be7dfd1 100644 --- a/sqlbase7_sa/base.py +++ b/sqlbase7_sa/base.py @@ -29,6 +29,16 @@ from sqlalchemy.sql.compiler import SQLCompiler from sqlalchemy.sql.expression import Join +class LimitClauseNotSupported(Exception): + + def __init__(self, limit, offset): + self.limit = limit + self.offset = offset + + def __str__(self): + return "Centura SQLBase 7.5.1 doesn't support a LIMIT clause for the SELECT statement (received: limit = %u, offset = %u)" % (self.limit, self.offset) + + class SQLBase7Compiler(SQLCompiler): # Most of the code below was copied from the Oracle dialect. Thanks to Michael Bayer @@ -41,9 +51,12 @@ class SQLBase7Compiler(SQLCompiler): def visit_select(self, select, **kwargs): froms = select._get_display_froms() whereclause = self._get_join_whereclause(froms) - if whereclause: + if whereclause is not None: select = select.where(whereclause) + if select._limit is not None or select._offset is not None: + raise LimitClauseNotSupported(select._limit, select._offset) + kwargs['iswrapper'] = getattr(select, '_is_wrapper', False) return SQLCompiler.visit_select(self, select, **kwargs)