Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: Enable More SQL Server Tests #2119

Merged
merged 2 commits into from Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 19 additions & 10 deletions migration-engine/migration-engine-tests/tests/migrations/sql.rs
Expand Up @@ -132,15 +132,19 @@ fn relations_to_models_with_no_pk_and_a_single_unique_required_field_work(api: T
});
}

// TODO: Enable SQL Server when cascading rules are in PSL.
#[test_connector(exclude(Mssql))]
fn reserved_sql_key_words_must_work(api: TestApi) {
#[test_connector]
fn reserved_sql_keywords_must_work(api: TestApi) {
// Group is a reserved keyword
let dm = r#"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For these you could use the new api.schema_push_w_datasource(dm1). This is adds the correct datasource and generator (generator should probably be mentioned in the method name). You'll probably get that already as merge conflict though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do that in another review round later this week!

generator js {
provider = "prisma-client-js"
previewFeatures = ["referentialActions"]
}

model Group {
id String @id @default(cuid())
parent_id String?
parent Group? @relation(name: "ChildGroups", fields: [parent_id], references: id)
parent Group? @relation(name: "ChildGroups", fields: [parent_id], references: id, onDelete: NoAction, onUpdate: NoAction)
childGroups Group[] @relation(name: "ChildGroups")
}
"#;
Expand Down Expand Up @@ -404,23 +408,28 @@ fn indexes_on_composite_relation_fields(api: TestApi) {
});
}

#[test_connector(exclude(Mssql))]
#[test_connector]
fn dropping_mutually_referencing_tables_works(api: TestApi) {
let dm1 = r#"
generator js {
provider = "prisma-client-js"
previewFeatures = ["referentialActions"]
}

model A {
id Int @id
b_id Int
ab B @relation("AtoB", fields: [b_id], references: [id])
ab B @relation("AtoB", fields: [b_id], references: [id], onUpdate: NoAction)
c_id Int
ac C @relation("AtoC", fields: [c_id], references: [id])
ac C @relation("AtoC", fields: [c_id], references: [id], onUpdate: NoAction)
b B[] @relation("BtoA")
c C[] @relation("CtoA")
}

model B {
id Int @id
a_id Int
ba A @relation("BtoA", fields: [a_id], references: [id])
ba A @relation("BtoA", fields: [a_id], references: [id], onUpdate: NoAction)
c_id Int
bc C @relation("BtoC", fields: [c_id], references: [id])
a A[] @relation("AtoB")
Expand All @@ -430,9 +439,9 @@ fn dropping_mutually_referencing_tables_works(api: TestApi) {
model C {
id Int @id
a_id Int
ca A @relation("CtoA", fields: [a_id], references: [id])
ca A @relation("CtoA", fields: [a_id], references: [id], onUpdate: NoAction)
b_id Int
cb B @relation("CtoB", fields: [b_id], references: [id])
cb B @relation("CtoB", fields: [b_id], references: [id], onUpdate: NoAction)
b B[] @relation("BtoC")
a A[] @relation("AtoC")
}
Expand Down
@@ -1,7 +1,7 @@
use indoc::indoc;
use query_engine_tests::*;

#[test_suite(schema(schema), exclude(SqlServer))]
#[test_suite(schema(schema))]
mod one2one_regression {
fn schema() -> String {
let schema = indoc! {
Expand All @@ -10,7 +10,7 @@ mod one2one_regression {
#id(id, Int, @id)
name String?
friendOf User? @relation("Userfriend")
friend User? @relation("Userfriend", fields: [friendId], references: [id])
friend User? @relation("Userfriend", fields: [friendId], references: [id], onDelete: NoAction, onUpdate: NoAction)
friendId Int?
}
"#
Expand Down
@@ -1,7 +1,7 @@
use indoc::indoc;
use query_engine_tests::*;

#[test_suite(schema(schema), exclude(SqlServer))]
#[test_suite(schema(schema))]
mod self_relation_filters {
use query_engine_tests::assert_error;

Expand All @@ -18,11 +18,11 @@ mod self_relation_filters {
title_id String?

husband Human? @relation(name: "Marriage")
wife Human? @relation(name: "Marriage", fields: [wife_id], references: [id])
mother Human? @relation(name: "Cuckoo", fields: [mother_id], references: [id])
father Human? @relation(name: "Offspring", fields: [father_id], references: [id])
singer Human? @relation(name: "Team", fields: [singer_id], references: [id])
title Song? @relation( fields: [title_id], references: [id])
wife Human? @relation(name: "Marriage", fields: [wife_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
mother Human? @relation(name: "Cuckoo", fields: [mother_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
father Human? @relation(name: "Offspring", fields: [father_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
singer Human? @relation(name: "Team", fields: [singer_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
title Song? @relation( fields: [title_id], references: [id], onDelete: NoAction, onUpdate: NoAction)

daughters Human[] @relation(name: "Offspring")
stepdaughters Human[] @relation(name: "Cuckoo")
Expand All @@ -44,7 +44,7 @@ mod self_relation_filters {
}

// Filter Queries along self relations should succeed with one level.
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn l1_query(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand All @@ -63,7 +63,7 @@ mod self_relation_filters {
}

// Filter Queries along self relations should succeed with two levels.
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn l2_query(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand All @@ -86,7 +86,7 @@ mod self_relation_filters {
}

// Filter Queries along OneToOne self relations should succeed with two levels.
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn l2_one2one(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand All @@ -107,7 +107,7 @@ mod self_relation_filters {
}

// Filter Queries along OneToOne self relations should succeed with null filter.
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn one2one_null(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand All @@ -126,7 +126,7 @@ mod self_relation_filters {
}

// Filter Queries along OneToOne self relations should succeed with {} filter.
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn one2one_empty(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand All @@ -145,7 +145,7 @@ mod self_relation_filters {
}

// Filter Queries along OneToMany self relations should fail with null filter.
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn one2one_null_fail(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand All @@ -167,7 +167,7 @@ mod self_relation_filters {
}

// Filter Queries along OneToMany self relations should succeed with empty filter (`{}`).
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn one2many_empty(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand All @@ -186,7 +186,7 @@ mod self_relation_filters {
}

// Filter Queries along ManyToMany self relations should succeed with valid filter `some`.
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn many2many_some(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand All @@ -208,7 +208,7 @@ mod self_relation_filters {
}

// Filter Queries along ManyToMany self relations should succeed with valid filter `none`.
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn many2many_none(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand All @@ -227,7 +227,7 @@ mod self_relation_filters {
}

// Filter Queries along ManyToMany self relations should succeed with valid filter `every`.
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn many2many_every(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand All @@ -246,7 +246,7 @@ mod self_relation_filters {
}

// Filter Queries along ManyToMany self relations should give an error with null.
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn many2many_null_error(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand All @@ -269,7 +269,7 @@ mod self_relation_filters {
}

// Filter Queries along ManyToMany self relations should succeed with {} filter `some`.
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn many2many_empty_some(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand All @@ -288,7 +288,7 @@ mod self_relation_filters {
}

// Filter Queries along ManyToMany self relations should succeed with {} filter `none`.
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn many2many_empty_none(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand All @@ -308,7 +308,7 @@ mod self_relation_filters {
}

// Filter Queries along ManyToMany self relations should succeed with {} filter `every`.
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn many2many_empty_every(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand All @@ -328,7 +328,7 @@ mod self_relation_filters {
}

// Filter Queries along ManyToOne self relations should succeed valid filter.
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn many2one(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand All @@ -347,7 +347,7 @@ mod self_relation_filters {
}

// Filter Queries along ManyToOne self relations should succeed with {} filter.
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn many2one_empty_filter(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand All @@ -366,7 +366,7 @@ mod self_relation_filters {
}

// Filter Queries along ManyToOne self relations should succeed with null filter.
#[connector_test]
#[connector_test(exclude(SqlServer))]
async fn many2one_null_filter(runner: &Runner) -> TestResult<()> {
test_data(runner).await?;

Expand Down
@@ -1,7 +1,7 @@
use indoc::indoc;
use query_engine_tests::*;

#[test_suite(schema(schema), exclude(SqlServer))]
#[test_suite(schema(schema))]
mod sr_regression {
fn schema() -> String {
let schema = indoc! {
Expand All @@ -11,7 +11,7 @@ mod sr_regression {
name String
parent_id String?

parent Category? @relation(name: "C", fields: [parent_id], references: [id])
parent Category? @relation(name: "C", fields: [parent_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
opposite Category? @relation(name: "C")
}
"#
Expand Down
Expand Up @@ -10,7 +10,7 @@ mod order_by_dependent {
r#"model ModelA {
#id(id, Int, @id)
b_id Int?
b ModelB? @relation(fields: [b_id], references: [id])
b ModelB? @relation(fields: [b_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
c ModelC?
}

Expand Down Expand Up @@ -76,7 +76,7 @@ mod order_by_dependent {
}

// "[Hops: 1] Ordering by related record field ascending with nulls" should "work"
#[connector_test(exclude(SqlServer))]
#[connector_test]
async fn hop_1_related_record_asc_nulls(runner: &Runner) -> TestResult<()> {
create_row(runner, 1, Some(1), Some(1), None).await?;
create_row(runner, 2, Some(2), None, None).await?;
Expand Down Expand Up @@ -140,7 +140,7 @@ mod order_by_dependent {
}

// "[Hops: 2] Ordering by related record field ascending with nulls" should "work"
#[connector_test(exclude(SqlServer))]
#[connector_test]
async fn hop_2_related_record_asc_null(runner: &Runner) -> TestResult<()> {
// 1 record has the "full chain", one half, one none
create_row(runner, 1, Some(1), Some(1), None).await?;
Expand Down Expand Up @@ -171,7 +171,7 @@ mod order_by_dependent {
}

// "[Circular] Ordering by related record field ascending" should "work"
#[connector_test(exclude(SqlServer))]
#[connector_test]
async fn circular_related_record_asc(runner: &Runner) -> TestResult<()> {
// Records form circles with their relations
create_row(runner, 1, Some(1), Some(1), Some(1)).await?;
Expand All @@ -197,7 +197,7 @@ mod order_by_dependent {
}

// "[Circular] Ordering by related record field descending" should "work"
#[connector_test(exclude(SqlServer))]
#[connector_test]
async fn circular_related_record_desc(runner: &Runner) -> TestResult<()> {
// Records form circles with their relations
create_row(runner, 1, Some(1), Some(1), Some(1)).await?;
Expand Down Expand Up @@ -290,7 +290,7 @@ mod order_by_dependent {
#id(id, Int, @id)

b1_id Int?
b1 ModelB? @relation(fields: [b1_id], references: [id], name: "1")
b1 ModelB? @relation(fields: [b1_id], references: [id], name: "1", onDelete: NoAction, onUpdate: NoAction)

b2_id Int?
b2 ModelB? @relation(fields: [b2_id], references: [id], name: "2")
Expand All @@ -307,7 +307,7 @@ mod order_by_dependent {
schema.to_string()
}

#[connector_test(schema(multiple_rel_same_model), exclude(SqlServer, MongoDb))] // Mongo is excluded due to CI issues (version drift?).
#[connector_test(schema(multiple_rel_same_model), exclude(MongoDb))] // Mongo is excluded due to CI issues (version drift?).
async fn multiple_rel_same_model_order_by(runner: &Runner) -> TestResult<()> {
// test data
run_query!(
Expand Down