Added check for SELECT with LIMIT...this won't fly with SQLBase.

This commit is contained in:
Lance Edgar 2010-04-22 18:18:43 -05:00
parent e44aecdf79
commit 5c8f88551a

View file

@ -29,6 +29,16 @@ from sqlalchemy.sql.compiler import SQLCompiler
from sqlalchemy.sql.expression import Join 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): class SQLBase7Compiler(SQLCompiler):
# Most of the code below was copied from the Oracle dialect. Thanks to Michael Bayer # 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): def visit_select(self, select, **kwargs):
froms = select._get_display_froms() froms = select._get_display_froms()
whereclause = self._get_join_whereclause(froms) whereclause = self._get_join_whereclause(froms)
if whereclause: if whereclause is not None:
select = select.where(whereclause) 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) kwargs['iswrapper'] = getattr(select, '_is_wrapper', False)
return SQLCompiler.visit_select(self, select, **kwargs) return SQLCompiler.visit_select(self, select, **kwargs)