Merge branch 'master' into sea-query-v0.27
This commit is contained in:
commit
3219e6ff42
@ -14,18 +14,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
* [sea-orm-cli] Generate migration in modules https://github.com/SeaQL/sea-orm/pull/933
|
* [sea-orm-cli] Generate migration in modules https://github.com/SeaQL/sea-orm/pull/933
|
||||||
* [sea-orm-cli] Generate `DeriveRelation` on empty `Relation` enum https://github.com/SeaQL/sea-orm/pull/1019
|
* [sea-orm-cli] Generate `DeriveRelation` on empty `Relation` enum https://github.com/SeaQL/sea-orm/pull/1019
|
||||||
* [sea-orm-cli] Generate entity derive `Eq` if possible https://github.com/SeaQL/sea-orm/pull/988
|
* [sea-orm-cli] Generate entity derive `Eq` if possible https://github.com/SeaQL/sea-orm/pull/988
|
||||||
* Run migration on any PostgreSQL schema https://github.com/SeaQL/sea-orm/pull/1056
|
* [sea-orm-cli] Run migration on any PostgreSQL schema https://github.com/SeaQL/sea-orm/pull/1056
|
||||||
|
|
||||||
### Enhancements
|
### Enhancements
|
||||||
|
|
||||||
* Support `distinct` & `distinct_on` expression https://github.com/SeaQL/sea-orm/pull/902
|
* Support `distinct` & `distinct_on` expression https://github.com/SeaQL/sea-orm/pull/902
|
||||||
* `fn column()` also handle enum type https://github.com/SeaQL/sea-orm/pull/973
|
* `fn column()` also handle enum type https://github.com/SeaQL/sea-orm/pull/973
|
||||||
* Added `acquire_timeout` on `ConnectOptions` https://github.com/SeaQL/sea-orm/pull/897
|
* Added `acquire_timeout` on `ConnectOptions` https://github.com/SeaQL/sea-orm/pull/897
|
||||||
* `migrate fresh` command will drop all PostgreSQL types https://github.com/SeaQL/sea-orm/pull/864, https://github.com/SeaQL/sea-orm/pull/991
|
* [sea-orm-cli] `migrate fresh` command will drop all PostgreSQL types https://github.com/SeaQL/sea-orm/pull/864, https://github.com/SeaQL/sea-orm/pull/991
|
||||||
* Better compile error for entity without primary key https://github.com/SeaQL/sea-orm/pull/1020
|
* Better compile error for entity without primary key https://github.com/SeaQL/sea-orm/pull/1020
|
||||||
* Added blanket implementations of `IntoActiveValue` for `Option` values https://github.com/SeaQL/sea-orm/pull/833
|
* Added blanket implementations of `IntoActiveValue` for `Option` values https://github.com/SeaQL/sea-orm/pull/833
|
||||||
* Added `into_model` & `into_json` to `Cursor` https://github.com/SeaQL/sea-orm/pull/1112
|
* Added `into_model` & `into_json` to `Cursor` https://github.com/SeaQL/sea-orm/pull/1112
|
||||||
* Added `set_schema_search_path` method to `ConnectOptions` for setting schema search path of PostgreSQL connection https://github.com/SeaQL/sea-orm/pull/1056
|
* Added `set_schema_search_path` method to `ConnectOptions` for setting schema search path of PostgreSQL connection https://github.com/SeaQL/sea-orm/pull/1056
|
||||||
|
* Serialize `time` types as `serde_json::Value` https://github.com/SeaQL/sea-orm/pull/1042
|
||||||
|
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
|
|
||||||
|
@ -57,6 +57,7 @@ If you have built an app using SeaORM and want to showcase it, feel free to open
|
|||||||
- [url_shortener](https://github.com/michidk/url_shortener) | A simple self-hosted URL shortener written in Rust | DB: MySQL, Postgres, SQLite
|
- [url_shortener](https://github.com/michidk/url_shortener) | A simple self-hosted URL shortener written in Rust | DB: MySQL, Postgres, SQLite
|
||||||
- [RGB Lib](https://github.com/RGB-Tools/rgb-lib) | A library to manage wallets for RGB assets | DB: MySQL, Postgres, SQLite
|
- [RGB Lib](https://github.com/RGB-Tools/rgb-lib) | A library to manage wallets for RGB assets | DB: MySQL, Postgres, SQLite
|
||||||
- [RCloud](https://github.com/p0rtL6/RCloud) | A self-hosted lightweight cloud drive alternative
|
- [RCloud](https://github.com/p0rtL6/RCloud) | A self-hosted lightweight cloud drive alternative
|
||||||
|
- [Music Player](https://github.com/tsirysndr/music-player) | An extensible music server written in Rust 🚀🎵✨ | DB: SQLite
|
||||||
|
|
||||||
## Learning Resources
|
## Learning Resources
|
||||||
|
|
||||||
|
@ -234,6 +234,7 @@ where
|
|||||||
type Selector = S;
|
type Selector = S;
|
||||||
|
|
||||||
fn paginate(self, db: &'db C, page_size: u64) -> Paginator<'db, C, S> {
|
fn paginate(self, db: &'db C, page_size: u64) -> Paginator<'db, C, S> {
|
||||||
|
assert!(page_size != 0, "page_size should not be zero");
|
||||||
Paginator {
|
Paginator {
|
||||||
query: self.query,
|
query: self.query,
|
||||||
page: 0,
|
page: 0,
|
||||||
@ -251,7 +252,8 @@ where
|
|||||||
{
|
{
|
||||||
type Selector = S;
|
type Selector = S;
|
||||||
fn paginate(self, db: &'db C, page_size: u64) -> Paginator<'db, C, S> {
|
fn paginate(self, db: &'db C, page_size: u64) -> Paginator<'db, C, S> {
|
||||||
let sql = &self.stmt.sql.trim()[6..].trim();
|
assert!(page_size != 0, "page_size should not be zero");
|
||||||
|
let sql = &self.stmt.sql.trim()[6..];
|
||||||
let mut query = SelectStatement::new();
|
let mut query = SelectStatement::new();
|
||||||
query.expr(if let Some(values) = self.stmt.values {
|
query.expr(if let Some(values) = self.stmt.values {
|
||||||
Expr::cust_with_values(sql, values.0)
|
Expr::cust_with_values(sql, values.0)
|
||||||
@ -768,4 +770,12 @@ mod tests {
|
|||||||
assert_eq!(db.into_transaction_log(), Transaction::wrap(stmts));
|
assert_eq!(db.into_transaction_log(), Transaction::wrap(stmts));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[smol_potat::test]
|
||||||
|
#[should_panic]
|
||||||
|
async fn error() {
|
||||||
|
let (db, _pages) = setup();
|
||||||
|
|
||||||
|
fruit::Entity::find().paginate(&db, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,14 @@ impl FromQueryResult for JsonValue {
|
|||||||
match_mysql_type!(chrono::NaiveDateTime);
|
match_mysql_type!(chrono::NaiveDateTime);
|
||||||
#[cfg(feature = "with-chrono")]
|
#[cfg(feature = "with-chrono")]
|
||||||
match_mysql_type!(chrono::DateTime<chrono::Utc>);
|
match_mysql_type!(chrono::DateTime<chrono::Utc>);
|
||||||
|
#[cfg(feature = "with-time")]
|
||||||
|
match_mysql_type!(time::Date);
|
||||||
|
#[cfg(feature = "with-time")]
|
||||||
|
match_mysql_type!(time::Time);
|
||||||
|
#[cfg(feature = "with-time")]
|
||||||
|
match_mysql_type!(time::PrimitiveDateTime);
|
||||||
|
#[cfg(feature = "with-time")]
|
||||||
|
match_mysql_type!(time::OffsetDateTime);
|
||||||
#[cfg(feature = "with-rust_decimal")]
|
#[cfg(feature = "with-rust_decimal")]
|
||||||
match_mysql_type!(rust_decimal::Decimal);
|
match_mysql_type!(rust_decimal::Decimal);
|
||||||
#[cfg(feature = "with-json")]
|
#[cfg(feature = "with-json")]
|
||||||
@ -106,6 +114,14 @@ impl FromQueryResult for JsonValue {
|
|||||||
match_postgres_type!(chrono::NaiveDateTime);
|
match_postgres_type!(chrono::NaiveDateTime);
|
||||||
#[cfg(feature = "with-chrono")]
|
#[cfg(feature = "with-chrono")]
|
||||||
match_postgres_type!(chrono::DateTime<chrono::FixedOffset>);
|
match_postgres_type!(chrono::DateTime<chrono::FixedOffset>);
|
||||||
|
#[cfg(feature = "with-time")]
|
||||||
|
match_postgres_type!(time::Date);
|
||||||
|
#[cfg(feature = "with-time")]
|
||||||
|
match_postgres_type!(time::Time);
|
||||||
|
#[cfg(feature = "with-time")]
|
||||||
|
match_postgres_type!(time::PrimitiveDateTime);
|
||||||
|
#[cfg(feature = "with-time")]
|
||||||
|
match_postgres_type!(time::OffsetDateTime);
|
||||||
#[cfg(feature = "with-rust_decimal")]
|
#[cfg(feature = "with-rust_decimal")]
|
||||||
match_postgres_type!(rust_decimal::Decimal);
|
match_postgres_type!(rust_decimal::Decimal);
|
||||||
#[cfg(feature = "with-json")]
|
#[cfg(feature = "with-json")]
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
pub mod common;
|
pub mod common;
|
||||||
pub use common::{features::*, setup::*, TestContext};
|
pub use common::{features::*, setup::*, TestContext};
|
||||||
use sea_orm::{entity::prelude::*, DatabaseConnection, IntoActiveModel};
|
use sea_orm::{entity::prelude::*, DatabaseConnection, IntoActiveModel};
|
||||||
|
use serde_json::json;
|
||||||
use time::macros::{date, time};
|
use time::macros::{date, time};
|
||||||
|
|
||||||
#[sea_orm_macros::test]
|
#[sea_orm_macros::test]
|
||||||
@ -42,5 +43,31 @@ pub async fn create_transaction_log(db: &DatabaseConnection) -> Result<(), DbErr
|
|||||||
Some(transaction_log.clone())
|
Some(transaction_log.clone())
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let json = TransactionLog::find().into_json().one(db).await?.unwrap();
|
||||||
|
|
||||||
|
#[cfg(feature = "sqlx-postgres")]
|
||||||
|
assert_eq!(
|
||||||
|
json,
|
||||||
|
json!({
|
||||||
|
"id": 1,
|
||||||
|
"date": "2022-03-13",
|
||||||
|
"time": "16:24:00",
|
||||||
|
"date_time": "2022-03-13T16:24:00",
|
||||||
|
"date_time_tz": "2022-03-13T16:24:00+00:00",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
#[cfg(feature = "sqlx-mysql")]
|
||||||
|
assert_eq!(
|
||||||
|
json,
|
||||||
|
json!({
|
||||||
|
"id": 1,
|
||||||
|
"date": "2022-03-13",
|
||||||
|
"time": "16:24:00",
|
||||||
|
"date_time": "2022-03-13T16:24:00",
|
||||||
|
"date_time_tz": "2022-03-13T16:24:00Z",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user