From e911d2f5f42a9369120f163806114b00459ae914 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Thu, 21 Oct 2021 11:36:57 +0800 Subject: [PATCH 1/4] Unify case-transform using the same crate --- .github/workflows/rust.yml | 8 ++++++- issues/262/Cargo.toml | 12 ++++++++++ issues/262/src/cake.rs | 26 ++++++++++++++++++++++ issues/262/src/main.rs | 14 ++++++++++++ sea-orm-macros/Cargo.toml | 1 - sea-orm-macros/src/derives/entity_model.rs | 4 ++-- 6 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 issues/262/Cargo.toml create mode 100644 issues/262/src/cake.rs create mode 100644 issues/262/src/main.rs diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c9073f5c..c4112860 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -208,7 +208,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - path: [86] + path: [86, 249, 262] steps: - uses: actions/checkout@v2 @@ -224,6 +224,12 @@ jobs: args: > --manifest-path issues/${{ matrix.path }}/Cargo.toml + - uses: actions-rs/cargo@v1 + with: + command: test + args: > + --manifest-path issues/${{ matrix.path }}/Cargo.toml + sqlite: name: SQLite runs-on: ubuntu-20.04 diff --git a/issues/262/Cargo.toml b/issues/262/Cargo.toml new file mode 100644 index 00000000..ad34d61c --- /dev/null +++ b/issues/262/Cargo.toml @@ -0,0 +1,12 @@ +[workspace] +# A separate workspace + +[package] +name = "sea-orm-issues-262" +version = "0.1.0" +edition = "2018" +publish = false + +[dependencies] +sea-orm = { path = "../../", features = [ "sqlx-all", "runtime-async-std-native-tls", "debug-print" ] } +async-std = { version = "^1", features = ["attributes"] } diff --git a/issues/262/src/cake.rs b/issues/262/src/cake.rs new file mode 100644 index 00000000..08ae70ae --- /dev/null +++ b/issues/262/src/cake.rs @@ -0,0 +1,26 @@ +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "cake")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub md5hash: String, + pub md5_hash: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation {} + +impl ActiveModelBehavior for ActiveModel {} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_case_transform_1() { + assert_eq!(Column::Md5hash.to_string().as_str(), "md5hash"); + assert_eq!(Column::Md5Hash.to_string().as_str(), "md5_hash"); + } +} diff --git a/issues/262/src/main.rs b/issues/262/src/main.rs new file mode 100644 index 00000000..030325ad --- /dev/null +++ b/issues/262/src/main.rs @@ -0,0 +1,14 @@ +mod cake; +use sea_orm::*; + +#[async_std::main] +pub async fn main() { + let db = Database::connect("mysql://sea:sea@localhost/bakery") + .await + .unwrap(); + + async_std::task::spawn(async move { + cake::Entity::find().one(&db).await.unwrap(); + }) + .await; +} diff --git a/sea-orm-macros/Cargo.toml b/sea-orm-macros/Cargo.toml index aabcf079..6cc73bca 100644 --- a/sea-orm-macros/Cargo.toml +++ b/sea-orm-macros/Cargo.toml @@ -21,4 +21,3 @@ syn = { version = "^1", default-features = false, features = [ "full", "derive", quote = "^1" heck = "^0.3" proc-macro2 = "^1" -convert_case = "0.4" diff --git a/sea-orm-macros/src/derives/entity_model.rs b/sea-orm-macros/src/derives/entity_model.rs index 3b0dac26..3329731a 100644 --- a/sea-orm-macros/src/derives/entity_model.rs +++ b/sea-orm-macros/src/derives/entity_model.rs @@ -1,5 +1,5 @@ use crate::util::{escape_rust_keyword, trim_starting_raw_identifier}; -use convert_case::{Case, Casing}; +use heck::CamelCase; use proc_macro2::{Ident, Span, TokenStream}; use quote::quote; use syn::{ @@ -62,7 +62,7 @@ pub fn expand_derive_entity_model(data: Data, attrs: Vec) -> syn::Res for field in fields.named { if let Some(ident) = &field.ident { let mut field_name = Ident::new( - &trim_starting_raw_identifier(&ident).to_case(Case::Pascal), + &trim_starting_raw_identifier(&ident).to_camel_case(), Span::call_site(), ); From d10a52cc58aa6570e330d97c3d0f234ef771bd70 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Thu, 21 Oct 2021 18:25:35 +0800 Subject: [PATCH 2/4] Try skip CI job issues --- .github/workflows/rust.yml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c4112860..da6749e3 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -211,20 +211,28 @@ jobs: path: [86, 249, 262] steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - - uses: actions-rs/toolchain@v1 + - id: git-log + run: echo "::set-output name=message::$(git log --no-merges -1 --oneline)" + + - if: "contains(steps.git-log.outputs.message, '[issues]')" + uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable override: true - - uses: actions-rs/cargo@v1 + - if: "contains(steps.git-log.outputs.message, '[issues]')" + uses: actions-rs/cargo@v1 with: command: build args: > --manifest-path issues/${{ matrix.path }}/Cargo.toml - - uses: actions-rs/cargo@v1 + - if: "contains(steps.git-log.outputs.message, '[issues]')" + uses: actions-rs/cargo@v1 with: command: test args: > From 56e2f7c0e91bd3c79de583769a4b190b42a9102a Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Thu, 21 Oct 2021 19:08:58 +0800 Subject: [PATCH 3/4] Add empty line... --- .github/workflows/rust.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index da6749e3..110b2317 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -202,6 +202,7 @@ jobs: args: > --manifest-path examples/${{ matrix.path }}/Cargo.toml + issues: name: Issues runs-on: ${{ matrix.os }} From b65de654644d7ff253c94e03daad909a1ec69f6c Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Thu, 21 Oct 2021 19:09:38 +0800 Subject: [PATCH 4/4] [issues] The CI issues job should be running --- .github/workflows/rust.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 110b2317..da6749e3 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -202,7 +202,6 @@ jobs: args: > --manifest-path examples/${{ matrix.path }}/Cargo.toml - issues: name: Issues runs-on: ${{ matrix.os }}