MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / column_as

Method column_as

src/query/helper.rs:87–98  ·  view source on GitHub ↗

Add a select column with alias ``` use sea_orm::{entity::*, query::*, tests_cfg::cake, DbBackend}; assert_eq!( cake::Entity::find() .select_only() .column_as(cake::Column::Id.count(), "count") .build(DbBackend::Postgres) .to_string(), r#"SELECT COUNT("cake"."id") AS "count" FROM "cake""# ); ```

(mut self, col: C, alias: I)

Source from the content-addressed store, hash-verified

85 /// );
86 /// ```
87 fn column_as<C, I>(mut self, col: C, alias: I) -> Self
88 where
89 C: ColumnAsExpr,
90 I: IntoIdentity,
91 {
92 self.query().expr(SelectExpr {
93 expr: col.into_column_as_expr(),
94 alias: Some(SeaRc::new(alias.into_identity())),
95 window: None,
96 });
97 self
98 }
99
100 /// Select columns
101 ///

Callers 14

left_joinFunction · 0.80
right_joinFunction · 0.80
inner_joinFunction · 0.80
group_byFunction · 0.80
havingFunction · 0.80
relatedFunction · 0.80
linkedFunction · 0.80
from_query_result_nestedFunction · 0.80
find_baker_least_salesFunction · 0.80
mainFunction · 0.80

Implementers 1

cursor.rssrc/executor/cursor.rs

Calls 5

exprMethod · 0.80
into_column_as_exprMethod · 0.80
into_identityMethod · 0.80
newFunction · 0.50
queryMethod · 0.45

Tested by 11

left_joinFunction · 0.64
right_joinFunction · 0.64
inner_joinFunction · 0.64
group_byFunction · 0.64
havingFunction · 0.64
relatedFunction · 0.64
linkedFunction · 0.64
from_query_result_nestedFunction · 0.64
find_baker_least_salesFunction · 0.64