@@ -32,15 +32,10 @@ impl<S: Storage> Database<S> {
3232 /// database.create_table::<User>().unwrap();
3333 /// ```
3434 pub fn create_table < M : Model > ( & self ) -> Result < ( ) , DatabaseError > {
35- self . execute (
36- M :: create_table_statement ( ) ,
37- Vec :: < ( & ' static str , DataValue ) > :: new ( ) ,
38- ) ?
39- . done ( ) ?;
35+ self . execute ( M :: create_table_statement ( ) , & [ ] ) ?. done ( ) ?;
4036
4137 for statement in M :: create_index_statements ( ) {
42- self . execute ( statement, Vec :: < ( & ' static str , DataValue ) > :: new ( ) ) ?
43- . done ( ) ?;
38+ self . execute ( statement, & [ ] ) ?. done ( ) ?;
4439 }
4540
4641 Ok ( ( ) )
@@ -52,15 +47,11 @@ impl<S: Storage> Database<S> {
5247 /// schema initialization should stay idempotent. Secondary indexes declared
5348 /// with `#[model(index)]` are created with `IF NOT EXISTS` as well.
5449 pub fn create_table_if_not_exists < M : Model > ( & self ) -> Result < ( ) , DatabaseError > {
55- self . execute (
56- M :: create_table_if_not_exists_statement ( ) ,
57- Vec :: < ( & ' static str , DataValue ) > :: new ( ) ,
58- ) ?
59- . done ( ) ?;
50+ self . execute ( M :: create_table_if_not_exists_statement ( ) , & [ ] ) ?
51+ . done ( ) ?;
6052
6153 for statement in M :: create_index_if_not_exists_statements ( ) {
62- self . execute ( statement, Vec :: < ( & ' static str , DataValue ) > :: new ( ) ) ?
63- . done ( ) ?;
54+ self . execute ( statement, & [ ] ) ?. done ( ) ?;
6455 }
6556
6657 Ok ( ( ) )
@@ -279,8 +270,7 @@ impl<S: Storage> Database<S> {
279270 }
280271
281272 for statement in M :: create_index_if_not_exists_statements ( ) {
282- self . execute ( statement, Vec :: < ( & ' static str , DataValue ) > :: new ( ) ) ?
283- . done ( ) ?;
273+ self . execute ( statement, & [ ] ) ?. done ( ) ?;
284274 }
285275
286276 Ok ( ( ) )
@@ -294,17 +284,15 @@ impl<S: Storage> Database<S> {
294284 let sql = :: std:: format!( "drop index {}.{}" , M :: table_name( ) , index_name) ;
295285 let statement = crate :: db:: prepare ( & sql) ?;
296286
297- self . execute ( & statement, Vec :: < ( & ' static str , DataValue ) > :: new ( ) ) ?
298- . done ( )
287+ self . execute ( & statement, & [ ] ) ?. done ( )
299288 }
300289
301290 /// Drops a non-primary-key model index by name if it exists.
302291 pub fn drop_index_if_exists < M : Model > ( & self , index_name : & str ) -> Result < ( ) , DatabaseError > {
303292 let sql = :: std:: format!( "drop index if exists {}.{}" , M :: table_name( ) , index_name) ;
304293 let statement = crate :: db:: prepare ( & sql) ?;
305294
306- self . execute ( & statement, Vec :: < ( & ' static str , DataValue ) > :: new ( ) ) ?
307- . done ( )
295+ self . execute ( & statement, & [ ] ) ?. done ( )
308296 }
309297
310298 /// Drops the model table.
@@ -328,22 +316,15 @@ impl<S: Storage> Database<S> {
328316 /// database.drop_table::<User>().unwrap();
329317 /// ```
330318 pub fn drop_table < M : Model > ( & self ) -> Result < ( ) , DatabaseError > {
331- self . execute (
332- M :: drop_table_statement ( ) ,
333- Vec :: < ( & ' static str , DataValue ) > :: new ( ) ,
334- ) ?
335- . done ( )
319+ self . execute ( M :: drop_table_statement ( ) , & [ ] ) ?. done ( )
336320 }
337321
338322 /// Drops the model table if it exists.
339323 ///
340324 /// This variant is convenient for cleanup code that should succeed even if
341325 /// the table was already removed.
342326 pub fn drop_table_if_exists < M : Model > ( & self ) -> Result < ( ) , DatabaseError > {
343- self . execute (
344- M :: drop_table_if_exists_statement ( ) ,
345- Vec :: < ( & ' static str , DataValue ) > :: new ( ) ,
346- ) ?
347- . done ( )
327+ self . execute ( M :: drop_table_if_exists_statement ( ) , & [ ] ) ?
328+ . done ( )
348329 }
349330}
0 commit comments