-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
describer: multiSchema-aware SQL Server
- Loading branch information
Julius de Bruijn
committed
Dec 5, 2022
1 parent
367cade
commit f90407c
Showing
11 changed files
with
695 additions
and
521 deletions.
There are no files selected for viewing
422 changes: 2 additions & 420 deletions
422
introspection-engine/introspection-engine-tests/tests/multi_schema/mod.rs
Large diffs are not rendered by default.
Oops, something went wrong.
421 changes: 421 additions & 0 deletions
421
introspection-engine/introspection-engine-tests/tests/multi_schema/postgres.rs
Large diffs are not rendered by default.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
introspection-engine/introspection-engine-tests/tests/multi_schema/sql_server.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
use introspection_engine_tests::{test_api::*, TestResult}; | ||
|
||
#[test_connector(tags(Mssql), preview_features("multiSchema"), namespaces("first", "second"))] | ||
async fn multiple_schemas_w_tables_are_introspected(api: &TestApi) -> TestResult { | ||
let schema_name = "first"; | ||
let other_name = "second"; | ||
|
||
let setup = format!("CREATE SCHEMA {schema_name}"); | ||
api.database().raw_cmd(&setup).await?; | ||
|
||
let setup = format!("CREATE SCHEMA {other_name}"); | ||
api.database().raw_cmd(&setup).await?; | ||
|
||
let setup = format!("CREATE SCHEMA third"); | ||
api.database().raw_cmd(&setup).await?; | ||
|
||
let setup = formatdoc!( | ||
r#" | ||
CREATE TABLE [{schema_name}].[A] ( | ||
id INT IDENTITY, | ||
data INT, | ||
CONSTRAINT [A_pkey] PRIMARY KEY (id) | ||
); | ||
"# | ||
); | ||
api.database().raw_cmd(&setup).await?; | ||
|
||
let setup = formatdoc!( | ||
r#" | ||
CREATE TABLE [{other_name}].[B] ( | ||
id INT IDENTITY, | ||
data INT, | ||
CONSTRAINT [B_pkey] PRIMARY KEY (id) | ||
); | ||
"# | ||
); | ||
api.database().raw_cmd(&setup).await?; | ||
|
||
let setup = formatdoc!( | ||
r#" | ||
CREATE TABLE [third].[C] ( | ||
id INT IDENTITY, | ||
data INT, | ||
CONSTRAINT [C_pkey] PRIMARY KEY (id) | ||
); | ||
"# | ||
); | ||
api.database().raw_cmd(&setup).await?; | ||
|
||
let expected = expect![[r#" | ||
generator client { | ||
provider = "prisma-client-js" | ||
previewFeatures = ["multiSchema"] | ||
} | ||
datasource db { | ||
provider = "sqlserver" | ||
url = "env(TEST_DATABASE_URL)" | ||
schemas = ["first", "second"] | ||
} | ||
model A { | ||
id Int @id @default(autoincrement()) | ||
data Int? | ||
@@schema("first") | ||
} | ||
model B { | ||
id Int @id @default(autoincrement()) | ||
data Int? | ||
@@schema("second") | ||
} | ||
"#]]; | ||
|
||
api.expect_datamodel(&expected).await; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.