@@ -107,14 +107,22 @@ pub trait QueryParamsBuilder {
107
107
}
108
108
109
109
if let Some ( after) = pagination. after . as_ref ( ) {
110
- let after_conditions =
111
- Self :: create_pagination_conditions ( cursor_fields, after, ">" ) ;
110
+ let after_conditions = Self :: create_pagination_conditions (
111
+ cursor_fields,
112
+ after,
113
+ ">" ,
114
+ join_prefix,
115
+ ) ;
112
116
conditions. push ( after_conditions) ;
113
117
}
114
118
115
119
if let Some ( before) = pagination. before . as_ref ( ) {
116
- let before_conditions =
117
- Self :: create_pagination_conditions ( cursor_fields, before, "<" ) ;
120
+ let before_conditions = Self :: create_pagination_conditions (
121
+ cursor_fields,
122
+ before,
123
+ "<" ,
124
+ join_prefix,
125
+ ) ;
118
126
conditions. push ( before_conditions) ;
119
127
}
120
128
@@ -151,11 +159,16 @@ pub trait QueryParamsBuilder {
151
159
cursor_fields : & [ & str ] ,
152
160
cursor : & Cursor ,
153
161
operation : & str ,
162
+ join_prefix : Option < & str > ,
154
163
) -> String {
155
164
if cursor_fields. is_empty ( ) || cursor. is_empty ( ) {
156
165
return String :: new ( ) ;
157
166
}
158
167
168
+ let cursor_fields = cursor_fields
169
+ . iter ( )
170
+ . map ( |f| Self :: prefix_field ( f, join_prefix) )
171
+ . collect :: < Vec < _ > > ( ) ;
159
172
let cursor_values = cursor. split ( ) ;
160
173
161
174
let result = ( 0 ..cursor_values. len ( ) )
@@ -186,6 +199,7 @@ pub trait QueryParamsBuilder {
186
199
query_builder : & mut QueryBuilder < Postgres > ,
187
200
pagination : & QueryPagination ,
188
201
cursor_fields : & [ & str ] ,
202
+ join_prefix : Option < & str > ,
189
203
) {
190
204
let order_by: OrderBy ;
191
205
let limit: i32 ;
@@ -206,7 +220,8 @@ pub trait QueryParamsBuilder {
206
220
}
207
221
}
208
222
209
- let order_by_sql = Self :: order_by_statement ( cursor_fields, order_by) ;
223
+ let order_by_sql =
224
+ Self :: order_by_statement ( cursor_fields, order_by, join_prefix) ;
210
225
query_builder. push ( order_by_sql) ;
211
226
query_builder. push ( format ! ( " LIMIT {limit}" ) ) ;
212
227
if let Some ( offset) = pagination. offset {
@@ -217,9 +232,11 @@ pub trait QueryParamsBuilder {
217
232
fn order_by_statement (
218
233
order_by_fields : & [ & str ] ,
219
234
order_by : OrderBy ,
235
+ join_prefix : Option < & str > ,
220
236
) -> String {
221
237
let fields = order_by_fields
222
238
. iter ( )
239
+ . map ( |field| Self :: prefix_field ( field, join_prefix) )
223
240
. map ( |field| format ! ( "{field} {order_by}" ) )
224
241
. collect :: < Vec < _ > > ( )
225
242
. join ( ", " ) ;
0 commit comments