@@ -61,7 +61,7 @@ impl CanyonMemory {
6161 #[ allow( clippy:: nonminimal_bool) ]
6262 pub async fn remember (
6363 datasource : & DatasourceConfig < ' static > ,
64- canyon_entities : & Vec < CanyonRegisterEntity < ' _ > > ,
64+ canyon_entities : & [ CanyonRegisterEntity < ' _ > ] ,
6565 ) -> Self {
6666 // Creates the memory table if not exists
6767 Self :: create_memory ( datasource. name , & datasource. properties . db_type ) . await ;
@@ -90,18 +90,24 @@ impl CanyonMemory {
9090 renamed_entities : HashMap :: new ( ) ,
9191 } ;
9292 Self :: find_canyon_entity_annotated_structs ( & mut mem, canyon_entities) . await ;
93-
93+
9494 let mut updates = Vec :: new ( ) ;
9595
96- for _struct in & mem. memory { // For every program entity detected
97- let already_in_db = db_rows. iter ( ) . find ( |el|
98- el. filepath == _struct. filepath || el. struct_name == _struct. struct_name || el. declared_table_name == _struct. declared_table_name
99- ) ;
96+ for _struct in & mem. memory {
97+ // For every program entity detected
98+ let already_in_db = db_rows. iter ( ) . find ( |el| {
99+ el. filepath == _struct. filepath
100+ || el. struct_name == _struct. struct_name
101+ || el. declared_table_name == _struct. declared_table_name
102+ } ) ;
100103
101104 if let Some ( old) = already_in_db {
102- if !( old. filepath == _struct. filepath && old. struct_name == _struct. struct_name && old. declared_table_name == _struct. declared_table_name ) {
105+ if !( old. filepath == _struct. filepath
106+ && old. struct_name == _struct. struct_name
107+ && old. declared_table_name == _struct. declared_table_name )
108+ {
103109 updates. push ( old. struct_name ) ;
104- let stmt = format ! (
110+ let stmt = format ! (
105111 "UPDATE canyon_memory SET filepath = '{}', struct_name = '{}', declared_table_name = '{}' \
106112 WHERE id = {}",
107113 _struct. filepath, _struct. struct_name, _struct. declared_table_name, old. id
@@ -121,7 +127,6 @@ impl CanyonMemory {
121127 }
122128
123129 if already_in_db. is_none ( ) {
124- println ! ( "\t Insert action for: {_struct:?}" ) ;
125130 let stmt = format ! (
126131 "INSERT INTO canyon_memory (filepath, struct_name, declared_table_name) \
127132 VALUES ('{}', '{}', '{}')",
@@ -139,7 +144,13 @@ impl CanyonMemory {
139144 . any ( |entity| entity. struct_name == db_row. struct_name )
140145 && !updates. contains ( & db_row. struct_name )
141146 {
142- save_canyon_memory_query ( format ! ( "DELETE FROM canyon_memory WHERE struct_name = '{}'" , db_row. struct_name) , datasource. name ) ;
147+ save_canyon_memory_query (
148+ format ! (
149+ "DELETE FROM canyon_memory WHERE struct_name = '{}'" ,
150+ db_row. struct_name
151+ ) ,
152+ datasource. name ,
153+ ) ;
143154 }
144155 }
145156 mem
@@ -219,15 +230,10 @@ impl CanyonMemory {
219230 }
220231}
221232
222-
223- fn save_canyon_memory_query < ' a > ( stmt : String , ds_name : & ' static str ) {
233+ fn save_canyon_memory_query ( stmt : String , ds_name : & ' static str ) {
224234 use crate :: CM_QUERIES_TO_EXECUTE ;
225235
226- if CM_QUERIES_TO_EXECUTE
227- . lock ( )
228- . unwrap ( )
229- . contains_key ( ds_name)
230- {
236+ if CM_QUERIES_TO_EXECUTE . lock ( ) . unwrap ( ) . contains_key ( ds_name) {
231237 CM_QUERIES_TO_EXECUTE
232238 . lock ( )
233239 . unwrap ( )
@@ -240,7 +246,7 @@ fn save_canyon_memory_query<'a>(stmt: String, ds_name: &'static str) {
240246 . unwrap ( )
241247 . insert ( ds_name, vec ! [ stmt] ) ;
242248 }
243- }
249+ }
244250
245251/// Represents a single row from the `canyon_memory` table
246252#[ derive( Debug ) ]
0 commit comments