Skip to content

Commit

Permalink
Generate arbitrary named entity (#70)
Browse files Browse the repository at this point in the history
* Generate arbitrary named entity (#69)

* Bump cli & codegen version

* CI tests no caching

* Remove local dependency path
  • Loading branch information
billy1624 committed Aug 10, 2021
1 parent b1d28db commit ba226a2
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 18 deletions.
10 changes: 0 additions & 10 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ jobs:
toolchain: stable
override: true

- uses: Swatinem/rust-cache@v1

- uses: actions-rs/cargo@v1
with:
command: build
Expand Down Expand Up @@ -60,8 +58,6 @@ jobs:
toolchain: stable
override: true

- uses: Swatinem/rust-cache@v1

- uses: actions-rs/cargo@v1
with:
command: build
Expand Down Expand Up @@ -109,8 +105,6 @@ jobs:
toolchain: stable
override: true

- uses: Swatinem/rust-cache@v1

- uses: actions-rs/cargo@v1
with:
command: build
Expand Down Expand Up @@ -158,8 +152,6 @@ jobs:
toolchain: stable
override: true

- uses: Swatinem/rust-cache@v1

- uses: actions-rs/cargo@v1
with:
command: build
Expand Down Expand Up @@ -204,8 +196,6 @@ jobs:
toolchain: stable
override: true

- uses: Swatinem/rust-cache@v1

- uses: actions-rs/cargo@v1
with:
command: build
Expand Down
2 changes: 1 addition & 1 deletion sea-orm-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sea-orm-cli"
version = "0.1.0"
version = "0.1.1"
authors = [ "Billy Chan <ccw.billy.123@gmail.com>" ]
edition = "2018"
description = "Command line utility for SeaORM"
Expand Down
2 changes: 1 addition & 1 deletion sea-orm-cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ cargo run -- -h
Running Entity Generator:

```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
```
2 changes: 1 addition & 1 deletion sea-orm-codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sea-orm-codegen"
version = "0.1.1"
version = "0.1.2"
authors = ["Billy Chan <ccw.billy.123@gmail.com>"]
edition = "2018"
description = "Code Generator for SeaORM"
Expand Down
8 changes: 4 additions & 4 deletions sea-orm-codegen/src/entity/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl EntityWriter {
let code_blocks = Self::gen_code_blocks(entity);
Self::write(&mut lines, code_blocks);
OutputFile {
name: format!("{}.rs", entity.table_name),
name: format!("{}.rs", entity.get_table_name_snake_case()),
content: lines.join("\n\n"),
}
})
Expand Down Expand Up @@ -123,11 +123,11 @@ impl EntityWriter {
}

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! {
impl EntityName for Entity {
fn table_name(&self) -> &str {
#table_name_snake_case
#table_name
}
}
}
Expand Down Expand Up @@ -341,7 +341,7 @@ mod tests {
}],
},
Entity {
table_name: "cake_filling".to_owned(),
table_name: "_cake_filling_".to_owned(),
columns: vec![
Column {
name: "cake_id".to_owned(),
Expand Down
2 changes: 1 addition & 1 deletion sea-orm-codegen/tests/entity/cake_filling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct Entity;

impl EntityName for Entity {
fn table_name(&self) -> &str {
"cake_filling"
"_cake_filling_"
}
}

Expand Down

0 comments on commit ba226a2

Please sign in to comment.