@@ -537,7 +537,6 @@ struct QueryValue<'a>(&'a Value, &'a ColumnType);
537
537
538
538
impl < ' a > QueryFragment < Pg > for QueryValue < ' a > {
539
539
fn walk_ast < ' b > ( & ' b self , mut out : AstPass < ' _ , ' b , Pg > ) -> QueryResult < ( ) > {
540
- let out = & mut out;
541
540
out. unsafe_to_cache_prepared ( ) ;
542
541
let column_type = self . 1 ;
543
542
@@ -1105,12 +1104,12 @@ impl<'a> QueryFilter<'a> {
1105
1104
. expect ( "the constructor already checked that all attribute names are valid" )
1106
1105
}
1107
1106
1108
- fn binary_op (
1109
- & self ,
1110
- filters : & [ EntityFilter ] ,
1107
+ fn binary_op < ' b > (
1108
+ & ' b self ,
1109
+ filters : & ' b [ EntityFilter ] ,
1111
1110
op : & str ,
1112
1111
on_empty : & str ,
1113
- mut out : AstPass < Pg > ,
1112
+ mut out : AstPass < ' _ , ' b , Pg > ,
1114
1113
) -> QueryResult < ( ) > {
1115
1114
if !filters. is_empty ( ) {
1116
1115
out. push_sql ( "(" ) ;
@@ -1127,13 +1126,13 @@ impl<'a> QueryFilter<'a> {
1127
1126
Ok ( ( ) )
1128
1127
}
1129
1128
1130
- fn contains (
1131
- & self ,
1129
+ fn contains < ' b > (
1130
+ & ' b self ,
1132
1131
attribute : & Attribute ,
1133
- value : & Value ,
1132
+ value : & ' b Value ,
1134
1133
negated : bool ,
1135
1134
strict : bool ,
1136
- mut out : AstPass < Pg > ,
1135
+ mut out : AstPass < ' _ , ' b , Pg > ,
1137
1136
) -> QueryResult < ( ) > {
1138
1137
let column = self . column ( attribute) ;
1139
1138
let operation = match ( strict, negated) {
@@ -1199,12 +1198,12 @@ impl<'a> QueryFilter<'a> {
1199
1198
Ok ( ( ) )
1200
1199
}
1201
1200
1202
- fn equals (
1203
- & self ,
1201
+ fn equals < ' b > (
1202
+ & ' b self ,
1204
1203
attribute : & Attribute ,
1205
1204
value : & Value ,
1206
1205
op : Comparison ,
1207
- mut out : AstPass < Pg > ,
1206
+ mut out : AstPass < ' _ , ' b , Pg > ,
1208
1207
) -> QueryResult < ( ) > {
1209
1208
let column = self . column ( attribute) ;
1210
1209
@@ -1480,14 +1479,14 @@ pub struct FindQuery<'a> {
1480
1479
}
1481
1480
1482
1481
impl < ' a > QueryFragment < Pg > for FindQuery < ' a > {
1483
- fn walk_ast ( & self , mut out : AstPass < Pg > ) -> QueryResult < ( ) > {
1482
+ fn walk_ast < ' b > ( & ' b self , mut out : AstPass < ' _ , ' b , Pg > ) -> QueryResult < ( ) > {
1484
1483
out. unsafe_to_cache_prepared ( ) ;
1485
1484
1486
1485
// Generate
1487
1486
// select '..' as entity, to_jsonb(e.*) as data
1488
1487
// from schema.table e where id = $1
1489
1488
out. push_sql ( "select " ) ;
1490
- out. push_bind_param :: < Text , _ > ( & self . table . object . as_str ( ) ) ?;
1489
+ out. push_bind_param :: < Text , _ > ( self . table . object . as_str ( ) ) ?;
1491
1490
out. push_sql ( " as entity, to_jsonb(e.*) as data\n " ) ;
1492
1491
out. push_sql ( " from " ) ;
1493
1492
out. push_sql ( self . table . qualified_name . as_str ( ) ) ;
@@ -1534,7 +1533,7 @@ impl<'a> QueryFragment<Pg> for FindChangesQuery<'a> {
1534
1533
out. push_sql ( "\n union all\n " ) ;
1535
1534
}
1536
1535
out. push_sql ( "select " ) ;
1537
- out. push_bind_param :: < Text , _ > ( & table. object . as_str ( ) ) ?;
1536
+ out. push_bind_param :: < Text , _ > ( table. object . as_str ( ) ) ?;
1538
1537
out. push_sql ( " as entity, to_jsonb(e.*) as data\n " ) ;
1539
1538
out. push_sql ( " from " ) ;
1540
1539
out. push_sql ( table. qualified_name . as_str ( ) ) ;
@@ -1574,7 +1573,7 @@ pub struct FindPossibleDeletionsQuery<'a> {
1574
1573
}
1575
1574
1576
1575
impl < ' a > QueryFragment < Pg > for FindPossibleDeletionsQuery < ' a > {
1577
- fn walk_ast ( & self , mut out : AstPass < Pg > ) -> QueryResult < ( ) > {
1576
+ fn walk_ast < ' b > ( & ' b self , mut out : AstPass < ' _ , ' b , Pg > ) -> QueryResult < ( ) > {
1578
1577
let out = & mut out;
1579
1578
out. unsafe_to_cache_prepared ( ) ;
1580
1579
@@ -1583,7 +1582,7 @@ impl<'a> QueryFragment<Pg> for FindPossibleDeletionsQuery<'a> {
1583
1582
out. push_sql ( "\n union all\n " ) ;
1584
1583
}
1585
1584
out. push_sql ( "select " ) ;
1586
- out. push_bind_param :: < Text , _ > ( & table. object . as_str ( ) ) ?;
1585
+ out. push_bind_param :: < Text , _ > ( table. object . as_str ( ) ) ?;
1587
1586
out. push_sql ( " as entity, " ) ;
1588
1587
if table. has_causality_region {
1589
1588
out. push_sql ( "causality_region, " ) ;
@@ -1639,7 +1638,7 @@ impl<'a> QueryFragment<Pg> for FindManyQuery<'a> {
1639
1638
out. push_sql ( "\n union all\n " ) ;
1640
1639
}
1641
1640
out. push_sql ( "select " ) ;
1642
- out. push_bind_param :: < Text , _ > ( & table. object . as_str ( ) ) ?;
1641
+ out. push_bind_param :: < Text , _ > ( table. object . as_str ( ) ) ?;
1643
1642
out. push_sql ( " as entity, to_jsonb(e.*) as data\n " ) ;
1644
1643
out. push_sql ( " from " ) ;
1645
1644
out. push_sql ( table. qualified_name . as_str ( ) ) ;
@@ -1696,7 +1695,7 @@ impl<'a> QueryFragment<Pg> for FindDerivedQuery<'a> {
1696
1695
// select '..' as entity, to_jsonb(e.*) as data
1697
1696
// from schema.table e where field = $1
1698
1697
out. push_sql ( "select " ) ;
1699
- out. push_bind_param :: < Text , _ > ( & self . table . object . as_str ( ) ) ?;
1698
+ out. push_bind_param :: < Text , _ > ( self . table . object . as_str ( ) ) ?;
1700
1699
out. push_sql ( " as entity, to_jsonb(e.*) as data\n " ) ;
1701
1700
out. push_sql ( " from " ) ;
1702
1701
out. push_sql ( self . table . qualified_name . as_str ( ) ) ;
@@ -1876,7 +1875,7 @@ impl<'a> InsertQuery<'a> {
1876
1875
}
1877
1876
1878
1877
impl < ' a > QueryFragment < Pg > for InsertQuery < ' a > {
1879
- fn walk_ast ( & self , mut out : AstPass < Pg > ) -> QueryResult < ( ) > {
1878
+ fn walk_ast < ' b > ( & ' b self , mut out : AstPass < ' _ , ' b , Pg > ) -> QueryResult < ( ) > {
1880
1879
let out = & mut out;
1881
1880
out. unsafe_to_cache_prepared ( ) ;
1882
1881
@@ -1984,7 +1983,7 @@ impl<'a> QueryFragment<Pg> for ConflictingEntityQuery<'a> {
1984
1983
out. push_sql ( "\n union all\n " ) ;
1985
1984
}
1986
1985
out. push_sql ( "select " ) ;
1987
- out. push_bind_param :: < Text , _ > ( & table. object . as_str ( ) ) ?;
1986
+ out. push_bind_param :: < Text , _ > ( table. object . as_str ( ) ) ?;
1988
1987
out. push_sql ( " as entity from " ) ;
1989
1988
out. push_sql ( table. qualified_name . as_str ( ) ) ;
1990
1989
out. push_sql ( " where id = " ) ;
@@ -2073,17 +2072,17 @@ enum ParentLimit<'a> {
2073
2072
}
2074
2073
2075
2074
impl < ' a > ParentLimit < ' a > {
2076
- fn filter ( & self , mut out : AstPass < ' _ , ' a , Pg > ) {
2075
+ fn filter ( & self , out : & mut AstPass < ' _ , ' a , Pg > ) {
2077
2076
match self {
2078
2077
ParentLimit :: Outer => out. push_sql ( " and q.id = p.id" ) ,
2079
2078
ParentLimit :: Ranked ( _, _) => ( ) ,
2080
2079
}
2081
2080
}
2082
2081
2083
- fn restrict < ' b > ( & ' b self , mut out : AstPass < ' _ , ' b , Pg > ) -> QueryResult < ( ) > {
2082
+ fn restrict ( & ' a self , out : & mut AstPass < ' _ , ' a , Pg > ) -> QueryResult < ( ) > {
2084
2083
if let ParentLimit :: Ranked ( sort_key, range) = self {
2085
2084
out. push_sql ( " " ) ;
2086
- sort_key. order_by ( & mut out, false ) ?;
2085
+ sort_key. order_by ( out, false ) ?;
2087
2086
range. walk_ast ( out. reborrow ( ) ) ?;
2088
2087
}
2089
2088
Ok ( ( ) )
@@ -2177,7 +2176,7 @@ impl<'a> FilterWindow<'a> {
2177
2176
fn children_type_a < ' b > (
2178
2177
& ' b self ,
2179
2178
column : & Column ,
2180
- limit : ParentLimit < ' b > ,
2179
+ limit : & ' b ParentLimit < ' _ > ,
2181
2180
block : BlockNumber ,
2182
2181
out : & mut AstPass < ' _ , ' b , Pg > ,
2183
2182
) -> QueryResult < ( ) > {
@@ -2202,20 +2201,20 @@ impl<'a> FilterWindow<'a> {
2202
2201
out. push_sql ( self . table . qualified_name . as_str ( ) ) ;
2203
2202
out. push_sql ( " c where " ) ;
2204
2203
BlockRangeColumn :: new ( self . table , "c." , block) . contains ( out, false ) ?;
2205
- limit. filter ( out. reborrow ( ) ) ;
2204
+ limit. filter ( out) ;
2206
2205
out. push_sql ( " and p.id = any(c." ) ;
2207
2206
out. push_identifier ( column. name . as_str ( ) ) ?;
2208
2207
out. push_sql ( ")" ) ;
2209
2208
self . and_filter ( out) ?;
2210
- limit. restrict ( out. reborrow ( ) ) ?;
2209
+ limit. restrict ( out) ?;
2211
2210
out. push_sql ( ") c" ) ;
2212
2211
Ok ( ( ) )
2213
2212
}
2214
2213
2215
2214
fn child_type_a < ' b > (
2216
2215
& ' b self ,
2217
2216
column : & Column ,
2218
- limit : ParentLimit < ' b > ,
2217
+ limit : & ' b ParentLimit < ' _ > ,
2219
2218
block : BlockNumber ,
2220
2219
out : & mut AstPass < ' _ , ' b , Pg > ,
2221
2220
) -> QueryResult < ( ) > {
@@ -2238,7 +2237,7 @@ impl<'a> FilterWindow<'a> {
2238
2237
out. push_sql ( self . table . qualified_name . as_str ( ) ) ;
2239
2238
out. push_sql ( " c where " ) ;
2240
2239
BlockRangeColumn :: new ( self . table , "c." , block) . contains ( out, false ) ?;
2241
- limit. filter ( out. reborrow ( ) ) ;
2240
+ limit. filter ( out) ;
2242
2241
out. push_sql ( " and c." ) ;
2243
2242
out. push_identifier ( column. name . as_str ( ) ) ?;
2244
2243
out. push_sql ( " @> array[p.id]" ) ;
@@ -2256,7 +2255,7 @@ impl<'a> FilterWindow<'a> {
2256
2255
fn children_type_b < ' b > (
2257
2256
& ' b self ,
2258
2257
column : & Column ,
2259
- limit : ParentLimit < ' b > ,
2258
+ limit : & ' b ParentLimit < ' _ > ,
2260
2259
block : BlockNumber ,
2261
2260
out : & mut AstPass < ' _ , ' b , Pg > ,
2262
2261
) -> QueryResult < ( ) > {
@@ -2281,19 +2280,19 @@ impl<'a> FilterWindow<'a> {
2281
2280
out. push_sql ( self . table . qualified_name . as_str ( ) ) ;
2282
2281
out. push_sql ( " c where " ) ;
2283
2282
BlockRangeColumn :: new ( self . table , "c." , block) . contains ( out, false ) ?;
2284
- limit. filter ( out. reborrow ( ) ) ;
2283
+ limit. filter ( out) ;
2285
2284
out. push_sql ( " and p.id = c." ) ;
2286
2285
out. push_identifier ( column. name . as_str ( ) ) ?;
2287
2286
self . and_filter ( out) ?;
2288
- limit. restrict ( out. reborrow ( ) ) ?;
2287
+ limit. restrict ( out) ?;
2289
2288
out. push_sql ( ") c" ) ;
2290
2289
Ok ( ( ) )
2291
2290
}
2292
2291
2293
2292
fn child_type_b < ' b > (
2294
2293
& ' b self ,
2295
2294
column : & Column ,
2296
- limit : ParentLimit < ' b > ,
2295
+ limit : & ' b ParentLimit < ' _ > ,
2297
2296
block : BlockNumber ,
2298
2297
out : & mut AstPass < ' _ , ' b , Pg > ,
2299
2298
) -> QueryResult < ( ) > {
@@ -2311,7 +2310,7 @@ impl<'a> FilterWindow<'a> {
2311
2310
out. push_sql ( self . table . qualified_name . as_str ( ) ) ;
2312
2311
out. push_sql ( " c where " ) ;
2313
2312
BlockRangeColumn :: new ( self . table , "c." , block) . contains ( out, false ) ?;
2314
- limit. filter ( out. reborrow ( ) ) ;
2313
+ limit. filter ( out) ;
2315
2314
out. push_sql ( " and p.id = c." ) ;
2316
2315
out. push_identifier ( column. name . as_str ( ) ) ?;
2317
2316
self . and_filter ( out) ?;
@@ -2322,7 +2321,7 @@ impl<'a> FilterWindow<'a> {
2322
2321
fn children_type_c < ' b > (
2323
2322
& ' b self ,
2324
2323
child_ids : & ' b [ IdList ] ,
2325
- limit : ParentLimit < ' b > ,
2324
+ limit : & ' b ParentLimit < ' _ > ,
2326
2325
block : BlockNumber ,
2327
2326
out : & mut AstPass < ' _ , ' b , Pg > ,
2328
2327
) -> QueryResult < ( ) > {
@@ -2366,10 +2365,10 @@ impl<'a> FilterWindow<'a> {
2366
2365
out. push_sql ( self . table . qualified_name . as_str ( ) ) ;
2367
2366
out. push_sql ( " c where " ) ;
2368
2367
BlockRangeColumn :: new ( self . table , "c." , block) . contains ( out, true ) ;
2369
- limit. filter ( out. reborrow ( ) ) ;
2368
+ limit. filter ( out) ;
2370
2369
out. push_sql ( " and c.id = any(p.child_ids)" ) ;
2371
2370
self . and_filter ( out) ?;
2372
- limit. restrict ( out. reborrow ( ) ) ?;
2371
+ limit. restrict ( out) ?;
2373
2372
out. push_sql ( ") c" ) ;
2374
2373
} else {
2375
2374
// Generate
@@ -2390,7 +2389,7 @@ impl<'a> FilterWindow<'a> {
2390
2389
fn child_type_d < ' b > (
2391
2390
& ' b self ,
2392
2391
child_ids : & ' b IdList ,
2393
- limit : ParentLimit < ' b > ,
2392
+ limit : & ' b ParentLimit < ' _ > ,
2394
2393
block : BlockNumber ,
2395
2394
out : & mut AstPass < ' _ , ' b , Pg > ,
2396
2395
) -> QueryResult < ( ) > {
@@ -2408,7 +2407,7 @@ impl<'a> FilterWindow<'a> {
2408
2407
out. push_sql ( self . table . qualified_name . as_str ( ) ) ;
2409
2408
out. push_sql ( " c where " ) ;
2410
2409
BlockRangeColumn :: new ( self . table , "c." , block) . contains ( out, true ) ?;
2411
- limit. filter ( out. reborrow ( ) ) ;
2410
+ limit. filter ( out) ;
2412
2411
2413
2412
// Include a constraint on the child IDs as a set if the size of the set
2414
2413
// is below the threshold set by environment variable. Set it to
@@ -2431,7 +2430,7 @@ impl<'a> FilterWindow<'a> {
2431
2430
2432
2431
fn children < ' b > (
2433
2432
& ' b self ,
2434
- limit : ParentLimit < ' b > ,
2433
+ limit : & ' b ParentLimit < ' _ > ,
2435
2434
block : BlockNumber ,
2436
2435
out : & mut AstPass < ' _ , ' b , Pg > ,
2437
2436
) -> QueryResult < ( ) > {
@@ -2473,7 +2472,7 @@ impl<'a> FilterWindow<'a> {
2473
2472
out. push_sql ( "' as entity, c.id, c.vid, p.id::text as " ) ;
2474
2473
out. push_sql ( & * PARENT_ID ) ;
2475
2474
sort_key. select ( & mut out, SelectStatementLevel :: InnerStatement ) ?;
2476
- self . children ( ParentLimit :: Outer , block, & mut out)
2475
+ self . children ( & ParentLimit :: Outer , block, & mut out)
2477
2476
}
2478
2477
2479
2478
/// Collect all the parent id's from all windows
@@ -3646,14 +3645,18 @@ impl<'a> SortKey<'a> {
3646
3645
Ok ( ( ) )
3647
3646
}
3648
3647
3649
- fn add_child ( & self , block : BlockNumber , out : & mut AstPass < Pg > ) -> QueryResult < ( ) > {
3650
- fn add (
3651
- block : BlockNumber ,
3648
+ fn add_child < ' b > (
3649
+ & self ,
3650
+ block : & ' b BlockNumber ,
3651
+ out : & mut AstPass < ' _ , ' b , Pg > ,
3652
+ ) -> QueryResult < ( ) > {
3653
+ fn add < ' b > (
3654
+ block : & ' b BlockNumber ,
3652
3655
child_table : & Table ,
3653
3656
child_column : & Column ,
3654
3657
parent_column : & Column ,
3655
3658
prefix : & str ,
3656
- out : & mut AstPass < Pg > ,
3659
+ out : & mut AstPass < ' _ , ' b , Pg > ,
3657
3660
) -> QueryResult < ( ) > {
3658
3661
out. push_sql ( " left join " ) ;
3659
3662
out. push_sql ( child_table. qualified_name . as_str ( ) ) ;
@@ -3693,7 +3696,7 @@ impl<'a> SortKey<'a> {
3693
3696
out. push_sql ( "." ) ;
3694
3697
out. push_identifier ( BLOCK_RANGE_COLUMN ) ?;
3695
3698
out. push_sql ( " @> " ) ;
3696
- out. push_bind_param :: < Integer , _ > ( & block) ?;
3699
+ out. push_bind_param :: < Integer , _ > ( block) ?;
3697
3700
out. push_sql ( ") " ) ;
3698
3701
3699
3702
Ok ( ( ) )
@@ -3855,7 +3858,7 @@ impl<'a> FilterQuery<'a> {
3855
3858
out. push_sql ( table. qualified_name . as_str ( ) ) ;
3856
3859
out. push_sql ( " c" ) ;
3857
3860
3858
- self . sort_key . add_child ( self . block , out) ?;
3861
+ self . sort_key . add_child ( & self . block , out) ?;
3859
3862
3860
3863
out. push_sql ( "\n where " ) ;
3861
3864
@@ -3926,7 +3929,7 @@ impl<'a> FilterQuery<'a> {
3926
3929
out. push_sql ( "select c.*, p.id::text as " ) ;
3927
3930
out. push_sql ( & * PARENT_ID ) ;
3928
3931
window. children (
3929
- ParentLimit :: Ranked ( & self . sort_key , & self . range ) ,
3932
+ & ParentLimit :: Ranked ( & self . sort_key , & self . range ) ,
3930
3933
self . block ,
3931
3934
& mut out,
3932
3935
) ?;
0 commit comments