add test case for custom relation names
@@ -352,6 +352,37 @@ fn adding_a_many_to_many_relation_must_result_in_a_prisma_style_relation_table()
});
}
+#[test]
+fn adding_a_many_to_many_relation_with_custom_name_must_work() {
+ test_each_connector(|_, engine| {
+ let dm1 = r#"
+ model A {
+ id Int @id
+ bs B[] @relation(name: "my_relation")
+ }
+ model B {
+ id Int @id
+ as A[] @relation(name: "my_relation")
+ }
+ "#;
+ let result = infer_and_apply(&engine, &dm1);
+ let relation_table = result.table_bang("_MyRelation");
+ assert_eq!(relation_table.columns.len(), 2);
+ let aColumn = relation_table.column_bang("A");
+ assert_eq!(aColumn.tpe, ColumnType::Int);
+ assert_eq!(
+ aColumn.foreign_key,
+ Some(ForeignKey::new("A".to_string(), "id".to_string()))
+ );
+ let bColumn = relation_table.column_bang("B");
+ assert_eq!(bColumn.tpe, ColumnType::Int);
+ assert_eq!(
+ bColumn.foreign_key,
+ Some(ForeignKey::new("B".to_string(), "id".to_string()))
+ );
+ });
+}
+
#[test]
#[ignore]
fn adding_a_many_to_many_relation_for_exotic_id_types_must_work() {
@@ -583,8 +614,6 @@ fn removing_an_existing_unique_field_must_work() {
});
}
-
-
#[test]
fn adding_unique_to_an_existing_field_must_work() {
test_each_connector(|_, engine| {
