Changelog
This commit is contained in:
parent
ad33d7745d
commit
ebbfc0f5be
45
CHANGELOG.md
45
CHANGELOG.md
@ -98,58 +98,17 @@ assert_eq!(
|
|||||||
The DeriveRelatedEntity derive macro will implement `seaography::RelationBuilder` for `RelatedEntity` enumeration when the `seaography` feature is enabled
|
The DeriveRelatedEntity derive macro will implement `seaography::RelationBuilder` for `RelatedEntity` enumeration when the `seaography` feature is enabled
|
||||||
|
|
||||||
* Add `expr`, `exprs` and `expr_as` methods to `QuerySelect` trait https://github.com/SeaQL/sea-orm/pull/1702
|
* Add `expr`, `exprs` and `expr_as` methods to `QuerySelect` trait https://github.com/SeaQL/sea-orm/pull/1702
|
||||||
```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`"
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
cake::Entity::find()
|
|
||||||
.select_only()
|
|
||||||
.exprs([
|
|
||||||
Expr::col((cake::Entity, cake::Column::Id)),
|
|
||||||
Expr::col((cake::Entity, cake::Column::Name)),
|
|
||||||
])
|
|
||||||
.build(DbBackend::MySql)
|
|
||||||
.to_string(),
|
|
||||||
"SELECT `cake`.`id`, `cake`.`name` FROM `cake`"
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
cake::Entity::find()
|
|
||||||
.expr_as(
|
|
||||||
Func::upper(Expr::col((cake::Entity, cake::Column::Name))),
|
|
||||||
"name_upper"
|
|
||||||
)
|
|
||||||
.build(DbBackend::MySql)
|
|
||||||
.to_string(),
|
|
||||||
"SELECT `cake`.`id`, `cake`.`name`, UPPER(`cake`.`name`) AS `name_upper` FROM `cake`"
|
|
||||||
);
|
|
||||||
```
|
|
||||||
* 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
|
* 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
|
||||||
```rust
|
```rust
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
cake
|
cake.into_active_model().insert(db).await
|
||||||
.into_active_model()
|
|
||||||
.insert(db)
|
|
||||||
.await
|
|
||||||
.expect_err("Insert a row with duplicated primary key")
|
.expect_err("Insert a row with duplicated primary key")
|
||||||
.sql_err(),
|
.sql_err(),
|
||||||
Some(SqlErr::UniqueConstraintViolation(_))
|
Some(SqlErr::UniqueConstraintViolation(_))
|
||||||
));
|
));
|
||||||
|
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
fk_cake
|
fk_cake.insert(db).await
|
||||||
.insert(db)
|
|
||||||
.await
|
|
||||||
.expect_err("Insert a row with invalid foreign key")
|
.expect_err("Insert a row with invalid foreign key")
|
||||||
.sql_err(),
|
.sql_err(),
|
||||||
Some(SqlErr::ForeignKeyConstraintViolation(_))
|
Some(SqlErr::ForeignKeyConstraintViolation(_))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user