Skip to content

Commit a8db133

Browse files
committed
fix(lib): actually have correct lowercase snake_case directories and imports
1 parent 15b3b69 commit a8db133

File tree

18 files changed

+15
-9
lines changed

18 files changed

+15
-9
lines changed

src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ mod parser;
1818
use error::IOErrorToError;
1919
pub use error::{Error, Result};
2020
use file::MarkedFile;
21+
use heck::ToSnakeCase;
2122
use parser::ParsedTableMacro;
2223
pub use parser::FILE_SIGNATURE;
2324
use std::collections::HashMap;
@@ -416,7 +417,7 @@ pub fn generate_files(
416417
let table_dir = if table_config.single_model_file {
417418
output_models_dir.to_owned()
418419
} else {
419-
output_models_dir.join(&table_name)
420+
output_models_dir.join(table_name.to_snake_case().to_lowercase())
420421
};
421422

422423
if !table_dir.exists() {
@@ -451,11 +452,12 @@ pub fn generate_files(
451452
file_changes.push(FileChange::from(&table_mod_rs));
452453
}
453454

454-
mod_rs.ensure_mod_stmt(&table.name.to_string());
455+
mod_rs.ensure_mod_stmt(&table.name.to_string().to_snake_case().to_lowercase());
455456
}
456457

457458
// pass 2: delete code for removed tables
458459
for item in std::fs::read_dir(output_models_dir).attach_path_err(output_models_dir)? {
460+
// TODO: this does not work with "single-model-file"
459461
let item = item.attach_path_err(output_models_dir)?;
460462

461463
// check if item is a directory
@@ -484,6 +486,7 @@ pub fn generate_files(
484486
let found = generated.iter().find(|g| {
485487
g.name
486488
.to_string()
489+
.to_snake_case()
487490
.eq_ignore_ascii_case(associated_table_name)
488491
});
489492
if found.is_some() {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pub mod tableA;
2-
pub mod tableB;
1+
pub mod table_a;
2+
pub mod table_b;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pub mod tableA;
2-
pub mod tableB;
1+
pub mod table_a;
2+
pub mod table_b;

0 commit comments

Comments
 (0)