Skip to content

Commit 678d71e

Browse files
committed
chore: codefmt
1 parent ceafe0b commit 678d71e

3 files changed

Lines changed: 13 additions & 45 deletions

File tree

src/macros/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,6 @@ macro_rules! from_tuple {
6565
};
6666
}
6767

68-
#[macro_export]
69-
macro_rules! implement_from_tuple {
70-
($($tokens:tt)*) => {
71-
$crate::from_tuple!($($tokens)*);
72-
};
73-
}
74-
7568
/// # Examples
7669
///
7770
/// ```

src/orm/ddl.rs

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/orm/mod.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -976,10 +976,7 @@ where
976976

977977
fn orm_analyze<E: StatementSource, M: Model>(executor: E) -> Result<(), DatabaseError> {
978978
executor
979-
.execute_statement(
980-
M::analyze_statement(),
981-
Vec::<(&'static str, DataValue)>::new(),
982-
)?
979+
.execute_statement(M::analyze_statement(), &[])?
983980
.done()
984981
}
985982

@@ -1017,9 +1014,6 @@ fn orm_list<E: StatementSource, M: Model>(
10171014
executor: E,
10181015
) -> Result<OrmIter<E::Iter, M>, DatabaseError> {
10191016
Ok(executor
1020-
.execute_statement(
1021-
M::select_statement(),
1022-
Vec::<(&'static str, DataValue)>::new(),
1023-
)?
1017+
.execute_statement(M::select_statement(), &[])?
10241018
.orm::<M>())
10251019
}

0 commit comments

Comments
 (0)