Skip to content

Commit

Permalink
Fix AssertSql() checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
lauxjpn committed Nov 30, 2024
1 parent 6f0b42e commit 42ebb2d
Show file tree
Hide file tree
Showing 24 changed files with 4,822 additions and 1,052 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public override async Task Update_owned_and_non_owned_properties_with_table_shar
"""
UPDATE `Owner` AS `o`
SET `o`.`OwnedReference_Number` = CHAR_LENGTH(`o`.`Title`),
`o`.`Title` = CAST(`o`.`OwnedReference_Number` AS char)
`o`.`Title` = COALESCE(CAST(`o`.`OwnedReference_Number` AS char), '')
""");
}

Expand Down Expand Up @@ -162,7 +162,12 @@ public override async Task Replace_ColumnExpression_in_column_setter(bool async)
{
await base.Replace_ColumnExpression_in_column_setter(async);

AssertSql();
AssertSql(
"""
UPDATE `Owner` AS `o`
INNER JOIN `OwnedCollection` AS `o0` ON `o`.`Id` = `o0`.`OwnerId`
SET `o0`.`Value` = 'SomeValue'
""");
}

private void AssertSql(params string[] expected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1388,12 +1388,12 @@ public override async Task Update_Where_Join_set_property_from_joined_single_res
AssertExecuteUpdateSql(
"""
UPDATE `Customers` AS `c`
SET `c`.`City` = CAST(EXTRACT(year FROM (
SET `c`.`City` = COALESCE(CAST(EXTRACT(year FROM (
SELECT `o`.`OrderDate`
FROM `Orders` AS `o`
WHERE `c`.`CustomerID` = `o`.`CustomerID`
ORDER BY `o`.`OrderDate` DESC
LIMIT 1)) AS char)
LIMIT 1)) AS char), '')
WHERE `c`.`CustomerID` LIKE 'F%'
""");
}
Expand Down Expand Up @@ -1422,12 +1422,12 @@ public override async Task Update_Where_Join_set_property_from_joined_single_res
AssertExecuteUpdateSql(
"""
UPDATE `Customers` AS `c`
SET `c`.`City` = CAST(EXTRACT(year FROM (
SET `c`.`City` = COALESCE(CAST(EXTRACT(year FROM (
SELECT `o`.`OrderDate`
FROM `Orders` AS `o`
WHERE `c`.`CustomerID` = `o`.`CustomerID`
ORDER BY `o`.`OrderDate` DESC
LIMIT 1)) AS char)
LIMIT 1)) AS char), '')
WHERE `c`.`CustomerID` LIKE 'F%'
""");
}
Expand Down
18 changes: 18 additions & 0 deletions test/EFCore.MySql.FunctionalTests/GraphUpdatesMySqlTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con

modelBuilder.Entity<SomethingOfCategoryA>().Property<int>("CategoryId").HasDefaultValue(1);
modelBuilder.Entity<SomethingOfCategoryB>().Property(e => e.CategoryId).HasDefaultValue(2);

modelBuilder.Entity<CompositeKeyWith<int>>(
b =>
{
b.Property(e => e.PrimaryGroup).HasDefaultValue(1).HasSentinel(1);
});

modelBuilder.Entity<CompositeKeyWith<bool>>(
b =>
{
b.Property(e => e.PrimaryGroup).HasDefaultValue(true);
});

modelBuilder.Entity<CompositeKeyWith<bool?>>(
b =>
{
b.Property(e => e.PrimaryGroup).HasDefaultValue(true);
});
}
}
}
Loading

0 comments on commit 42ebb2d

Please sign in to comment.