@@ -9,7 +9,7 @@ use crate::errors::{ErrorKind, ErrorLang, ErrorType, ErrorVm};
99use crate :: functions:: { FunDef , Param } ;
1010use crate :: operator:: { Op , OpCmp , OpLogic , OpQuery } ;
1111use crate :: types:: Ty ;
12- use spacetimedb_lib:: Identity ;
12+ use spacetimedb_lib:: { Address , Identity } ;
1313use spacetimedb_primitives:: * ;
1414use spacetimedb_sats:: algebraic_type:: AlgebraicType ;
1515use spacetimedb_sats:: algebraic_value:: AlgebraicValue ;
@@ -476,9 +476,9 @@ pub enum CrudExpr {
476476}
477477
478478impl CrudExpr {
479- pub fn optimize ( self ) -> Self {
479+ pub fn optimize ( self , db : Option < Address > ) -> Self {
480480 match self {
481- CrudExpr :: Query ( x) => CrudExpr :: Query ( x. optimize ( ) ) ,
481+ CrudExpr :: Query ( x) => CrudExpr :: Query ( x. optimize ( db ) ) ,
482482 _ => self ,
483483 }
484484 }
@@ -1129,7 +1129,7 @@ impl QueryExpr {
11291129 //
11301130 // Ex. SELECT Left.* FROM Left JOIN Right ON Left.id = Right.id ...
11311131 // where `Left` has an index defined on `id`.
1132- fn try_index_join ( mut query : QueryExpr ) -> QueryExpr {
1132+ fn try_index_join ( mut query : QueryExpr , _db : Option < Address > ) -> QueryExpr {
11331133 // We expect 2 and only 2 operations - a join followed by a wildcard projection.
11341134 if query. query . len ( ) != 2 {
11351135 return query;
@@ -1325,7 +1325,7 @@ impl QueryExpr {
13251325 } )
13261326 }
13271327
1328- pub fn optimize ( self ) -> Self {
1328+ pub fn optimize ( self , db : Option < Address > ) -> Self {
13291329 let mut q = Self {
13301330 source : self . source . clone ( ) ,
13311331 query : Vec :: with_capacity ( self . query . len ( ) ) ,
@@ -1350,11 +1350,11 @@ impl QueryExpr {
13501350 Query :: Select ( op) => {
13511351 q = Self :: optimize_select ( q, op, & tables) ;
13521352 }
1353- Query :: JoinInner ( join) => q = q. with_join_inner ( join. rhs . optimize ( ) , join. col_lhs , join. col_rhs ) ,
1353+ Query :: JoinInner ( join) => q = q. with_join_inner ( join. rhs . optimize ( db ) , join. col_lhs , join. col_rhs ) ,
13541354 _ => q. query . push ( query) ,
13551355 } ;
13561356 }
1357- Self :: try_index_join ( q)
1357+ Self :: try_index_join ( q, db )
13581358 }
13591359}
13601360
0 commit comments