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

Function right_join

tests/relational_tests.rs:121–200  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

119#[sea_orm_macros::test]
120#[cfg(any(feature = "sqlx-mysql", feature = "sqlx-postgres"))]
121pub async fn right_join() {
122 let ctx = TestContext::new("test_right_join").await;
123 create_tables(&ctx.db).await.unwrap();
124
125 let bakery = bakery::ActiveModel {
126 name: Set("SeaSide Bakery".to_owned()),
127 profit_margin: Set(10.4),
128 ..Default::default()
129 }
130 .insert(&ctx.db)
131 .await
132 .expect("could not insert bakery");
133
134 let customer_kate = customer::ActiveModel {
135 name: Set("Kate".to_owned()),
136 ..Default::default()
137 }
138 .insert(&ctx.db)
139 .await
140 .expect("could not insert customer");
141
142 let _customer_jim = customer::ActiveModel {
143 name: Set("Jim".to_owned()),
144 ..Default::default()
145 }
146 .insert(&ctx.db)
147 .await
148 .expect("could not insert customer");
149
150 let _order = order::ActiveModel {
151 bakery_id: Set(bakery.id),
152 customer_id: Set(customer_kate.id),
153 total: Set(rust_dec(15.10)),
154 placed_at: Set(Utc::now().naive_utc()),
155
156 ..Default::default()
157 }
158 .insert(&ctx.db)
159 .await
160 .expect("could not insert order");
161
162 #[derive(FromQueryResult)]
163 #[allow(dead_code)]
164 struct SelectResult {
165 name: String,
166 order_total: Option<Decimal>,
167 }
168
169 let select = order::Entity::find()
170 .right_join(customer::Entity)
171 .select_only()
172 .column(customer::Column::Name)
173 .column_as(order::Column::Total, "order_total")
174 .filter(customer::Column::Name.contains("Kate"));
175
176 let result = select
177 .into_model::<SelectResult>()
178 .one(&ctx.db)

Callers

nothing calls this directly

Calls 13

rust_decFunction · 0.85
unwrapMethod · 0.80
filterMethod · 0.80
column_asMethod · 0.80
columnMethod · 0.80
select_onlyMethod · 0.80
right_joinMethod · 0.80
containsMethod · 0.80
newFunction · 0.50
create_tablesFunction · 0.50
insertMethod · 0.45
oneMethod · 0.45

Tested by

no test coverage detected