Skip to content

Commit

Permalink
Format fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Oyelowo committed Oct 5, 2023
1 parent f5270a5 commit 1de6dd5
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions query-builder/src/statements/for_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub struct ForStatementData {
errors: ErrorList,
}


pub struct ForParam(Vec<Param>);

impl From<Vec<Param>> for ForParam {
Expand Down Expand Up @@ -69,7 +68,7 @@ impl From<&Param> for ForParam {
///
/// let ref person_table = Table::from("person");
/// let ref user_name = Field::from("user_name");
///
///
/// for_!((name in vec!["Oyelowo", "Oyedayo"]) {
/// select(All).from(person_table).where_(user_name.eq(name));
/// select(All).from(person_table).where_(user_name.eq(name));
Expand Down Expand Up @@ -108,7 +107,7 @@ pub use for_loop as for_;
/// ```
/// use surreal_query_builder as surreal_orm;
/// use surreal_orm::{*, statements::{select, for_}};
///
///
/// let ref __name = Param::new("name");
/// let ref person_table = Table::from("person");
/// let ref user_name = Field::from("user_name");
Expand Down Expand Up @@ -243,8 +242,14 @@ impl fmt::Display for ForLoopStatement {
#[cfg(test)]
mod tests {
use super::*;
use crate::{statements::{if_, select::{select, select_value}}, *};

use crate::{
statements::{
if_,
select::{select, select_value},
},
*,
};

#[test]
fn test_for_macro() {
let ref person_table = Table::from("person");
Expand Down Expand Up @@ -280,7 +285,7 @@ mod tests {
insta::assert_snapshot!(for_loop.fine_tune_params());
insta::assert_snapshot!(for_loop.to_raw().build());
}

#[test]
fn test_for_macro_and_block_macro() {
let ref person_table = Table::from("person");
Expand All @@ -290,8 +295,8 @@ mod tests {
FOR (__name IN vec!["Oyelowo", "Oyedayo"]) {
select(All).from(person_table).where_(user_name.eq(__name));
select(All).from(person_table).where_(user_name.eq(__name));
for_!((__moniker IN select_value(user_name).from(person_table)) {

for_!((__moniker IN select_value(user_name).from(person_table)) {
select(All).from(person_table).where_(user_name.eq(__moniker));
select(All).from(person_table).where_(user_name.eq(__name));
});
Expand All @@ -302,47 +307,46 @@ mod tests {
});

};

FOR (__name IN vec!["Oyelowo", "Oyedayo"]) {
select(All).from(person_table).where_(user_name.eq(__name));
select(All).from(person_table).where_(user_name.eq(__name));
};

FOR (__name IN vec!["Oyelowo", "Oyedayo"]) {
select(All).from(person_table).where_(user_name.eq(__name));
select(All).from(person_table).where_(user_name.eq(__name));
};

if_(__name.eq("Oyelowo")).then(6).end();


};
for_!((__name in vec!["Oyelowo"]) {
for_!((__name in vec!["Oyelowo"]) {
select(All).from(person_table).where_(user_name.eq(__name));
select(All).from(person_table).where_(user_name.eq(__name));

for_!((__name in vec!["Oyelowo"]) {
select(All).from(person_table).where_(user_name.eq(__name));
select(All).from(person_table).where_(user_name.eq(__name));

for_!((__name in vec!["Oyelowo"]) {
for_!((__name in vec!["Oyelowo"]) {
select(All).from(person_table).where_(user_name.eq(__name));
select(All).from(person_table).where_(user_name.eq(__name));
});

for_!((__name in vec!["Oyelowo"]) {
select(All).from(person_table).where_(user_name.eq(__name));
select(All).from(person_table).where_(user_name.eq(__name));
});

for_!((__name in vec!["Oyelowo"]) {
select(All).from(person_table).where_(user_name.eq(__name));
select(All).from(person_table).where_(user_name.eq(__name));
});

for_!((__name in vec!["Oyelowo"]) {
select(All).from(person_table).where_(user_name.eq(__name));
select(All).from(person_table).where_(user_name.eq(__name));
});

});
});

insta::assert_snapshot!(for_loop.fine_tune_params());
insta::assert_snapshot!(for_loop.to_raw().build());
}



#[test]
fn test_for_in_block() {
let ref __name = Param::new("name");
Expand Down

0 comments on commit 1de6dd5

Please sign in to comment.