Skip to content

Commit

Permalink
Format Rust code using rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Mar 8, 2022
1 parent cb55a62 commit 6e16cb0
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ mod update;
mod values;

pub use column::{Column, DefaultValue, TypeDataLength, TypeFamily};
pub use compare::{Comparable, Compare, JsonCompare, JsonType};
#[cfg(feature = "postgresql")]
pub use compare::{LtreeCompare, LtreeQuery};
pub use compare::{Comparable, Compare, JsonCompare, JsonType};
pub use conditions::ConditionTree;
pub use conjunctive::Conjunctive;
pub use cte::{CommonTableExpression, IntoCommonTableExpression};
Expand Down
22 changes: 12 additions & 10 deletions src/tests/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2980,8 +2980,7 @@ async fn ltree_select_is_not_ancestor(api: &mut dyn TestApi) -> crate::Result<()

api.conn().insert(insert.into()).await?;

let select =
Select::from_table(&table).so_that(col!("path").ltree_is_not_ancestor(LtreeQuery::string("A.B")));
let select = Select::from_table(&table).so_that(col!("path").ltree_is_not_ancestor(LtreeQuery::string("A.B")));
let rows = api.conn().select(select).await?;

assert_eq!(rows.len(), 5);
Expand Down Expand Up @@ -3015,8 +3014,8 @@ async fn ltree_select_is_not_ancestor_any(api: &mut dyn TestApi) -> crate::Resul

api.conn().insert(insert.into()).await?;

let select =
Select::from_table(&table).so_that(col!("path").ltree_is_not_ancestor(LtreeQuery::array(vec!["A.B.C", "B.C.D"])));
let select = Select::from_table(&table)
.so_that(col!("path").ltree_is_not_ancestor(LtreeQuery::array(vec!["A.B.C", "B.C.D"])));
let rows = api.conn().select(select).await?;

assert_eq!(rows.len(), 2);
Expand Down Expand Up @@ -3112,8 +3111,7 @@ async fn ltree_select_is_not_descendant(api: &mut dyn TestApi) -> crate::Result<

api.conn().insert(insert.into()).await?;

let select =
Select::from_table(&table).so_that(col!("path").ltree_is_not_descendant(LtreeQuery::string("A.B")));
let select = Select::from_table(&table).so_that(col!("path").ltree_is_not_descendant(LtreeQuery::string("A.B")));
let rows = api.conn().select(select).await?;

assert_eq!(rows.len(), 5);
Expand Down Expand Up @@ -3217,7 +3215,8 @@ async fn ltree_select_match_any(api: &mut dyn TestApi) -> crate::Result<()> {

api.conn().insert(insert.into()).await?;

let select = Select::from_table(&table).so_that(col!("path").ltree_match(LtreeQuery::array(vec!["foo.baz|bar.!foo", "foo.*.foo"])));
let select = Select::from_table(&table)
.so_that(col!("path").ltree_match(LtreeQuery::array(vec!["foo.baz|bar.!foo", "foo.*.foo"])));
let rows = api.conn().select(select).await?;

assert_eq!(rows.len(), 7);
Expand Down Expand Up @@ -3255,7 +3254,8 @@ async fn ltree_select_not_match(api: &mut dyn TestApi) -> crate::Result<()> {

api.conn().insert(insert.into()).await?;

let select = Select::from_table(&table).so_that(col!("path").ltree_does_not_match(LtreeQuery::string("foo.*.baz|bar")));
let select =
Select::from_table(&table).so_that(col!("path").ltree_does_not_match(LtreeQuery::string("foo.*.baz|bar")));
let rows = api.conn().select(select).await?;

assert_eq!(rows.len(), 3);
Expand Down Expand Up @@ -3289,7 +3289,8 @@ async fn ltree_select_not_match_any(api: &mut dyn TestApi) -> crate::Result<()>

api.conn().insert(insert.into()).await?;

let select = Select::from_table(&table).so_that(col!("path").ltree_does_not_match(LtreeQuery::array(vec!["foo.*.baz|bar", "foo.b*.*"])));
let select = Select::from_table(&table)
.so_that(col!("path").ltree_does_not_match(LtreeQuery::array(vec!["foo.*.baz|bar", "foo.b*.*"])));
let rows = api.conn().select(select).await?;

assert_eq!(rows.len(), 1);
Expand Down Expand Up @@ -3355,7 +3356,8 @@ async fn ltree_select_not_match_fulltext(api: &mut dyn TestApi) -> crate::Result

api.conn().insert(insert.into()).await?;

let select = Select::from_table(&table).so_that(col!("path").ltree_does_not_match_fulltext(LtreeQuery::string("b* & !bar")));
let select =
Select::from_table(&table).so_that(col!("path").ltree_does_not_match_fulltext(LtreeQuery::string("b* & !bar")));
let rows = api.conn().select(select).await?;

assert_eq!(rows.len(), 6);
Expand Down
26 changes: 20 additions & 6 deletions src/visitor/mssql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ use super::Visitor;
use crate::prelude::{JsonExtract, JsonType};
use crate::{
ast::{
Column, Comparable, Expression, ExpressionKind, Insert, IntoRaw, Join, JoinData, Joinable,
LtreeQuery, Merge, OnConflict, Order, Ordering, Row, Table, TypeDataLength, TypeFamily,
Values,
Column, Comparable, Expression, ExpressionKind, Insert, IntoRaw, Join, JoinData, Joinable, LtreeQuery, Merge,
OnConflict, Order, Ordering, Row, Table, TypeDataLength, TypeFamily, Values,
},
error::{Error, ErrorKind},
prelude::{Aliasable, Average, Query},
Expand Down Expand Up @@ -646,12 +645,22 @@ impl<'a> Visitor<'a> for Mssql<'a> {
}

#[cfg(feature = "postgresql")]
fn visit_ltree_is_ancestor(&mut self, _left: Expression<'a>, _right: LtreeQuery<'a>, _not: bool) -> visitor::Result {
fn visit_ltree_is_ancestor(
&mut self,
_left: Expression<'a>,
_right: LtreeQuery<'a>,
_not: bool,
) -> visitor::Result {
unimplemented!("Ltree is not supported on MSSQL");
}

#[cfg(feature = "postgresql")]
fn visit_ltree_is_descendant(&mut self, _left: Expression<'a>, _right: LtreeQuery<'a>, _not: bool) -> visitor::Result {
fn visit_ltree_is_descendant(
&mut self,
_left: Expression<'a>,
_right: LtreeQuery<'a>,
_not: bool,
) -> visitor::Result {
unimplemented!("Ltree is not supported on MSSQL");
}

Expand All @@ -661,7 +670,12 @@ impl<'a> Visitor<'a> for Mssql<'a> {
}

#[cfg(feature = "postgresql")]
fn visit_ltree_match_fulltext(&mut self, _left: Expression<'a>, _right: LtreeQuery<'a>, _not: bool) -> visitor::Result {
fn visit_ltree_match_fulltext(
&mut self,
_left: Expression<'a>,
_right: LtreeQuery<'a>,
_not: bool,
) -> visitor::Result {
unimplemented!("Ltree is not supported on MSSQL");
}
}
Expand Down
21 changes: 18 additions & 3 deletions src/visitor/mysql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,22 @@ impl<'a> Visitor<'a> for Mysql<'a> {
}

#[cfg(feature = "postgresql")]
fn visit_ltree_is_ancestor(&mut self, _left: Expression<'a>, _right: LtreeQuery<'a>, _not: bool) -> visitor::Result {
fn visit_ltree_is_ancestor(
&mut self,
_left: Expression<'a>,
_right: LtreeQuery<'a>,
_not: bool,
) -> visitor::Result {
unimplemented!("Ltree is not supported on MySQL");
}

#[cfg(feature = "postgresql")]
fn visit_ltree_is_descendant(&mut self, _left: Expression<'a>, _right: LtreeQuery<'a>, _not: bool) -> visitor::Result {
fn visit_ltree_is_descendant(
&mut self,
_left: Expression<'a>,
_right: LtreeQuery<'a>,
_not: bool,
) -> visitor::Result {
unimplemented!("Ltree is not supported on MySQL");
}

Expand All @@ -524,7 +534,12 @@ impl<'a> Visitor<'a> for Mysql<'a> {
}

#[cfg(feature = "postgresql")]
fn visit_ltree_match_fulltext(&mut self, _left: Expression<'a>, _right: LtreeQuery<'a>, _not: bool) -> visitor::Result {
fn visit_ltree_match_fulltext(
&mut self,
_left: Expression<'a>,
_right: LtreeQuery<'a>,
_not: bool,
) -> visitor::Result {
unimplemented!("Ltree is not supported on MySQL");
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/visitor/postgres.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::error::Error;
use crate::error::ErrorKind::Unsupported;
use crate::{
ast::*,
visitor::{self, Visitor},
};
use std::fmt::{self, Write};
use crate::error::Error;
use crate::error::ErrorKind::Unsupported;

/// A visitor to generate queries for the PostgreSQL database.
///
Expand Down Expand Up @@ -497,7 +497,7 @@ impl<'a> Visitor<'a> for Postgres<'a> {
LtreeQuery::String(str) => {
self.write(" ~ ")?;
self.visit_parameterized(Value::text(str))?;
},
}
LtreeQuery::Array(query_path) => {
self.write(" ? ")?;

Expand Down Expand Up @@ -545,7 +545,7 @@ impl<'a> Visitor<'a> for Postgres<'a> {
}

Ok(())
},
}
LtreeQuery::Array(_) => Err(Error::builder(Unsupported("ltxtquery array".into())).build()),
}
}
Expand Down Expand Up @@ -1190,7 +1190,7 @@ mod tests {
// This should error due to arrays of ltxtqueries not being supported
let success = match Postgres::build(query) {
Err(_) => true,
_ => false
_ => false,
};

assert!(success)
Expand Down Expand Up @@ -1223,7 +1223,7 @@ mod tests {
// This should error due to arrays of ltxtqueries not being supported
let success = match Postgres::build(query) {
Err(_) => true,
_ => false
_ => false,
};

assert!(success);
Expand Down
21 changes: 18 additions & 3 deletions src/visitor/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,22 @@ impl<'a> Visitor<'a> for Sqlite<'a> {
}

#[cfg(feature = "postgresql")]
fn visit_ltree_is_ancestor(&mut self, _left: Expression<'a>, _right: LtreeQuery<'a>, _not: bool) -> visitor::Result {
fn visit_ltree_is_ancestor(
&mut self,
_left: Expression<'a>,
_right: LtreeQuery<'a>,
_not: bool,
) -> visitor::Result {
unimplemented!("Ltree is not supported on SQLite");
}

#[cfg(feature = "postgresql")]
fn visit_ltree_is_descendant(&mut self, _left: Expression<'a>, _right: LtreeQuery<'a>, _not: bool) -> visitor::Result {
fn visit_ltree_is_descendant(
&mut self,
_left: Expression<'a>,
_right: LtreeQuery<'a>,
_not: bool,
) -> visitor::Result {
unimplemented!("Ltree is not supported on SQLite");
}

Expand All @@ -302,7 +312,12 @@ impl<'a> Visitor<'a> for Sqlite<'a> {
}

#[cfg(feature = "postgresql")]
fn visit_ltree_match_fulltext(&mut self, _left: Expression<'a>, _right: LtreeQuery<'a>, _not: bool) -> visitor::Result {
fn visit_ltree_match_fulltext(
&mut self,
_left: Expression<'a>,
_right: LtreeQuery<'a>,
_not: bool,
) -> visitor::Result {
unimplemented!("Ltree is not supported on SQLite");
}
}
Expand Down

0 comments on commit 6e16cb0

Please sign in to comment.