We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Version: 5.2.3 from NuGet
Code to reproduce:
session.Save(new TestClass { Int32Prop = Int32.MaxValue }); session.Save(new TestClass { Int32Prop = Int32.MaxValue }); session.Query<TestClass>() .GroupBy(i => 1) .Select(g => new { s = g.Sum(i => (long)i.Int32Prop) }) .ToArray();
Generated SQL
select cast(sum(testclass0_.Int32Prop) as BIGINT) as col_0_0_ from TestClass testclass0_
fails with
Arithmetic overflow error converting expression to data type int.
Looks like sum and cast should be swapped. This runs fine:
sum
cast
select sum(cast(testclass0_.Int32Prop as BIGINT)) as col_0_0_ from TestClass testclass0_
Test class and mapping:
public class TestClass { public virtual int Id { get; set; } public virtual int? Int32Prop { get; set; } } public class TestClassMap : ClassMap<TestClass> { public TestClassMap() { Table("TestClass"); Id(i => i.Id); Map(i => i.Int32Prop); } }
The text was updated successfully, but these errors were encountered:
UPDATE
The bug is reproduced only with Nullable properties. For plain int, two cast are issued and no exception occurs:
int
select cast(sum(cast(testclass0_.Int32Prop as BIGINT)) as BIGINT) as col_0_0_ from TestClass testclass0_
Sorry, something went wrong.
Made a PR that fixes the issue with nullable types and also reduces the cast usage. For your example only one cast will be generated for int and int?.
int?
Successfully merging a pull request may close this issue.
Version: 5.2.3 from NuGet
Code to reproduce:
Generated SQL
fails with
Looks like
sum
andcast
should be swapped.This runs fine:
Test class and mapping:
The text was updated successfully, but these errors were encountered: