Skip to content

Commit b14c143

Browse files
committed
Add examples
1 parent 23523f0 commit b14c143

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/query/helper.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,35 @@ pub trait QueryFilter: Sized {
718718
/// );
719719
/// ```
720720
///
721+
/// Like above, but using the `IN` operator.
722+
///
723+
/// ```
724+
/// use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};
725+
///
726+
/// assert_eq!(
727+
/// cake::Entity::find()
728+
/// .filter(cake::Column::Id.is_in([4, 5]))
729+
/// .build(DbBackend::MySql)
730+
/// .to_string(),
731+
/// "SELECT `cake`.`id`, `cake`.`name` FROM `cake` WHERE `cake`.`id` IN (4, 5)"
732+
/// );
733+
/// ```
734+
///
735+
/// Like above, but using the `ANY` operator. Postgres only.
736+
///
737+
/// ```
738+
/// use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};
739+
/// use sea_orm::sea_query::{Expr, extension::postgres::PgFunc};
740+
///
741+
/// assert_eq!(
742+
/// cake::Entity::find()
743+
/// .filter(Expr::col((cake::Entity, cake::Column::Id)).eq(PgFunc::any(vec![4, 5])))
744+
/// .build(DbBackend::Postgres)
745+
/// .to_string(),
746+
/// r#"SELECT "cake"."id", "cake"."name" FROM "cake" WHERE "cake"."id" = ANY(ARRAY [4,5])"#
747+
/// );
748+
/// ```
749+
///
721750
/// Add a runtime-built condition tree.
722751
/// ```
723752
/// use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend};

0 commit comments

Comments
 (0)