Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PARKED] dep: sea-orm rc1->rc3 #530

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ci-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
env:
RUST_TOOLCHAIN: stable
TOOLCHAIN_PROFILE: minimal
SEA_CLI_VER: "@^1.0.0-rc.3"

jobs:
rustfmt:
Expand Down Expand Up @@ -95,7 +96,7 @@ jobs:
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
- name: Install seaorm cli
run: cargo install sea-orm-cli
run: cargo install sea-orm-cli${{env.SEA_CLI_VER}}
- name: Run cargo test
run: cargo test --all-features --all
working-directory: ./examples/demo
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci-generators.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
env:
RUST_TOOLCHAIN: stable
TOOLCHAIN_PROFILE: minimal
SEA_CLI_VER: "@^1.0.0-rc.3"

jobs:
test:
Expand Down Expand Up @@ -54,7 +55,7 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Install seaorm cli
run: cargo install sea-orm-cli
run: cargo install sea-orm-cli${{env.SEA_CLI_VER}}

- name: scaffold
run: cargo run -- generate scaffold car name:string year:int && cargo build
Expand Down Expand Up @@ -149,7 +150,7 @@ jobs:
uses: Swatinem/rust-cache@v2

- name: Install seaorm cli
run: cargo install sea-orm-cli
run: cargo install sea-orm-cli${{env.SEA_CLI_VER}}

- name: test ${{ matrix.field_type }} model field type
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# local dev
todo.txt
*.sqlite

# IDE config files
.idea
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ clap = { version = "4.4.7", features = ["derive"], optional = true }
colored = "2"


sea-orm = { version = "1.0.0-rc.1", features = [
sea-orm = { version = "1.0.0-rc.3", features = [
"sqlx-postgres", # `DATABASE_DRIVER` feature
"sqlx-sqlite",
"runtime-tokio-rustls",
Expand Down Expand Up @@ -136,7 +136,7 @@ tower-http = { version = "0.5.0", features = [

[dependencies.sea-orm-migration]
optional = true
version = "1.0.0-rc.1"
version = "1.0.0-rc.3"
features = [
# Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI.
# View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime.
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ contain context, special notes for that module, and a checklist if needed, so pl
**Test your changes**

* [ ] Ensure you have the necessary local resources, such as `DB`/`Redis`, by executing the command `cargo loco doctor --environment test`. In case you don't have them, refer to the relevant documentation section for guidance.
* [ ] run `cargo test` on the root to test Loco itself
* [ ] run `cargo xtask test --quick` on the root to test Loco itself, or run `cargo xtask test` to do a full suite of tests of Loco and all of the starters and projects in this repo
* [ ] cd `examples/demo` and run `cargo test` to test our "driver app" which exercises the framework in various ways
* [ ] push your changes to Github to get the CI running and testing in various additional configurations that you don't have
* [ ] CI should pass. Take note that all `starters-*` CI are using a **fixed version** of Loco and are not seeing your changes yet
Expand Down
26 changes: 13 additions & 13 deletions examples/demo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async-trait = "0.1.74"
tracing = "0.1.40"
chrono = "0.4"
validator = { version = "0.16" }
sea-orm = { version = "1.0.0-rc.1", features = [
sea-orm = { version = "1.0.0-rc.3", features = [
"sqlx-sqlite",
"sqlx-postgres",
"runtime-tokio-rustls",
Expand Down
3 changes: 2 additions & 1 deletion examples/demo/config/development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ mailer:
# Database Configuration
database:
# Database connection URI
uri: {{get_env(name="DATABASE_URL", default="postgres://loco:loco@localhost:5432/loco_app")}}
#uri: {{get_env(name="DATABASE_URL", default="postgres://loco:loco@localhost:5432/loco_app")}}
uri: sqlite://loco_app.sqlite?mode=rwc
# When enabled, the sql query will be logged.
enable_logging: false
# Set the timeout duration when acquiring a connection.
Expand Down
2 changes: 1 addition & 1 deletion examples/demo/migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async-std = { version = "1", features = ["attributes", "tokio1"] }
loco-rs = { version = "*", path = "../../../" }

[dependencies.sea-orm-migration]
version = "1.0.0-rc.1"
version = "1.0.0-rc.3"
features = [
# Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI.
# View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime.
Expand Down
6 changes: 3 additions & 3 deletions examples/demo/src/models/_entities/notes.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.11
//! `SeaORM` Entity. Generated by sea-orm-codegen 1.0.0-rc.3

use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "notes")]
pub struct Model {
pub created_at: DateTime,
pub updated_at: DateTime,
pub created_at: DateTimeUtc,
pub updated_at: DateTimeUtc,
#[sea_orm(primary_key)]
pub id: i32,
pub title: Option<String>,
Expand Down
12 changes: 6 additions & 6 deletions examples/demo/src/models/_entities/users.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.11
//! `SeaORM` Entity. Generated by sea-orm-codegen 1.0.0-rc.3

use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "users")]
pub struct Model {
pub created_at: DateTime,
pub updated_at: DateTime,
pub created_at: DateTimeUtc,
pub updated_at: DateTimeUtc,
#[sea_orm(primary_key)]
pub id: i32,
pub pid: Uuid,
Expand All @@ -18,10 +18,10 @@ pub struct Model {
pub api_key: String,
pub name: String,
pub reset_token: Option<String>,
pub reset_sent_at: Option<DateTime>,
pub reset_sent_at: Option<DateTimeUtc>,
pub email_verification_token: Option<String>,
pub email_verification_sent_at: Option<DateTime>,
pub email_verified_at: Option<DateTime>,
pub email_verification_sent_at: Option<DateTimeUtc>,
pub email_verified_at: Option<DateTimeUtc>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand Down
6 changes: 3 additions & 3 deletions examples/demo/src/models/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl super::_entities::users::ActiveModel {
mut self,
db: &DatabaseConnection,
) -> ModelResult<Model> {
self.email_verification_sent_at = ActiveValue::set(Some(Local::now().naive_local()));
self.email_verification_sent_at = ActiveValue::set(Some(Local::now().into()));
self.email_verification_token = ActiveValue::Set(Some(Uuid::new_v4().to_string()));
Ok(self.update(db).await?)
}
Expand All @@ -273,7 +273,7 @@ impl super::_entities::users::ActiveModel {
///
/// when has DB query error
pub async fn set_forgot_password_sent(mut self, db: &DatabaseConnection) -> ModelResult<Model> {
self.reset_sent_at = ActiveValue::set(Some(Local::now().naive_local()));
self.reset_sent_at = ActiveValue::set(Some(Local::now().into()));
self.reset_token = ActiveValue::Set(Some(Uuid::new_v4().to_string()));
Ok(self.update(db).await?)
}
Expand All @@ -288,7 +288,7 @@ impl super::_entities::users::ActiveModel {
///
/// when has DB query error
pub async fn verified(mut self, db: &DatabaseConnection) -> ModelResult<Model> {
self.email_verified_at = ActiveValue::set(Some(Local::now().naive_local()));
self.email_verified_at = ActiveValue::set(Some(Local::now().into()));
Ok(self.update(db).await?)
}

Expand Down
5 changes: 2 additions & 3 deletions examples/demo/tests/requests/ping.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use blo::app::App;
use insta::assert_debug_snapshot;

use loco_rs::testing;
use rstest::rstest;

Expand All @@ -15,8 +14,8 @@ macro_rules! configure_insta {
};
}

// This tests the `_ping` endpoint, as well as the `NormalizePathLayer` that removes trailing
// slashes from the request path.
// This tests the `_ping` endpoint, as well as the `NormalizePathLayer` that
// removes trailing slashes from the request path.
#[rstest]
#[case("ping", "/_ping")]
#[case("ping_with_trailing_slash", "/_ping/")]
Expand Down
18 changes: 10 additions & 8 deletions loco-extras/src/initializers/normalize_path.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
//! [Initializer] to add a [NormalizePathLayer] middleware to handle a trailing `/` at the end of URIs.
//! [Initializer] to add a [NormalizePathLayer] middleware to handle a trailing
//! `/` at the end of URIs.
//!
//! See the [layer's docs][normalize-docs] for more details.
//!
//! Note that the normal approach to adding middleware via [Router::layer] results in the middleware
//! running after routing has already occurred. This means that any middleware that re-writes the
//! request URI, including [NormalizePathLayer], will not work as expected if added using
//! [Router::layer]. As a workaround, the middleware can be added by wrapping the entire router.
//! See [axum's docs][axum-docs] for more details and an example.
//! Note that the normal approach to adding middleware via [Router::layer]
//! results in the middleware running after routing has already occurred. This
//! means that any middleware that re-writes the request URI, including
//! [NormalizePathLayer], will not work as expected if added using
//! [Router::layer]. As a workaround, the middleware can be added by wrapping
//! the entire router. See [axum's docs][axum-docs] for more details and an
//! example.
//!
//! [normalize-docs]: https://docs.rs/tower-http/latest/tower_http/normalize_path/index.html
//! [axum-docs]: https://docs.rs/axum/latest/axum/middleware/index.html#rewriting-request-uri-in-middleware
use async_trait::async_trait;
use axum::Router;
use loco_rs::prelude::*;
use tower::Layer;
use tower_http::normalize_path::NormalizePathLayer;

use loco_rs::prelude::*;

#[allow(clippy::module_name_repetitions)]
pub struct NormalizePathInitializer;

Expand Down
7 changes: 3 additions & 4 deletions src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,15 @@
//! }
//! ```

use axum::extract::FromRequest;
pub use app_routes::{AppRoutes, ListRoutes};
use axum::{
extract::FromRequest,
http::StatusCode,
response::{IntoResponse, Response},
};
use colored::Colorize;
use serde::Serialize;

pub use app_routes::{AppRoutes, ListRoutes};
pub use routes::Routes;
use serde::Serialize;

use crate::{errors::Error, Result};

Expand Down
19 changes: 15 additions & 4 deletions xtask/src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use std::env;

use cargo_metadata::{semver::Version, MetadataCommand, Package};
use clap::{ArgAction::SetFalse, Parser, Subcommand};
use clap::{
ArgAction::{SetFalse, SetTrue},
Parser, Subcommand,
};

#[derive(Parser)]
#[command(author, version, about, long_about = None)]
Expand All @@ -14,7 +17,11 @@ struct Cli {
#[derive(Subcommand)]
enum Commands {
/// Run test on all Loco resources
Test {},
Test {
/// Test only Loco as a library
#[arg(short, long, action = SetTrue)]
quick: bool,
},
/// Bump loco version in all dependencies places
BumpVersion {
#[arg(name = "VERSION")]
Expand All @@ -30,8 +37,12 @@ fn main() -> eyre::Result<()> {
println!("running in: {project_dir:?}");

let res = match cli.command {
Commands::Test {} => {
let res = xtask::ci::all_resources(project_dir.as_path())?;
Commands::Test { quick } => {
let res = if quick {
vec![xtask::ci::run(project_dir.as_path()).expect("test should have run")]
} else {
xtask::ci::all_resources(project_dir.as_path())?
};
println!("{}", xtask::out::print_ci_results(&res));
xtask::CmdExit::ok()
}
Expand Down
Loading