Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
franklx committed Nov 5, 2023
2 parents c40f283 + ff32f52 commit 28182af
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"macro",
"core",
Expand Down
12 changes: 10 additions & 2 deletions attr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,17 @@ impl Intermediate {
}

pub fn schema_from_filepaths(paths: &[&Path]) -> anyhow::Result<OrmliteSchema> {
let invalid_paths = paths.iter().filter(|p| fs::metadata(p).is_err()).collect::<Vec<_>>();
if !invalid_paths.is_empty() {
for path in invalid_paths {
tracing::error!(path=path.display().to_string(), "Does not exist");
}
anyhow::bail!("Provided paths that did not exist.");
}

let walk = paths.iter().flat_map(Walk::new);

let walk = walk.filter_map(|e| e.ok())
let walk = walk.map(|e| e.unwrap())
.filter(|e| e.path().extension().map(|e| e == "rs")
.unwrap_or(false))
.map(|e| e.into_path())
Expand All @@ -102,10 +110,10 @@ pub fn schema_from_filepaths(paths: &[&Path]) -> anyhow::Result<OrmliteSchema> {
for entry in walk {
let contents = fs::read_to_string(&entry)
.context(format!("failed to read file: {}", entry.display()))?;
tracing::debug!(file=entry.display().to_string(), "Checking for Model, Type, ManualType derive attrs");
if !contents.contains("Model") {
continue;
}
tracing::debug!(file=entry.display().to_string(), "Checking for derive attrs: Model, Type, ManualType");
let ast = syn::parse_file(&contents)
.context(format!("Failed to parse file: {}", entry.display()))?;
let intermediate = Intermediate::from_with_opts(ast);
Expand Down
1 change: 0 additions & 1 deletion attr/src/syndecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ mod tests {
};
let item = syn::parse2::<syn::ItemEnum>(q).unwrap();
let attrs = Attributes2::from(item.attrs.as_slice());
dbg!(&attrs);
assert!(attrs.has_derive("Type"));
assert_eq!(attrs.repr, Some("u8".to_string()));
}
Expand Down
1 change: 0 additions & 1 deletion cli/src/command/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ impl Migrate {
file_name.push_str(&self.name);
let migration_body = migration.as_ref().map(|m| {
m.statements.iter()
.inspect(|&f| { dbg!(f); })
.map(|s| s.to_sql(Dialect::Postgres))
.collect::<Vec<_>>()
.join(";\n")
Expand Down
3 changes: 1 addition & 2 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ fn main() -> Result<()> {
.without_time()
)
.with(tracing_subscriber::filter::Targets::new()
.with_target(env!("CARGO_PKG_NAME"), level)
.with_target("ormlite", level)
.with_target(env!("CARGO_BIN_NAME"), level)
.with_target("ormlite_attr", level)
.with_target("sqlmo", level)
)
Expand Down

0 comments on commit 28182af

Please sign in to comment.