Skip to content

Commit

Permalink
Repro for #3274 (#3275)
Browse files Browse the repository at this point in the history
* Repro for #3274

* fix formatting

* fix test

Co-authored-by: MaceWindu <MaceWindu@users.noreply.github.com>
  • Loading branch information
AndreyAndryushinPSB and MaceWindu committed Oct 20, 2021
1 parent 3275c02 commit 8dbd58b
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Tests/Linq/Update/UpdateTests.cs
Expand Up @@ -683,6 +683,48 @@ public async Task UpdateComplex1Async([DataSources] string context)
}
}

[Test]
public void SetWithTernaryOperatorIssue([DataSources] string context)
{
Gender? nullableGender = Gender.Other;

ResetPersonIdentity(context);

using (var db = GetDataContext(context))
{
db.Person.Where(_ => _.FirstName.StartsWith("UpdateComplex")).Delete();
try
{
var id = Convert.ToInt32(db.InsertWithIdentity(
new ComplexPerson2
{
Name = new FullName
{
FirstName = "UpdateComplex",
LastName = "Empty",
},
Gender = Gender.Male
}));

var cnt = db.GetTable<ComplexPerson2>()
.Where(_ => _.Name.FirstName.StartsWith("UpdateComplex"))
.Set(_ => _.Gender, _ => nullableGender.HasValue ? nullableGender.Value : _.Gender)
.Update();

Assert.AreEqual(1, cnt);

var obj = db.GetTable<ComplexPerson2>()
.First(_ => _.ID == id);

Assert.AreEqual(Gender.Other, obj.Gender);
}
finally
{
db.Person.Where(_ => _.FirstName.StartsWith("UpdateComplex")).Delete();
}
}
}

[Test]
public void UpdateComplex2([DataSources] string context)
{
Expand Down

0 comments on commit 8dbd58b

Please sign in to comment.