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 28, 2022
1 parent 92c2559 commit 3064ace
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 30 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
29 changes: 22 additions & 7 deletions src/visitor/mssql.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::Visitor;
#[cfg(all(feature = "json", any(feature = "postgresql", feature = "mysql")))]
use crate::prelude::{JsonExtract, JsonType};
#[cfg(feature = "postgresql")]
use crate::ast::LtreeQuery;
#[cfg(all(feature = "json", any(feature = "postgresql", feature = "mysql")))]
use crate::prelude::{JsonExtract, JsonType};
use crate::{
ast::{
Column, Comparable, Expression, ExpressionKind, Insert, IntoRaw, Join, JoinData, Joinable,
Merge, OnConflict, Order, Ordering, Row, Table, TypeDataLength, TypeFamily, Values,
Column, Comparable, Expression, ExpressionKind, Insert, IntoRaw, Join, JoinData, Joinable, Merge, OnConflict,
Order, Ordering, Row, Table, TypeDataLength, TypeFamily, Values,
},
error::{Error, ErrorKind},
prelude::{Aliasable, Average, Query},
Expand Down Expand Up @@ -647,12 +647,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 @@ -662,7 +672,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 3064ace

Please sign in to comment.