Skip to content

Commit

Permalink
Merge pull request #193 from Brendonovich/fix-file-paths
Browse files Browse the repository at this point in the history
only treat schema urls as relative
  • Loading branch information
Brendonovich authored Oct 28, 2022
2 parents ec2ac40 + 7f7d34f commit e12e693
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions cli/src/generator/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,23 @@ pub fn generate(args: &GenerateArgs) -> TokenStream {
let url = match self.url {
Some(url) => url,
None => {
if let Some(url) = source.load_shadow_database_url()? {
let url = if let Some(url) = source.load_shadow_database_url()? {
url
} else {
source.load_url(|key| std::env::var(key).ok())?
}
}
};
};

let url = match url.starts_with("file:") {
true => {
let path = url.split(":").nth(1).unwrap();
match url.starts_with("file:") {
true => {
let path = url.split(":").nth(1).unwrap();

if std::path::Path::new("./prisma/schema.prisma").exists() {
format!("file:./prisma/{}", path)
} else { url }
},
_ => url,
if std::path::Path::new("./prisma/schema.prisma").exists() {
format!("file:./prisma/{}", path)
} else { url }
},
_ => url,
}
}
};

let (db_name, executor) = #pcr::query_core::executor::load(&source, &[], &url).await?;
Expand Down

0 comments on commit e12e693

Please sign in to comment.