Skip to content

Commit

Permalink
QuerySelect SimpleExpr SeaQL/sea-orm#1702
Browse files Browse the repository at this point in the history
  • Loading branch information
darkmmon committed Jul 12, 2023
1 parent 7ea184d commit 74e68f4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion SeaORM/docs/0.12.x-CHANGELOG_temp.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ pub enum RelatedEntity {
* Add `DeriveEntityRelated` macro https://github.com/SeaQL/sea-orm/pull/1599

The DeriveRelatedEntity derive macro will implement `seaography::RelationBuilder` for `RelatedEntity` enumeration when the `seaography` feature is enabled
================================ All Changes above was being Documented ================================

* Add `expr`, `exprs` and `expr_as` methods to `QuerySelect` trait
```rs
Expand Down Expand Up @@ -243,6 +242,7 @@ assert_eq!(
"SELECT `cake`.`id`, `cake`.`name`, UPPER(`cake`.`name`) AS `name_upper` FROM `cake`"
);
```
================================ All Changes above was being Documented ================================
* Add `DbErr::sql_err()` method to convert error into common database errors `SqlErr`, such as unique constraint or foreign key violation errors. https://github.com/SeaQL/sea-orm/pull/1707
```rs
assert!(matches!(
Expand Down
15 changes: 15 additions & 0 deletions SeaORM/docs/08-advanced-query/01-custom-select.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ assert_eq!(
);
```

Alternatively, you can simply select with `expr`, `exprs` and `expr_as` methods.
```rust
use sea_orm::sea_query::Expr;
use sea_orm::{entity::*, tests_cfg::cake, DbBackend, QuerySelect, QueryTrait};

assert_eq!(
cake::Entity::find()
.select_only()
.expr(Expr::col((cake::Entity, cake::Column::Id)))
.build(DbBackend::MySql)
.to_string(),
"SELECT `cake`.`id` FROM `cake`"
);
```

## Handling Select Results

### Custom Struct
Expand Down

0 comments on commit 74e68f4

Please sign in to comment.