@@ -50,11 +50,12 @@
Loading
50 50
51 51
class QuerySet:
52 52
    ESCAPE_CHARACTERS = ['%', '_']
53 -
    def __init__(self, model_cls=None, filter_clauses=None, select_related=None, limit_count=None):
53 +
    def __init__(self, model_cls=None, filter_clauses=None, select_related=None, limit_count=None, offset=None):
54 54
        self.model_cls = model_cls
55 55
        self.filter_clauses = [] if filter_clauses is None else filter_clauses
56 56
        self._select_related = [] if select_related is None else select_related
57 57
        self.limit_count = limit_count
58 +
        self.query_offset = offset
58 59
59 60
    def __get__(self, instance, owner):
60 61
        return self.__class__(model_cls=owner)
@@ -92,6 +93,9 @@
Loading
92 93
        if self.limit_count:
93 94
            expr = expr.limit(self.limit_count)
94 95
96 +
        if self.query_offset:
97 +
            expr = expr.offset(self.query_offset)
98 +
95 99
        return expr
96 100
97 101
    def filter(self, **kwargs):
@@ -160,7 +164,8 @@
Loading
160 164
            model_cls=self.model_cls,
161 165
            filter_clauses=filter_clauses,
162 166
            select_related=select_related,
163 -
            limit_count=self.limit_count
167 +
            limit_count=self.limit_count,
168 +
            offset=self.query_offset
164 169
        )
165 170
166 171
    def select_related(self, related):
@@ -172,7 +177,8 @@
Loading
172 177
            model_cls=self.model_cls,
173 178
            filter_clauses=self.filter_clauses,
174 179
            select_related=related,
175 -
            limit_count=self.limit_count
180 +
            limit_count=self.limit_count,
181 +
            offset=self.query_offset
176 182
        )
177 183
178 184
    async def exists(self) -> bool:
@@ -185,7 +191,18 @@
Loading
185 191
            model_cls=self.model_cls,
186 192
            filter_clauses=self.filter_clauses,
187 193
            select_related=self._select_related,
188 -
            limit_count=limit_count
194 +
            limit_count=limit_count,
195 +
            offset=self.query_offset
196 +
        )
197 +
198 +
199 +
    def offset(self, offset: int):
200 +
        return self.__class__(
201 +
            model_cls=self.model_cls,
202 +
            filter_clauses=self.filter_clauses,
203 +
            select_related=self._select_related,
204 +
            limit_count=self.limit_count,
205 +
            offset=offset
189 206
        )
190 207
191 208
    async def count(self) -> int:

@@ -195,6 +195,17 @@
Loading
195 195
196 196
        assert len(await User.objects.limit(2).filter(name__iexact='Tom').all()) == 2
197 197
198 +
199 +
@async_adapter
200 +
async def test_offset():
201 +
    async with database:
202 +
        await User.objects.create(name="Tom")
203 +
        await User.objects.create(name="Jane")
204 +
205 +
        users = await User.objects.offset(1).limit(1).all()
206 +
        assert users[0].name == 'Jane'
207 +
208 +
198 209
@async_adapter
199 210
async def test_model_first():
200 211
    async with database:
Files Coverage
orm 100.00%
tests 100.00%
Project Totals (8 files) 100.00%
Notifications are pending CI completion. Periodically Codecov will check the CI state, when complete notifications will be submitted. Push notifications now.
114.1
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
114.2
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
1
coverage:
2
  precision: 2
3
  round: down
4
  range: "80...100"
5

6
  status:
7
    project: yes
8
    patch: yes
9
    changes: yes
10

11
comment: off
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading