Skip to content

Commit

Permalink
validation error when shadowUrl identical to either url or directUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
pranayat committed Apr 26, 2024
1 parent 16f07c8 commit b54bc96
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
20 changes: 8 additions & 12 deletions psl/psl-core/src/validate/datasource_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,14 @@ fn lift_datasource(
None => (None, None),
};

if let (Some((shadow_url, _)), Some(direct_url), url, Some(direct_url_span), url_span) = (
shadow_database_url.clone(),
direct_url.clone(),
url.clone(),
direct_url_span,
url_span,
) {
if shadow_url == direct_url {
diagnostics.push_error(DatamodelError::new_shadow_database_is_same_as_direct_url_error(
source_name,
direct_url_span,
));
if let Some((shadow_url, _)) = shadow_database_url.clone() {
if let (Some(direct_url), Some(direct_url_span)) = (direct_url.clone(), direct_url_span) {
if shadow_url == direct_url {
diagnostics.push_error(DatamodelError::new_shadow_database_is_same_as_direct_url_error(
source_name,
direct_url_span,
));
}
}

if shadow_url == url {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
datasource testds {
provider = "mysql"
url = "mysql://testurl"
directUrl = "mysql://testurl"
shadowDatabaseUrl = "mysql://testurl"
}

// error: shadowDatabaseUrl is the same as directUrl for datasource "testds". Please specify a different database as shadow database.
// --> schema.prisma:4
//  | 
//  3 |  url = "mysql://testurl"
//  4 |  directUrl = "mysql://testurl"
//  | 
// error: shadowDatabaseUrl is the same as url for datasource "testds". Please specify a different database as shadow database.
// --> schema.prisma:3
//  | 
//  2 |  provider = "mysql"
//  3 |  url = "mysql://testurl"
//  | 
7 changes: 0 additions & 7 deletions psl/psl/tests/validation/datasource/url_same_as_shadow.prisma
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
datasource testds {
provider = "mysql"
url = "mysql://testurl"
directUrl = "mysql://testurl"
shadowDatabaseUrl = "mysql://testurl"
}

// error: shadowDatabaseUrl is the same as directUrl for datasource "testds". Please specify a different database as shadow database.
// --> schema.prisma:4
//  | 
//  3 |  url = "mysql://testurl"
//  4 |  directUrl = "mysql://testurl"
//  | 
// error: shadowDatabaseUrl is the same as url for datasource "testds". Please specify a different database as shadow database.
// --> schema.prisma:3
//  | 
Expand Down

0 comments on commit b54bc96

Please sign in to comment.