Generate arbitrary named entity (#70)

* Generate arbitrary named entity (#69)

* Bump cli & codegen version

* CI tests no caching

* Remove local dependency path
This commit is contained in:
Billy Chan 2021-08-10 16:35:10 +08:00 committed by GitHub
parent b1d28db5ad
commit ba226a2b62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 18 deletions

View File

@ -25,8 +25,6 @@ jobs:
toolchain: stable toolchain: stable
override: true override: true
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/cargo@v1 - uses: actions-rs/cargo@v1
with: with:
command: build command: build
@ -60,8 +58,6 @@ jobs:
toolchain: stable toolchain: stable
override: true override: true
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/cargo@v1 - uses: actions-rs/cargo@v1
with: with:
command: build command: build
@ -109,8 +105,6 @@ jobs:
toolchain: stable toolchain: stable
override: true override: true
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/cargo@v1 - uses: actions-rs/cargo@v1
with: with:
command: build command: build
@ -158,8 +152,6 @@ jobs:
toolchain: stable toolchain: stable
override: true override: true
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/cargo@v1 - uses: actions-rs/cargo@v1
with: with:
command: build command: build
@ -204,8 +196,6 @@ jobs:
toolchain: stable toolchain: stable
override: true override: true
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/cargo@v1 - uses: actions-rs/cargo@v1
with: with:
command: build command: build

View File

@ -1,6 +1,6 @@
[package] [package]
name = "sea-orm-cli" name = "sea-orm-cli"
version = "0.1.0" version = "0.1.1"
authors = [ "Billy Chan <ccw.billy.123@gmail.com>" ] authors = [ "Billy Chan <ccw.billy.123@gmail.com>" ]
edition = "2018" edition = "2018"
description = "Command line utility for SeaORM" description = "Command line utility for SeaORM"

View File

@ -9,5 +9,5 @@ cargo run -- -h
Running Entity Generator: Running Entity Generator:
```sh ```sh
cargo run -- entity generate -url mysql://sea:sea@localhost/bakery -schema bakery -o out cargo run -- generate entity -u mysql://sea:sea@localhost/bakery -s bakery -o out
``` ```

View File

@ -1,6 +1,6 @@
[package] [package]
name = "sea-orm-codegen" name = "sea-orm-codegen"
version = "0.1.1" version = "0.1.2"
authors = ["Billy Chan <ccw.billy.123@gmail.com>"] authors = ["Billy Chan <ccw.billy.123@gmail.com>"]
edition = "2018" edition = "2018"
description = "Code Generator for SeaORM" description = "Code Generator for SeaORM"

View File

@ -34,7 +34,7 @@ impl EntityWriter {
let code_blocks = Self::gen_code_blocks(entity); let code_blocks = Self::gen_code_blocks(entity);
Self::write(&mut lines, code_blocks); Self::write(&mut lines, code_blocks);
OutputFile { OutputFile {
name: format!("{}.rs", entity.table_name), name: format!("{}.rs", entity.get_table_name_snake_case()),
content: lines.join("\n\n"), content: lines.join("\n\n"),
} }
}) })
@ -123,11 +123,11 @@ impl EntityWriter {
} }
pub fn gen_impl_entity_name(entity: &Entity) -> TokenStream { pub fn gen_impl_entity_name(entity: &Entity) -> TokenStream {
let table_name_snake_case = entity.get_table_name_snake_case(); let table_name = entity.table_name.as_str();
quote! { quote! {
impl EntityName for Entity { impl EntityName for Entity {
fn table_name(&self) -> &str { fn table_name(&self) -> &str {
#table_name_snake_case #table_name
} }
} }
} }
@ -341,7 +341,7 @@ mod tests {
}], }],
}, },
Entity { Entity {
table_name: "cake_filling".to_owned(), table_name: "_cake_filling_".to_owned(),
columns: vec![ columns: vec![
Column { Column {
name: "cake_id".to_owned(), name: "cake_id".to_owned(),

View File

@ -7,7 +7,7 @@ pub struct Entity;
impl EntityName for Entity { impl EntityName for Entity {
fn table_name(&self) -> &str { fn table_name(&self) -> &str {
"cake_filling" "_cake_filling_"
} }
} }