Skip to content

Commit 1ef3f63

Browse files
committed
Improve doc test
1 parent 2d49f76 commit 1ef3f63

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/extension/postgres/expr.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,33 @@ pub trait PgExpr: ExprTrait {
1111
/// use sea_query::{extension::postgres::PgExpr, tests_cfg::*, *};
1212
///
1313
/// let query = Query::select()
14-
/// .columns([Font::Name, Font::Variant, Font::Language])
15-
/// .from(Font::Table)
16-
/// .and_where(Expr::val("a").concatenate("b").concat("c").concat("d"))
17-
/// .to_owned();
14+
/// .expr(Expr::val("a").concatenate("b"))
15+
/// .take();
1816
///
1917
/// assert_eq!(
2018
/// query.to_string(PostgresQueryBuilder),
21-
/// r#"SELECT "name", "variant", "language" FROM "font" WHERE 'a' || 'b' || 'c' || 'd'"#
19+
/// r#"SELECT 'a' || 'b'"#
2220
/// );
21+
///
22+
/// #[cfg(feature = "postgres-array")]
23+
/// {
24+
/// let query = Query::select()
25+
/// .expr(Expr::val(vec!["a".to_owned()]).concatenate(vec!["b".to_owned()]))
26+
/// .take();
27+
///
28+
/// assert_eq!(
29+
/// query.to_string(PostgresQueryBuilder),
30+
/// r#"SELECT ARRAY ['a'] || ARRAY ['b']"#
31+
/// );
32+
/// }
2333
/// ```
2434
fn concatenate<T>(self, right: T) -> Expr
2535
where
2636
T: Into<Expr>,
2737
{
2838
self.binary(PgBinOper::Concatenate, right)
2939
}
40+
3041
/// Alias of [`PgExpr::concatenate`]
3142
fn concat<T>(self, right: T) -> Expr
3243
where

0 commit comments

Comments
 (0)