diff --git a/AUTHORS b/AUTHORS index 53fcee13a8..e322526a64 100644 --- a/AUTHORS +++ b/AUTHORS @@ -325,6 +325,7 @@ answer newbie questions, and generally made Django that much better: Guillaume Pannatier Gustavo Picon hambaloney + Hang Park Hannes Struß Hasan Ramezani Hawkeye diff --git a/django/db/backends/base/operations.py b/django/db/backends/base/operations.py index b4c2250dfa..892527873a 100644 --- a/django/db/backends/base/operations.py +++ b/django/db/backends/base/operations.py @@ -218,10 +218,10 @@ class BaseDatabaseOperations: def limit_offset_sql(self, low_mark, high_mark): """Return LIMIT/OFFSET SQL clause.""" limit, offset = self._get_limit_offset_params(low_mark, high_mark) - return '%s%s' % ( - (' LIMIT %d' % limit) if limit else '', - (' OFFSET %d' % offset) if offset else '', - ) + return ' '.join(sql for sql in ( + ('LIMIT %d' % limit) if limit else None, + ('OFFSET %d' % offset) if offset else None, + ) if sql) def last_executed_query(self, cursor, sql, params): """ diff --git a/django/db/backends/oracle/operations.py b/django/db/backends/oracle/operations.py index 84c6bcc75f..6ac6b29737 100644 --- a/django/db/backends/oracle/operations.py +++ b/django/db/backends/oracle/operations.py @@ -249,10 +249,10 @@ END; def limit_offset_sql(self, low_mark, high_mark): fetch, offset = self._get_limit_offset_params(low_mark, high_mark) - return '%s%s' % ( - (' OFFSET %d ROWS' % offset) if offset else '', - (' FETCH FIRST %d ROWS ONLY' % fetch) if fetch else '', - ) + return ' '.join(sql for sql in ( + ('OFFSET %d ROWS' % offset) if offset else None, + ('FETCH FIRST %d ROWS ONLY' % fetch) if fetch else None, + ) if sql) def last_executed_query(self, cursor, sql, params): # https://cx-oracle.readthedocs.io/en/latest/cursor.html#Cursor.statement