diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index c9073f5ce..da6749e36 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -208,22 +208,36 @@ jobs: strategy: matrix: os: [ubuntu-latest] - path: [86] + 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 + - if: "contains(steps.git-log.outputs.message, '[issues]')" + 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 000000000..ad34d61cb --- /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 000000000..08ae70ae9 --- /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 000000000..030325ad0 --- /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 aabcf079f..6cc73bca4 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 3b0dac260..3329731ad 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(), );