Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
20 changes: 17 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions issues/262/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"] }
26 changes: 26 additions & 0 deletions issues/262/src/cake.rs
Original file line number Diff line number Diff line change
@@ -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");
}
}
14 changes: 14 additions & 0 deletions issues/262/src/main.rs
Original file line number Diff line number Diff line change
@@ -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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can get away with a mock. It makes compilation much faster

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure we can

.await
.unwrap();

async_std::task::spawn(async move {
cake::Entity::find().one(&db).await.unwrap();
})
.await;
}
1 change: 0 additions & 1 deletion sea-orm-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions sea-orm-macros/src/derives/entity_model.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -62,7 +62,7 @@ pub fn expand_derive_entity_model(data: Data, attrs: Vec<Attribute>) -> 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(),
);

Expand Down