@@ -43,6 +43,7 @@ class Order(BaseHashModel):
43
43
created_on : datetime .datetime
44
44
45
45
class Member (BaseHashModel ):
46
+ id : int = Field (index = True )
46
47
first_name : str = Field (index = True )
47
48
last_name : str = Field (index = True )
48
49
email : str = Field (index = True )
@@ -64,6 +65,7 @@ class Meta:
64
65
@pytest_asyncio .fixture
65
66
async def members (m ):
66
67
member1 = m .Member (
68
+ id = 0 ,
67
69
first_name = "Andrew" ,
68
70
last_name = "Brookins" ,
69
71
@@ -73,6 +75,7 @@ async def members(m):
73
75
)
74
76
75
77
member2 = m .Member (
78
+ id = 1 ,
76
79
first_name = "Kim" ,
77
80
last_name = "Brookins" ,
78
81
@@ -82,6 +85,7 @@ async def members(m):
82
85
)
83
86
84
87
member3 = m .Member (
88
+ id = 2 ,
85
89
first_name = "Andrew" ,
86
90
last_name = "Smith" ,
87
91
@@ -129,6 +133,9 @@ async def test_exact_match_queries(members, m):
129
133
).all ()
130
134
assert actual == [member2 ]
131
135
136
+ actual = await m .Member .find (m .Member .id == 0 ).all ()
137
+ assert actual == [member1 ]
138
+
132
139
133
140
@py_test_mark_asyncio
134
141
async def test_full_text_search_queries (members , m ):
@@ -143,6 +150,19 @@ async def test_full_text_search_queries(members, m):
143
150
assert actual == [member1 , member3 ]
144
151
145
152
153
+ @py_test_mark_asyncio
154
+ async def test_pagination_queries (members , m ):
155
+ member1 , member2 , member3 = members
156
+
157
+ actual = await m .Member .find (m .Member .last_name == "Brookins" ).page ()
158
+
159
+ assert actual == [member1 , member2 ]
160
+
161
+ actual = await m .Member .find ().page (1 ,2 )
162
+
163
+ assert actual == [member1 ]
164
+
165
+
146
166
@py_test_mark_asyncio
147
167
async def test_recursive_query_resolution (members , m ):
148
168
member1 , member2 , member3 = members
@@ -611,4 +631,3 @@ class Address(m.BaseHashModel):
611
631
assert (
612
632
Address .redisearch_schema ()
613
633
== f"ON HASH PREFIX 1 { key_prefix } SCHEMA pk TAG SEPARATOR | a_string TAG SEPARATOR | a_full_text_string TAG SEPARATOR | a_full_text_string AS a_full_text_string_fts TEXT an_integer NUMERIC SORTABLE a_float NUMERIC"
614
- )
0 commit comments